mirror of https://github.com/docker/cli.git
cli/config: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
3bed830a27
commit
c8bd8932a1
|
@ -241,12 +241,11 @@ func decodeAuth(authStr string) (string, string, error) {
|
|||
if n > decLen {
|
||||
return "", "", errors.Errorf("Something went wrong decoding auth config")
|
||||
}
|
||||
arr := strings.SplitN(string(decoded), ":", 2)
|
||||
if len(arr) != 2 {
|
||||
userName, password, ok := strings.Cut(string(decoded), ":")
|
||||
if !ok || userName == "" {
|
||||
return "", "", errors.Errorf("Invalid auth configuration file")
|
||||
}
|
||||
password := strings.Trim(arr[1], "\x00")
|
||||
return arr[0], password, nil
|
||||
return userName, strings.Trim(password, "\x00"), nil
|
||||
}
|
||||
|
||||
// GetCredentialsStore returns a new credentials store from the settings in the
|
||||
|
|
|
@ -75,7 +75,6 @@ func ConvertToHostname(url string) string {
|
|||
stripped = strings.TrimPrefix(url, "https://")
|
||||
}
|
||||
|
||||
nameParts := strings.SplitN(stripped, "/", 2)
|
||||
|
||||
return nameParts[0]
|
||||
hostName, _, _ := strings.Cut(stripped, "/")
|
||||
return hostName
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue