Skip to content

Commit

Permalink
ecrClient now is ecternal function
Browse files Browse the repository at this point in the history
Signed-off-by: alexey.komyakov <[email protected]>
  • Loading branch information
scaps1 committed Oct 25, 2024
1 parent f048c93 commit 8ca7f0a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/registry/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ func parseRegion(reference name.Reference) (string, error) {
return "", nil
}

func awsClient(region string) (*ecr.Client, error) {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
if err != nil {
return nil, err
}

client := ecr.NewFromConfig(cfg)
return client, nil
}

func check(ref name.Reference, kc authn.Keychain, registryTransport http.RoundTripper) (store.AvailabilityMode, error) {
var imgErr error

Expand Down Expand Up @@ -446,13 +456,12 @@ func check(ref name.Reference, kc authn.Keychain, registryTransport http.RoundTr
}

func isImageInEcr(ref name.Reference, region string) bool {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
ecrClient, err := awsClient(region)
if err != nil {
logrus.Errorf("Failed to load AWS SDK config: %v", err)
logrus.Warningf("Failed to load aws configuration: %v", err)
return false
}

ecrClient := ecr.NewFromConfig(cfg)
accountID, _ := parseAccountID(ref)
input := &ecr.BatchGetImageInput{
RegistryId: aws.String(accountID),
Expand Down

0 comments on commit 8ca7f0a

Please sign in to comment.