1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-07-15 01:34:32 +02:00

fix ecr purge images

This commit is contained in:
Lee Brown
2019-08-13 17:15:53 -08:00
parent 09b4ff8171
commit c4b7abf685

View File

@ -179,27 +179,14 @@ func EcrPurgeImages(req *serviceBuildRequest) ([]*ecr.ImageIdentifier, error) {
svc := ecr.New(req.awsSession())
// First list all the image IDs for the repository.
var imgIds []*ecr.ImageIdentifier
err := svc.ListImagesPages(&ecr.ListImagesInput{
RepositoryName: aws.String(req.EcrRepositoryName),
}, func(res *ecr.ListImagesOutput, lastPage bool) bool {
imgIds = append(imgIds, res.ImageIds...)
return !lastPage
})
if err != nil {
return nil, errors.Wrapf(err, "failed to list images for repository '%s'", req.EcrRepositoryName)
}
var (
ts []int
tsImgIds = map[int][]*ecr.ImageIdentifier{}
)
// Describe all the image IDs to determine oldest.
err = svc.DescribeImagesPages(&ecr.DescribeImagesInput{
err := svc.DescribeImagesPages(&ecr.DescribeImagesInput{
RepositoryName: aws.String(req.EcrRepositoryName),
ImageIds: imgIds,
}, func(res *ecr.DescribeImagesOutput, lastPage bool) bool {
for _, img := range res.ImageDetails {