Skip to content

Commit

Permalink
image-copy-ecr: avoid spammy misleading error log when pushing to cgr…
Browse files Browse the repository at this point in the history
….dev (#210)

```
// Ordering matters here, as the first keychain that can resolve the resource will be used.
// When pushing to CGR we want to try the Chainguard keychain first, since the ECR keychain
// logs a misleading error message when it's invoked for a non-ECR registry. The CGR keychain
// does not log such an error, so it's better to try it first.
```

Signed-off-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
imjasonh authored Aug 22, 2024
1 parent ab16fc9 commit 6181fda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion image-copy-ecr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ func handler(ctx context.Context, levent events.LambdaFunctionURLRequest) (resp
src := "cgr.dev/" + body.Repository + ":" + body.Tag
dst := filepath.Join(env.FullDstRepo, filepath.Base(body.Repository)) + ":" + body.Tag
kc := authn.NewMultiKeychain(
amazonKeychain,
// Ordering matters here, as the first keychain that can resolve the resource will be used.
// When pushing to CGR we want to try the Chainguard keychain first, since the ECR keychain
// logs a misleading error message when it's invoked for a non-ECR registry. The CGR keychain
// does not log such an error, so it's better to try it first.
cgKeychain{env.Issuer, env.Region, env.Identity},
amazonKeychain,
)
if env.ImmutableTags {
dig, err := crane.Digest(src, crane.WithAuthFromKeychain(kc))
Expand Down

0 comments on commit 6181fda

Please sign in to comment.