Skip to content

Commit 8293142

Browse files
authored
Merge pull request #1432 from mtrmac/GetAllCredentials-not-found
Fix handling of missing data in GetAllCredentials
2 parents a36c455 + 390990b commit 8293142

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pkg/docker/config/config.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,12 @@ func GetAllCredentials(sys *types.SystemContext) (map[string]types.DockerAuthCon
190190
for key := range allKeys {
191191
authConf, err := GetCredentials(sys, key)
192192
if err != nil {
193-
if credentials.IsErrCredentialsNotFoundMessage(err.Error()) {
194-
// Ignore if the credentials could not be found (anymore).
195-
continue
196-
}
197193
// Note: we rely on the logging in `GetCredentials`.
198194
return nil, err
199195
}
200-
authConfigs[key] = authConf
196+
if authConf != (types.DockerAuthConfig{}) {
197+
authConfigs[key] = authConf
198+
}
201199
}
202200

203201
return authConfigs, nil
@@ -285,7 +283,7 @@ func getCredentialsWithHomeDir(sys *types.SystemContext, key, homeDir string) (t
285283
return types.DockerAuthConfig{}, "", err
286284
}
287285

288-
if (authConfig.Username != "" && authConfig.Password != "") || authConfig.IdentityToken != "" {
286+
if authConfig != (types.DockerAuthConfig{}) {
289287
return authConfig, path.path, nil
290288
}
291289
}

pkg/docker/config/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,7 @@ func TestGetAllCredentials(t *testing.T) {
551551
os.Setenv("DOCKER_CONFIG", filepath.Join(path, "testdata"))
552552
authConfigs, err := GetAllCredentials(nil)
553553
require.NoError(t, err)
554-
require.Len(t, authConfigs, 1)
555-
require.Equal(t, authConfigs["registry-no-creds.com"], types.DockerAuthConfig{})
554+
require.Empty(t, authConfigs)
556555
os.Unsetenv("DOCKER_CONFIG")
557556

558557
for _, data := range [][]struct {

0 commit comments

Comments
 (0)