mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +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/replicaset
|
||||||
pkg/controller/resourcequota
|
pkg/controller/resourcequota
|
||||||
pkg/controller/statefulset
|
pkg/controller/statefulset
|
||||||
pkg/credentialprovider
|
|
||||||
pkg/credentialprovider/aws
|
|
||||||
pkg/kubeapiserver/admission
|
pkg/kubeapiserver/admission
|
||||||
pkg/kubelet/apis/podresources
|
pkg/kubelet/apis/podresources
|
||||||
pkg/kubelet/cm/devicemanager
|
pkg/kubelet/cm/devicemanager
|
||||||
|
@ -196,7 +196,7 @@ func TestECRProvide(t *testing.T) {
|
|||||||
// Verify that we get an error for other images.
|
// Verify that we get an error for other images.
|
||||||
for _, otherRegistry := range otherRegistries {
|
for _, otherRegistry := range otherRegistries {
|
||||||
image = path.Join(otherRegistry, "foo/bar")
|
image = path.Join(otherRegistry, "foo/bar")
|
||||||
creds, ok = keyring.Lookup(image)
|
_, ok = keyring.Lookup(image)
|
||||||
if ok {
|
if ok {
|
||||||
t.Errorf("Unexpectedly found image: %s", image)
|
t.Errorf("Unexpectedly found image: %s", image)
|
||||||
return
|
return
|
||||||
@ -293,7 +293,7 @@ func TestChinaECRProvide(t *testing.T) {
|
|||||||
// Verify that we get an error for other images.
|
// Verify that we get an error for other images.
|
||||||
for _, otherRegistry := range otherRegistries {
|
for _, otherRegistry := range otherRegistries {
|
||||||
image = path.Join(otherRegistry, image)
|
image = path.Join(otherRegistry, image)
|
||||||
creds, ok = keyring.Lookup(image)
|
_, ok = keyring.Lookup(image)
|
||||||
if ok {
|
if ok {
|
||||||
t.Errorf("Unexpectedly found image: %s", image)
|
t.Errorf("Unexpectedly found image: %s", image)
|
||||||
return
|
return
|
||||||
|
@ -91,22 +91,22 @@ func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, erro
|
|||||||
|
|
||||||
var challenge *http.Response
|
var challenge *http.Response
|
||||||
if challenge, err = client.Do(r); err != nil {
|
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()
|
defer challenge.Body.Close()
|
||||||
|
|
||||||
if challenge.StatusCode != 401 {
|
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 authHeader []string
|
||||||
var ok bool
|
var ok bool
|
||||||
if authHeader, ok = challenge.Header["Www-Authenticate"]; !ok {
|
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 {
|
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, ", "))
|
strings.Join(authHeader, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, erro
|
|||||||
authType := strings.ToLower(authSections[0])
|
authType := strings.ToLower(authSections[0])
|
||||||
var authParams *map[string]string
|
var authParams *map[string]string
|
||||||
if authParams, err = parseAssignments(authSections[1]); err != nil {
|
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
|
// verify headers
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
func TestReadDockerConfigFile(t *testing.T) {
|
func TestReadDockerConfigFile(t *testing.T) {
|
||||||
configJsonFileName := "config.json"
|
configJsonFileName := "config.json"
|
||||||
var fileInfo *os.File
|
var fileInfo *os.File
|
||||||
preferredPaths := []string{}
|
|
||||||
|
|
||||||
//test dockerconfig json
|
//test dockerconfig json
|
||||||
inputDockerconfigJsonFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"
|
inputDockerconfigJsonFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"
|
||||||
@ -40,7 +39,6 @@ func TestReadDockerConfigFile(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(preferredPath)
|
defer os.RemoveAll(preferredPath)
|
||||||
preferredPaths = append(preferredPaths, preferredPath)
|
|
||||||
absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(preferredPath, configJsonFileName))
|
absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(preferredPath, configJsonFileName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("While trying to canonicalize %s: %v", preferredPath, err)
|
t.Fatalf("While trying to canonicalize %s: %v", preferredPath, err)
|
||||||
|
@ -265,7 +265,7 @@ func TestContainerRegistryBasics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
val := creds[0]
|
val := creds[0]
|
||||||
|
|
||||||
if "_token" != val.Username {
|
if val.Username != "_token" {
|
||||||
t.Errorf("Unexpected username value, want: %s, got: %s", "_token", val.Username)
|
t.Errorf("Unexpected username value, want: %s, got: %s", "_token", val.Username)
|
||||||
}
|
}
|
||||||
if token.AccessToken != val.Password {
|
if token.AccessToken != val.Password {
|
||||||
|
Loading…
Reference in New Issue
Block a user