revision

package
v0.0.0-...-1c7d887 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrReferencedOptionNotFound = "the referenced option was not found in the template spec"
)

Variables

View Source
var (
	LabelKeyTemplate = fmt.Sprintf("%s/template", v1beta1.GroupName)
	LabelKeyName     = fmt.Sprintf("%s/name", v1beta1.GroupName)
)

Functions

This section is empty.

Types

type Option

type Option func(p *Publisher)

func WithLogger

func WithLogger(logger logr.Logger) Option

func WithPatches

func WithPatches(patches ...v1beta1.PodTemplateSpec) Option

type Publisher

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

Publisher creates snapshots of templates with optional overrides of patches to the template. The Publisher is based on two resources, the template, and the resource referencing the template.

func NewPublisher

func NewPublisher(client client.Client, opts ...Option) *Publisher

func (*Publisher) Create

func (r *Publisher) Create(ctx context.Context, impl Referrer) (*v1beta1.Revision, error)

Create a new publisher for the given Referrer. The publisher is only created if the template has changed since the last publisher.

func (*Publisher) ElectRevision

func (r *Publisher) ElectRevision(ctx context.Context, impl Referrer) (*v1beta1.Revision, error)

ElectRevision sets a revision as the elected revision. The elected revision will either be the latest revision, or the revision that's already elected.

func (*Publisher) Elected

func (r *Publisher) Elected(ctx context.Context, impl Referrer) (*v1beta1.Revision, error)

Elected returns the elected publisher for the given Referrer. If there is no elected publisher, nil is returned.

func (*Publisher) Latest

func (r *Publisher) Latest(ctx context.Context, impl Referrer) (*v1beta1.Revision, error)

Latest returns the latest publisher for the given Template and Referrer.

func (*Publisher) List

func (r *Publisher) List(ctx context.Context, impl Referrer) (*v1beta1.RevisionList, error)

List the revisions for a given referrer.

func (*Publisher) SetLogger

func (r *Publisher) SetLogger(logger logr.Logger)

func (*Publisher) SetScheme

func (r *Publisher) SetScheme(scheme *runtime.Scheme)

func (*Publisher) TrimRevisions

func (r *Publisher) TrimRevisions(ctx context.Context, impl Referrer) error

TrimRevisions cleans up old revisions for a given Referrer. A Revision is considered old and eligible for deletion if it is not elected and is not within the history limit.

type Referrer

type Referrer interface {
	// GetName returns the name of the resource
	GetName() string
	// GetNamespace returns the namespace of the resource
	GetNamespace() string
	// TemplateRef returns the name and namespace of the template
	TemplateRef() types.NamespacedName
	// HistoryLimit returns the number of revisions to keep around
	// for this resource
	HistoryLimit() int
	// ResourceRequests returns the resource requests for this
	// resource
	ResourceRequests() corev1.ResourceList
	// ElectedOptions returns the elected options for this resource
	// if any. Elected options must exist in the template. If additional
	// patches are required, they should be applied by webhook.
	ElectedOptions() []corev1.LocalObjectReference
	// UpdatePolicy returns the update policy for this resource. The UpdatePolicy
	// can either be "Auto", or "Ignore".
	UpdatePolicy() string
}

A Referrer is a resource that references a template

Jump to

Keyboard shortcuts

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