MCPcopy
hub / github.com/nektos/act / LoadDockerAuthConfig

Function LoadDockerAuthConfig

pkg/container/docker_auth.go:15–40  ·  view source on GitHub ↗
(ctx context.Context, image string)

Source from the content-addressed store, hash-verified

13)
14
15func 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
42func LoadDockerAuthConfigs(ctx context.Context) map[string]registry.AuthConfig {
43 logger := common.Logger(ctx)

Callers 1

getImagePullOptionsFunction · 0.85

Calls 1

LoggerFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…