Skip to content

Commit

Permalink
no error reported by DockerKeychain if pull secret can't be read
Browse files Browse the repository at this point in the history
  • Loading branch information
aorcholski committed Jul 4, 2024
1 parent b6c318d commit 0a19682
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/oci/dockerkeychain/docker_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (keychain *DockerKeychain) loadDockerConfigFromSecrets(ctx context.Context,
pullSecret := corev1.Secret{}

if err := apiReader.Get(ctx, client.ObjectKey{Namespace: namespaceName, Name: pullSecretName}, &pullSecret); err != nil {
log.Info("failed to load registry pull secret", "name", pullSecretName, "namespace", namespaceName)
log.Info("registry pull secret not loaded", "name", pullSecretName, "namespace", namespaceName)

return errors.WithStack(err)
continue
}

dockerAuths, err := extractDockerAuthsFromSecret(&pullSecret)
Expand All @@ -59,9 +59,12 @@ func (keychain *DockerKeychain) loadDockerConfigFromSecrets(ctx context.Context,
}
}

keychain.dockerConfig = &configFile

log.Debug("loaded docker configs", "registries", maps.Keys(configFile.AuthConfigs))
if len(configFile.AuthConfigs) > 0 {
keychain.dockerConfig = &configFile
log.Debug("loaded docker configs", "registries", maps.Keys(configFile.AuthConfigs))
} else {
log.Debug("no docker configs found")
}

return nil
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/oci/dockerkeychain/docker_keychain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,12 @@ func TestNewDockerKeychain(t *testing.T) {
assert.Equal(t, testPassword, auth.Password)
})
}

func TestNewDockerKeychains(t *testing.T) {
t.Run("tenant secret not found", func(t *testing.T) {
client := fake.NewClient()

_, err := NewDockerKeychains(context.TODO(), client, "dynatrace", []string{"dynakube-pull-secret"})
require.NoError(t, err)
})
}

0 comments on commit 0a19682

Please sign in to comment.