t/cmd: make credential helper produce useful errors
The credential helper can fail in some cases when it gets data that doesn't contain a colon. In such a case, make it print a useful error instead of panicking.
This commit is contained in:
parent
56fc55a33f
commit
1b2e4c3d4e
@ -118,6 +118,9 @@ func credsFromFilename(file string) (string, string, error) {
|
|||||||
return "", "", fmt.Errorf("Error opening %q: %s", file, err)
|
return "", "", fmt.Errorf("Error opening %q: %s", file, err)
|
||||||
}
|
}
|
||||||
credsPieces := strings.SplitN(strings.TrimSpace(string(userPass)), ":", 2)
|
credsPieces := strings.SplitN(strings.TrimSpace(string(userPass)), ":", 2)
|
||||||
|
if len(credsPieces) != 2 {
|
||||||
|
return "", "", fmt.Errorf("Invalid data %q while reading %q", string(userPass), file)
|
||||||
|
}
|
||||||
return credsPieces[0], credsPieces[1], nil
|
return credsPieces[0], credsPieces[1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user