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 {
|
if n > decLen {
|
||||||
return "", "", errors.Errorf("Something went wrong decoding auth config")
|
return "", "", errors.Errorf("Something went wrong decoding auth config")
|
||||||
}
|
}
|
||||||
arr := strings.SplitN(string(decoded), ":", 2)
|
userName, password, ok := strings.Cut(string(decoded), ":")
|
||||||
if len(arr) != 2 {
|
if !ok || userName == "" {
|
||||||
return "", "", errors.Errorf("Invalid auth configuration file")
|
return "", "", errors.Errorf("Invalid auth configuration file")
|
||||||
}
|
}
|
||||||
password := strings.Trim(arr[1], "\x00")
|
return userName, strings.Trim(password, "\x00"), nil
|
||||||
return arr[0], password, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCredentialsStore returns a new credentials store from the settings in the
|
// 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://")
|
stripped = strings.TrimPrefix(url, "https://")
|
||||||
}
|
}
|
||||||
|
|
||||||
nameParts := strings.SplitN(stripped, "/", 2)
|
hostName, _, _ := strings.Cut(stripped, "/")
|
||||||
|
return hostName
|
||||||
return nameParts[0]
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue