gcrcleaner

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package gcrcleaner cleans up stale images from a container registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTimerCache added in v0.3.0

func NewTimerCache(lifetime time.Duration) *timerCache

NewTimerCache creates a new timer-based cache.

Types

type Cache

type Cache interface {
	// Insert inserts the item into the cache. If the item already exists, this
	// method returns true.
	Insert(string) bool

	// Stop stops the cache. When Stop returns, the cache must not perform any
	// additionally processing.
	Stop()
}

Cache is an interface used by the PubSub() function to prevent duplicate messages from being processed.

type Cleaner

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

Cleaner is a gcr cleaner.

func NewCleaner

func NewCleaner(auther gcrauthn.Authenticator, c int) (*Cleaner, error)

NewCleaner creates a new GCR cleaner with the given token provider and concurrency.

func (*Cleaner) Clean

func (c *Cleaner) Clean(repo string, since time.Time, allowTagged bool, keep int, tagFilterRegexp *regexp.Regexp, dryRun bool) ([]string, error)

Clean deletes old images from GCR that are (un)tagged and older than "since" and higher than the "keep" amount.

func (*Cleaner) ListChildRepositories added in v0.5.0

func (c *Cleaner) ListChildRepositories(ctx context.Context, rootRepository string) ([]string, error)

type Payload

type Payload struct {
	// Repo is the name of the repo in the format gcr.io/foo/bar
	Repo string `json:"repo"`

	// Grace is a time.Duration value indicating how much grade period should be
	// given to new, untagged layers. The default is no grace.
	Grace duration `json:"grace"`

	// AllowTagged is a Boolean value determine if tagged images are allowed
	// to be deleted.
	AllowTagged bool `json:"allow_tagged"`

	// Keep is the minimum number of images to keep.
	Keep int `json:"keep"`

	// TagFilter is the tags pattern to be allowed removing.
	TagFilter string `json:"tag_filter"`

	// DryRun instructs the server to not perform actual cleaning. The response
	// will include repositories that would have been deleted.
	DryRun bool `json:"dry_run"`

	// Recursive enables cleaning all child repositories.
	Recursive bool `json:"recursive"`
}

Payload is the expected incoming payload format.

type Server

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

Server is a cleaning server.

func NewServer

func NewServer(cleaner *Cleaner) (*Server, error)

NewServer creates a new server for handler functions.

func (*Server) HTTPHandler

func (s *Server) HTTPHandler() http.HandlerFunc

HTTPHandler is an http handler that invokes the cleaner with the given parameters.

func (*Server) PubSubHandler

func (s *Server) PubSubHandler(cache Cache) http.HandlerFunc

PubSubHandler is an http handler that invokes the cleaner from a pubsub request. Unlike an HTTP request, the pubsub endpoint always returns a success unless the pubsub message is malformed.

Jump to

Keyboard shortcuts

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