prune

package
v0.0.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package prune removes images from Amazon Web Services Elastic Container Registry repositories based on their age.

Index

Constants

View Source
const DefaultPeriodTagKey = "thermite:prune-period"

DefaultPeriodTagKey is the default Amazon Web Services resource tag used to specify Elastic Container Registry repository prune periods to a Client.

Variables

View Source
var ErrNoPrunePeriodTag = errors.New("no valid prune period tag for repository")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client is a configurable GarbageCollector wrapping ecriface.ECRAPI.

func NewClient

func NewClient(client ecriface.ECRAPI, opts ...Option) (*Client, error)

NewClient returns a GarbageCollector that removes images using client. If no WithPeriodTagKey options are specified in opts, DefaultPeriodTagKey will be used.

func (*Client) PeriodTagKey

func (gc *Client) PeriodTagKey() string

PeriodTagKey returns the resource tag used to specify Elastic Container Registry repository prune periods to gc.

func (*Client) PruneAllRepos

func (gc *Client) PruneAllRepos(ctx context.Context, until time.Time, excluded ...string) (pruned []string, err error)

PruneAllRepos runs PruneRepo for every repository in the Amazon Elastic Container Registry associated with gc, and returns the combined list of pruned image references.

func (*Client) PruneRepo

func (gc *Client) PruneRepo(ctx context.Context, name string, until time.Time, excluded ...string) (pruned []string, err error)

PruneRepo checks the named repo for a tag with the key identified by gc.PeriodTagKey(), whose value specifies a positive integer representing the number of days that must pass after an image is pushed to the repository before it can be removed. If the tag is present, PruneRepo removes any images that were pushed that many days before until, excluding any image referenced by excluded.

PruneRepo returns the list of image references that were pruned (or would haveb been pruned if WithRemoveImages was not specified as an option when creating gc). PruneRepo will fail if no image references are specified by excluded, unless WithAllowZeroExclusions was specified when creating gc.

type GarbageCollector

type GarbageCollector interface {
	PruneRepo(ctx context.Context, name string, until time.Time, excluded ...string) (pruned []string, err error)
	PruneAllRepos(ctx context.Context, until time.Time, excluded ...string) (pruned []string, err error)
}

A GarbageCollector removes images from Amazon ECR based on age.

type Option

type Option func(gc *Client)

An Option is an option applied when creating a Client.

func WithAllowZeroExclusions

func WithAllowZeroExclusions() Option

WithAllowZeroExclusions will allow a Client to prune even if no images are excluded.

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger sets a logger for a Client to output to.

func WithPageSize

func WithPageSize(size uint) Option

WithPageSize sets the maximum number of responses a Client should request in a single Elastic Container Registry API call.

func WithPeriodTagKey

func WithPeriodTagKey(key string) Option

WithPeriodTagKey sets the Amazon Web Services resource tag used to specify ECR repository prune periods to a Client.

func WithRemoveImages

func WithRemoveImages() Option

WithRemoveImages sets whether a Client should remove images from Elastic Container Registry or just determine which images are eligible.

func WithStatsdClient

func WithStatsdClient(client statsd.ClientInterface) Option

WithStatsdClient sets a statsd client to use to report metrics from a Client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL