Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterOldUnusedImages ¶
func FilterOldUnusedImages(keepMax int, repoImages []*ecr.ImageDetail, tagsInUse []string) []*ecr.ImageDetail
FilterOldUnusedImages goes through the given list of ECR images and returns another list of images (giving priority to older images) that are not in use. This list will contain at most 100 images, which is the maximum number of images we are allowed to delete in a single API call to AWS.
func SortImagesByPushDate ¶
func SortImagesByPushDate(images []*ecr.ImageDetail)
SortImagesByPushDate uses the `ImagesByPushDate` type to sort the given slice of ECR image objects.
Types ¶
type ECRClient ¶
type ECRClient interface { ListRepositories(repositoryNames []*string, registryID *string) ([]*ecr.Repository, error) ListImages(repositoryName *string, registryID *string) ([]*ecr.ImageDetail, error) BatchRemoveImages(images []*ecr.ImageDetail) error }
ECRClient defines the expected interface of any object capable of listing and removing images from a ECR repository.
type ECRClientImpl ¶
ECRClientImpl provides an interface for mocking.
func NewECRClient ¶
func NewECRClient(region string) *ECRClientImpl
NewECRClient returns a new client for interacting with the ECR API. The credentials are retrieved from environment variables or from the `~/.aws/credentials` file.
func (*ECRClientImpl) BatchRemoveImages ¶
func (c *ECRClientImpl) BatchRemoveImages(images []*ecr.ImageDetail) error
BatchRemoveImages deletes all the given images in one go. All images must be stored in the same repository for this to work.
func (*ECRClientImpl) ListImages ¶
func (c *ECRClientImpl) ListImages(repositoryName *string, registryID *string) ([]*ecr.ImageDetail, error)
ListImages returns data from all images stored in the repository identified by the given repository name.
func (*ECRClientImpl) ListRepositories ¶
func (c *ECRClientImpl) ListRepositories(repositoryNames []*string, registryID *string) ([]*ecr.Repository, error)
ListRepositories returns the data belonging to the given repository names.
type ImagesByPushDate ¶
type ImagesByPushDate []*ecr.ImageDetail
ImagesByPushDate lets us sort ECR images by push date so that we can delete old images.
func (ImagesByPushDate) Len ¶
func (slice ImagesByPushDate) Len() int
func (ImagesByPushDate) Less ¶
func (slice ImagesByPushDate) Less(i, j int) bool
func (ImagesByPushDate) Swap ¶
func (slice ImagesByPushDate) Swap(i, j int)