Skip to content

Commit

Permalink
fix: auth with no docker config
Browse files Browse the repository at this point in the history
Don't error when looking up auth if no docker configuration file exists,
instead treat it as no authentication was provided.

Fixes #2767
  • Loading branch information
stevenh committed Sep 7, 2024
1 parent 553afd3 commit 1aad304
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func configFileKey() (string, error) {
func getDockerAuthConfigs() (map[string]registry.AuthConfig, error) {
cfg, err := getDockerConfig()
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return map[string]registry.AuthConfig{}, nil
}

return nil, err
}

Expand Down
11 changes: 11 additions & 0 deletions docker_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,15 @@ func Test_getDockerAuthConfigs(t *testing.T) {
}
require.Equal(t, expected, got)
})

t.Run("file-not-found", func(t *testing.T) {
t.Setenv("DOCKER_CONFIG", "")
tmp := t.TempDir()
t.Setenv("HOME", tmp)
t.Setenv("USERPROFILE", tmp) // Windows

cfg, err := getDockerAuthConfigs()
require.NoError(t, err)
require.Empty(t, cfg)
})
}

0 comments on commit 1aad304

Please sign in to comment.