gcrcleaner

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 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 LogEntry added in v0.6.0

type LogEntry struct {
	Time     *time.Time
	Severity Severity
	Message  string
	Data     map[string]interface{}
}

func (*LogEntry) MarshalJSON added in v0.6.0

func (l *LogEntry) MarshalJSON() ([]byte, error)

type Logger added in v0.6.0

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

func NewLogger added in v0.6.0

func NewLogger(outw, errw io.Writer) *Logger

func (*Logger) Debug added in v0.6.0

func (l *Logger) Debug(msg string, fields ...interface{})

func (*Logger) Error added in v0.6.0

func (l *Logger) Error(msg string, fields ...interface{})

func (*Logger) Fatal added in v0.6.0

func (l *Logger) Fatal(msg string, fields ...interface{})

func (*Logger) Info added in v0.6.0

func (l *Logger) Info(msg string, fields ...interface{})

func (*Logger) Warn added in v0.6.0

func (l *Logger) Warn(msg string, fields ...interface{})

type Payload

type Payload struct {
	// Repo is the name of the repo to clean.
	//
	// Deprecated: Use Repos instead.
	Repo string `json:"repo"`

	// Repos is the list of repositories to clean.
	Repos sortedStringSlice `json:"repos"`

	// 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.

type Severity added in v0.6.0

type Severity string
const (
	SeverityDebug Severity = "DEBUG"
	SeverityInfo  Severity = "INFO"
	SeverityWarn  Severity = "WARNING"
	SeverityError Severity = "ERROR"
	SeverityFatal Severity = "EMERGENCY"
)

Jump to

Keyboard shortcuts

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