Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle no docker auth and log only a warning when getting auth credentials fails #2579

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ func storeConfigInVolume(
for _, registry := range registries {
creds, err := docker_manager.GetAuthFromDockerConfig(registry)
if err != nil {
return stacktrace.NewError("An error occurred getting auth for registry '%v' from Docker config: %v", registry, err)
logrus.Warnf("An error occurred getting auth for registry '%v' from Docker config: %v", registry, err)
}
// creds can be nil if the registry doesn't have auth
if err != nil && creds != nil {
cfg.Auths[registry] = *creds
}
cfg.Auths[registry] = *creds
}

cfgJsonStr, err := json.Marshal(cfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ func writeStaticConfig(t *testing.T, configContent string) string {
return tmpDir
}

func TestGetNoAuth(t *testing.T) {
os.Setenv(ENV_DOCKER_CONFIG, "/does/not/exist")
authConfig, err := GetAuthFromDockerConfig("my-repo/my-image:latest")
assert.NoError(t, err)
assert.Nil(t, authConfig, "Auth config should be nil")
}

func TestGetAuthConfigForRepoPlain(t *testing.T) {
expectedUser := "user"
expectedPassword := "password"
Expand Down
Loading