Skip to content

Commit

Permalink
feat: use credential helper in docker config, even if auth is empty i…
Browse files Browse the repository at this point in the history
…n .docker/config.json (#1079)

* use credential helper in docker config, even if auth is empty in .docker/config.json

* fix: simplify for loop skipping value

* simplified check for auth configs

* always add auth from credential helpers

---------

Co-authored-by: Joana Roque Durão <joana@kramphub.com>
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
  • Loading branch information
4 people authored Aug 9, 2023
1 parent c9c4a75 commit de74538
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docker_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ func getDockerAuthConfigs() (map[string]registry.AuthConfig, error) {
cfgs[k] = ac
}

// in the case where the auth field in the .docker/conf.json is empty, and the user has credential helpers registered
// the auth comes from there
for k := range cfg.CredentialHelpers {
ac := registry.AuthConfig{}
u, p, _ := dockercfg.GetRegistryCredentials(k)
ac.Username = u
ac.Password = p

cfgs[k] = ac
}

return cfgs, nil
}

Expand All @@ -96,7 +107,6 @@ func getDockerConfig() (dockercfg.Config, error) {
if err == nil {
return cfg, nil
}

}

cfg, err := dockercfg.LoadDefaultConfig()
Expand Down

0 comments on commit de74538

Please sign in to comment.