From e0b959432c6b567ffea32d59540145961402999e Mon Sep 17 00:00:00 2001 From: Min Uk Lee Date: Sun, 28 Apr 2024 15:48:26 +0900 Subject: [PATCH] wip --- pkg/imgutil/imgutil.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/imgutil/imgutil.go b/pkg/imgutil/imgutil.go index e51850920a9..7814383e8cc 100644 --- a/pkg/imgutil/imgutil.go +++ b/pkg/imgutil/imgutil.go @@ -138,6 +138,13 @@ func EnsureImage(ctx context.Context, client *containerd.Client, stdout, stderr dOpts = append(dOpts, dockerconfigresolver.WithSkipVerifyCerts(true)) } dOpts = append(dOpts, dockerconfigresolver.WithHostsDirs(hostsDirs)) + authCreds, err := dockerconfigresolver.NewAuthCreds(refDomain) + if err != nil { + log.G(ctx).WithError(err).Warnf("failed to get auth creds for %q", refDomain) + } + if authCreds != nil { + dOpts = append(dOpts, dockerconfigresolver.WithAuthCreds(authCreds)) + } resolver, err := dockerconfigresolver.New(ctx, refDomain, dOpts...) if err != nil { return nil, err @@ -181,6 +188,16 @@ func ResolveDigest(ctx context.Context, rawRef string, insecure bool, hostsDirs dOpts = append(dOpts, dockerconfigresolver.WithSkipVerifyCerts(true)) } dOpts = append(dOpts, dockerconfigresolver.WithHostsDirs(hostsDirs)) + if err != nil { + log.G(ctx).WithError(err).Warnf("failed to get auth creds for %q", refDomain) + } + authCreds, err := dockerconfigresolver.NewAuthCreds(refDomain) + if err != nil { + log.G(ctx).WithError(err).Warnf("failed to get auth creds for %q", refDomain) + } + if authCreds != nil { + dOpts = append(dOpts, dockerconfigresolver.WithAuthCreds(authCreds)) + } resolver, err := dockerconfigresolver.New(ctx, refDomain, dOpts...) if err != nil { return "", err