Skip to content

Commit

Permalink
Merge pull request porter-dev#797 from porter-dev/0.4.1-fix-ecr-loading
Browse files Browse the repository at this point in the history
[0.4.1] Remove max results from ECR loading and add next token
  • Loading branch information
abelanger5 authored Jun 21, 2021
2 parents b7c14a6 + 8d4d51f commit 3c90f30
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,36 @@ func (r *Registry) listECRImages(repoName string, repo repository.Repository) ([
return nil, err
}

var maxResults int64 = 999

describeResp, err := svc.DescribeImages(&ecr.DescribeImagesInput{
RepositoryName: &repoName,
ImageIds: resp.ImageIds,
MaxResults: &maxResults,
})

if err != nil {
return nil, err
}

imageDetails := describeResp.ImageDetails

nextToken := describeResp.NextToken

for nextToken != nil {
describeResp, err := svc.DescribeImages(&ecr.DescribeImagesInput{
RepositoryName: &repoName,
ImageIds: resp.ImageIds,
})

if err != nil {
return nil, err
}

nextToken = describeResp.NextToken
imageDetails = append(imageDetails, describeResp.ImageDetails...)
}

res := make([]*Image, 0)

for _, img := range describeResp.ImageDetails {
for _, img := range imageDetails {
for _, tag := range img.ImageTags {
res = append(res, &Image{
Digest: *img.ImageDigest,
Expand Down

0 comments on commit 3c90f30

Please sign in to comment.