mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #85075 from hwdef/fix-staticcheck9
pkg/credentialprovider: fix staticcheck warning
This commit is contained in:
commit
6eb2f25247
@ -15,8 +15,6 @@ pkg/controller/podgc
|
||||
pkg/controller/replicaset
|
||||
pkg/controller/resourcequota
|
||||
pkg/controller/statefulset
|
||||
pkg/credentialprovider
|
||||
pkg/credentialprovider/aws
|
||||
pkg/kubeapiserver/admission
|
||||
pkg/kubelet/apis/podresources
|
||||
pkg/kubelet/cm/devicemanager
|
||||
|
@ -196,7 +196,7 @@ func TestECRProvide(t *testing.T) {
|
||||
// Verify that we get an error for other images.
|
||||
for _, otherRegistry := range otherRegistries {
|
||||
image = path.Join(otherRegistry, "foo/bar")
|
||||
creds, ok = keyring.Lookup(image)
|
||||
_, ok = keyring.Lookup(image)
|
||||
if ok {
|
||||
t.Errorf("Unexpectedly found image: %s", image)
|
||||
return
|
||||
@ -293,7 +293,7 @@ func TestChinaECRProvide(t *testing.T) {
|
||||
// Verify that we get an error for other images.
|
||||
for _, otherRegistry := range otherRegistries {
|
||||
image = path.Join(otherRegistry, image)
|
||||
creds, ok = keyring.Lookup(image)
|
||||
_, ok = keyring.Lookup(image)
|
||||
if ok {
|
||||
t.Errorf("Unexpectedly found image: %s", image)
|
||||
return
|
||||
|
@ -91,22 +91,22 @@ func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, erro
|
||||
|
||||
var challenge *http.Response
|
||||
if challenge, err = client.Do(r); err != nil {
|
||||
return nil, fmt.Errorf("Error reaching registry endpoint %s, error: %s", challengeURL.String(), err)
|
||||
return nil, fmt.Errorf("error reaching registry endpoint %s, error: %s", challengeURL.String(), err)
|
||||
}
|
||||
defer challenge.Body.Close()
|
||||
|
||||
if challenge.StatusCode != 401 {
|
||||
return nil, fmt.Errorf("Registry did not issue a valid AAD challenge, status: %d", challenge.StatusCode)
|
||||
return nil, fmt.Errorf("registry did not issue a valid AAD challenge, status: %d", challenge.StatusCode)
|
||||
}
|
||||
|
||||
var authHeader []string
|
||||
var ok bool
|
||||
if authHeader, ok = challenge.Header["Www-Authenticate"]; !ok {
|
||||
return nil, fmt.Errorf("Challenge response does not contain header 'Www-Authenticate'")
|
||||
return nil, fmt.Errorf("challenge response does not contain header 'Www-Authenticate'")
|
||||
}
|
||||
|
||||
if len(authHeader) != 1 {
|
||||
return nil, fmt.Errorf("Registry did not issue a valid AAD challenge, authenticate header [%s]",
|
||||
return nil, fmt.Errorf("registry did not issue a valid AAD challenge, authenticate header [%s]",
|
||||
strings.Join(authHeader, ", "))
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, erro
|
||||
authType := strings.ToLower(authSections[0])
|
||||
var authParams *map[string]string
|
||||
if authParams, err = parseAssignments(authSections[1]); err != nil {
|
||||
return nil, fmt.Errorf("Unable to understand the contents of Www-Authenticate header %s", authSections[1])
|
||||
return nil, fmt.Errorf("unable to understand the contents of Www-Authenticate header %s", authSections[1])
|
||||
}
|
||||
|
||||
// verify headers
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
func TestReadDockerConfigFile(t *testing.T) {
|
||||
configJsonFileName := "config.json"
|
||||
var fileInfo *os.File
|
||||
preferredPaths := []string{}
|
||||
|
||||
//test dockerconfig json
|
||||
inputDockerconfigJsonFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"
|
||||
@ -40,7 +39,6 @@ func TestReadDockerConfigFile(t *testing.T) {
|
||||
return
|
||||
}
|
||||
defer os.RemoveAll(preferredPath)
|
||||
preferredPaths = append(preferredPaths, preferredPath)
|
||||
absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(preferredPath, configJsonFileName))
|
||||
if err != nil {
|
||||
t.Fatalf("While trying to canonicalize %s: %v", preferredPath, err)
|
||||
|
@ -265,7 +265,7 @@ func TestContainerRegistryBasics(t *testing.T) {
|
||||
}
|
||||
val := creds[0]
|
||||
|
||||
if "_token" != val.Username {
|
||||
if val.Username != "_token" {
|
||||
t.Errorf("Unexpected username value, want: %s, got: %s", "_token", val.Username)
|
||||
}
|
||||
if token.AccessToken != val.Password {
|
||||
|
Loading…
Reference in New Issue
Block a user