(ctx context.Context, image string)
| 13 | ) |
| 14 | |
| 15 | func LoadDockerAuthConfig(ctx context.Context, image string) (registry.AuthConfig, error) { |
| 16 | logger := common.Logger(ctx) |
| 17 | config, err := config.Load(config.Dir()) |
| 18 | if err != nil { |
| 19 | logger.Warnf("Could not load docker config: %v", err) |
| 20 | return registry.AuthConfig{}, err |
| 21 | } |
| 22 | |
| 23 | if !config.ContainsAuth() { |
| 24 | config.CredentialsStore = credentials.DetectDefaultStore(config.CredentialsStore) |
| 25 | } |
| 26 | |
| 27 | hostName := "index.docker.io" |
| 28 | index := strings.IndexRune(image, '/') |
| 29 | if index > -1 && (strings.ContainsAny(image[:index], ".:") || image[:index] == "localhost") { |
| 30 | hostName = image[:index] |
| 31 | } |
| 32 | |
| 33 | authConfig, err := config.GetAuthConfig(hostName) |
| 34 | if err != nil { |
| 35 | logger.Warnf("Could not get auth config from docker config: %v", err) |
| 36 | return registry.AuthConfig{}, err |
| 37 | } |
| 38 | |
| 39 | return registry.AuthConfig(authConfig), nil |
| 40 | } |
| 41 | |
| 42 | func LoadDockerAuthConfigs(ctx context.Context) map[string]registry.AuthConfig { |
| 43 | logger := common.Logger(ctx) |
no test coverage detected
searching dependent graphs…