Skip to content

Commit fd47a25

Browse files
authored
Merge pull request #28 from humblec/build
Fix unknown struct field reference and variable assignment in iscsi library
2 parents 4eea777 + dd4a7fc commit fd47a25

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

iscsi/iscsi.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ type Connector struct {
5959
CheckInterval int32 `json:"check_interval"`
6060
DoDiscovery bool `json:"do_discovery"`
6161
DoCHAPDiscovery bool `json:"do_chap_discovery"`
62+
TargetIqn string `json:"target_iqn"`
63+
TargetPortals []string `json:"target_portals"`
6264
}
6365

6466
func init() {
@@ -75,7 +77,7 @@ func EnableDebugLogging(writer io.Writer) {
7577

7678
// parseSession takes the raw stdout from the iscsiadm -m session command and encodes it into an iscsi session type
7779
func parseSessions(lines string) []iscsiSession {
78-
entries := strings.Split(strings.TrimSpace(string(lines)), "\n")
80+
entries := strings.Split(strings.TrimSpace(lines), "\n")
7981
r := strings.NewReplacer("[", "",
8082
"]", "")
8183

@@ -146,7 +148,7 @@ func waitForPathToExist(devicePath *string, maxRetries, intervalSeconds int, dev
146148

147149
func waitForPathToExistImpl(devicePath *string, maxRetries, intervalSeconds int, deviceTransport string, osStat statFunc, filepathGlob globFunc) (bool, error) {
148150
if devicePath == nil {
149-
return false, fmt.Errorf("Unable to check unspecified devicePath")
151+
return false, fmt.Errorf("unable to check unspecified devicePath")
150152
}
151153

152154
var err error
@@ -224,7 +226,7 @@ func getMultipathDisk(path string) (string, error) {
224226
}
225227
}
226228
debug.Printf("Couldn't find dm-* path for path: %s, found non dm-* path: %s", path, devicePath)
227-
return "", fmt.Errorf("Couldn't find dm-* path for path: %s, found non dm-* path: %s", path, devicePath)
229+
return "", fmt.Errorf("couldn't find dm-* path for path: %s, found non dm-* path: %s", path, devicePath)
228230
}
229231

230232
// Connect attempts to connect a volume to this node using the provided Connector info
@@ -238,7 +240,7 @@ func Connect(c Connector) (string, error) {
238240
}
239241

240242
if c.RetryCount < 0 || c.CheckInterval < 0 {
241-
return "", fmt.Errorf("Invalid RetryCount and CheckInterval combination, both must be positive integers. "+
243+
return "", fmt.Errorf("invalid RetryCount and CheckInterval combination, both must be positive integers. "+
242244
"RetryCount: %d, CheckInterval: %d", c.RetryCount, c.CheckInterval)
243245
}
244246
var devicePaths []string
@@ -316,7 +318,7 @@ func Connect(c Connector) (string, error) {
316318
devicePaths = append(devicePaths, devicePath)
317319
continue
318320
} else if err != nil {
319-
lastErr = fmt.Errorf("Couldn't attach disk, err: %v", err)
321+
lastErr = fmt.Errorf("couldn't attach disk, err: %v", err)
320322
}
321323
}
322324

@@ -376,7 +378,7 @@ func DisconnectVolume(c Connector) error {
376378
if err != nil {
377379
return err
378380
}
379-
err := FlushMultipathDevice(c.DevicePath)
381+
err = FlushMultipathDevice(c.DevicePath)
380382
if err != nil {
381383
return err
382384
}
@@ -456,7 +458,7 @@ func GetConnectorFromFile(filePath string) (*Connector, error) {
456458

457459
}
458460
data := Connector{}
459-
err = json.Unmarshal([]byte(f), &data)
461+
err = json.Unmarshal(f, &data)
460462
if err != nil {
461463
return &Connector{}, err
462464
}

iscsi/iscsiadm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func Discoverydb(tp, iface string, discoverySecrets Secrets, chapDiscovery bool)
116116
baseArgs := []string{"-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", iface}
117117
out, err := iscsiCmd(append(baseArgs, []string{"-o", "new"}...)...)
118118
if err != nil {
119-
return fmt.Errorf("failed to create new entry of target in discoverydb, output: %v, err: %v", string(out), err)
119+
return fmt.Errorf("failed to create new entry of target in discoverydb, output: %v, err: %v", out, err)
120120
}
121121

122122
if chapDiscovery {

0 commit comments

Comments
 (0)