From 931b868ca47994f8a9d1a641acc41f7e8628ae3e Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Mon, 19 Aug 2024 23:37:47 +0100 Subject: [PATCH] debugging: for auth errors Add debugging to help identify why we get no auth. --- docker.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docker.go b/docker.go index 283ab7db34b..0247c65da3f 100644 --- a/docker.go +++ b/docker.go @@ -22,6 +22,7 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/containerd/platforms" + "github.com/cpuguy83/dockercfg" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" @@ -1321,7 +1322,17 @@ func (p *DockerProvider) ReuseOrCreateContainer(ctx context.Context, req Contain func (p *DockerProvider) attemptToPullImage(ctx context.Context, tag string, pullOpt image.PullOptions) error { registry, imageAuth, err := DockerImageAuth(ctx, tag) if err != nil { - p.Logger.Printf("Failed to get image auth for %s. Setting empty credentials for the image: %s. Error is: %s", registry, tag, err) + cfg, errc := getDockerConfig() + path, errp := dockercfg.UserHomeConfigPath() + p.Logger.Printf("DOCKER_AUTH_CONFIG: %q DOCKER_CONFIG: %q path: %q, config: %#v errc: %v errp: %v", + os.Getenv("DOCKER_AUTH_CONFIG"), + os.Getenv("DOCKER_CONFIG"), + path, + cfg, + errc, + errp, + ) + p.Logger.Printf("Failed to get image auth for %s. Setting empty credentials for the image: %s. Error is: %s Config: %#v", registry, tag, err) } else { // see https://github.com/docker/docs/blob/e8e1204f914767128814dca0ea008644709c117f/engine/api/sdk/examples.md?plain=1#L649-L657 encodedJSON, err := json.Marshal(imageAuth)