history

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddToScheme = localSchemeBuilder.AddToScheme

AddToScheme adds all types necessary to handle history-related objects to the given scheme.

DecodingVersions is a list of GroupVersions that need to be decoded for handling history-related objects.

View Source
var Scheme = runtime.NewScheme()

Scheme is a *runtime.Scheme including all types necessary to handle history-related objects.

View Source
var SupportedKinds = []string{"Deployment", "StatefulSet", "DaemonSet"}

SupportedKinds is a list of object kinds supported by this package.

Functions

func ByNumber

func ByNumber(list Revisions) sort.Interface

ByNumber returns an implementation of the sort.Interface for sorting Revisions by number.

func ListControllerRevisionsAndPods added in v0.4.0

func ListControllerRevisionsAndPods(ctx context.Context, r client.Reader, namespace string, selector *metav1.LabelSelector) (*appsv1.ControllerRevisionList, *corev1.PodList, error)

ListControllerRevisionsAndPods is a helper for a ControllerRevision-based History implementation that needs to find all ControllerRevisions and Pods belonging to a given workload object.

func Sort

func Sort(r Revisions)

Sort sorts the given Revisions in-place by revision number (ascending).

Types

type ControllerRevision

type ControllerRevision struct {
	ControllerRevision *appsv1.ControllerRevision
	Template           *corev1.Pod

	Replicas
}

ControllerRevision is a Revision of a StatefulSet or DaemonSet.

func NewControllerRevisionForDaemonSet

func NewControllerRevisionForDaemonSet(controllerRevision *appsv1.ControllerRevision) (*ControllerRevision, error)

NewControllerRevisionForDaemonSet transforms the given ControllerRevision of a DaemonSet to a Revision object.

func NewControllerRevisionForStatefulSet

func NewControllerRevisionForStatefulSet(controllerRevision *appsv1.ControllerRevision) (*ControllerRevision, error)

NewControllerRevisionForStatefulSet transforms the given ControllerRevision of a StatefulSet to a Revision object.

func (*ControllerRevision) DeepCopyObject

func (c *ControllerRevision) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object.

func (*ControllerRevision) GetObjectKind

func (c *ControllerRevision) GetObjectKind() schema.ObjectKind

GetObjectKind implements runtime.Object.

func (*ControllerRevision) Name

func (c *ControllerRevision) Name() string

func (*ControllerRevision) Number

func (c *ControllerRevision) Number() int64

func (*ControllerRevision) Object

func (c *ControllerRevision) Object() client.Object

func (*ControllerRevision) PodTemplate

func (c *ControllerRevision) PodTemplate() *corev1.Pod

type DaemonSetHistory

type DaemonSetHistory struct {
	Client client.Reader
}

DaemonSetHistory implements the History interface for DaemonSets.

func (DaemonSetHistory) ListRevisions

func (d DaemonSetHistory) ListRevisions(ctx context.Context, obj client.Object) (Revisions, error)

type DeploymentHistory

type DeploymentHistory struct {
	Client client.Reader
}

DeploymentHistory implements the History interface for Deployments.

func (DeploymentHistory) ListRevisions

func (d DeploymentHistory) ListRevisions(ctx context.Context, obj client.Object) (Revisions, error)

type History

type History interface {
	// ListRevisions returns a sorted revision history (ascending) of the given object.
	ListRevisions(ctx context.Context, obj client.Object) (Revisions, error)
}

History is a kind-specific client that knows how to access the revision history of objects of that kind. Instantiate a History with For or ForGroupKind. Alternatively, use ListRevisions as a shortcut for listing revisions of a single object.

func For

func For(c client.Client, obj client.Object) (History, error)

For instantiates a new History client for the given Object. Note that the object is only used to determine the GroupKind to pass to ForGroupKind. The object for which to list revisions must be passed to History.ListRevisions. I.e., the following

history.For(c, &appsv1.Deployment{})

is a convenient shortcut for

history.ForGroupKind(c, appsv1.SchemeGroupVersion.WithKind("Deployment").GroupKind())

func ForGroupKind

func ForGroupKind(c client.Reader, gk schema.GroupKind) (History, error)

ForGroupKind instantiates a new History client for the given GroupKind.

type PodPredicate added in v0.4.0

type PodPredicate func(*corev1.Pod) bool

func PodBelongsToDaemonSetRevision added in v0.4.0

func PodBelongsToDaemonSetRevision(revision *appsv1.ControllerRevision) PodPredicate

func PodBelongsToStatefulSetRevision added in v0.4.0

func PodBelongsToStatefulSetRevision(revision *appsv1.ControllerRevision) PodPredicate

type ReplicaSet

type ReplicaSet struct {
	ReplicaSet *appsv1.ReplicaSet
	// contains filtered or unexported fields
}

ReplicaSet is a Revision of a Deployment.

func NewReplicaSet

func NewReplicaSet(replicaSet *appsv1.ReplicaSet) (*ReplicaSet, error)

NewReplicaSet transforms the given ReplicaSet to a Revision object.

func (*ReplicaSet) CurrentReplicas added in v0.4.0

func (r *ReplicaSet) CurrentReplicas() int32

func (*ReplicaSet) DeepCopyObject

func (r *ReplicaSet) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object.

func (*ReplicaSet) GetObjectKind

func (r *ReplicaSet) GetObjectKind() schema.ObjectKind

GetObjectKind implements runtime.Object.

func (*ReplicaSet) Name

func (r *ReplicaSet) Name() string

func (*ReplicaSet) Number

func (r *ReplicaSet) Number() int64

func (*ReplicaSet) Object

func (r *ReplicaSet) Object() client.Object

func (*ReplicaSet) PodTemplate

func (r *ReplicaSet) PodTemplate() *corev1.Pod

func (*ReplicaSet) ReadyReplicas added in v0.4.0

func (r *ReplicaSet) ReadyReplicas() int32

type Replicas added in v0.4.0

type Replicas struct {
	Current, Ready int32
}

Replicas is a common struct for storing numbers of replicas.

func CountReplicas added in v0.4.0

func CountReplicas(podList *corev1.PodList, predicate PodPredicate) Replicas

CountReplicas counts the number of total and ready replicas matching the given predicate in the list of pods.

func (Replicas) CurrentReplicas added in v0.4.0

func (r Replicas) CurrentReplicas() int32

func (Replicas) ReadyReplicas added in v0.4.0

func (r Replicas) ReadyReplicas() int32

type Revision

type Revision interface {
	// Object is embedded in Revision so that Revision objects can be passed around like a printable API object to
	// printers.ResourcePrinter.
	runtime.Object

	// Number returns the revision number identifying this Revision.
	Number() int64
	// Name returns the name of the underlying revision object.
	Name() string
	// Object returns the full revision object (e.g., *appsv1.ReplicaSet or *appsv1.ControllerRevision).
	Object() client.Object
	// PodTemplate returns the PodTemplate that was specified in this revision of the object.
	PodTemplate() *corev1.Pod

	// CurrentReplicas returns the total number of replicas belonging to the Revision.
	CurrentReplicas() int32
	// ReadyReplicas returns the number of ready replicas belonging to the Revision.
	ReadyReplicas() int32
}

Revision represents a single revision in the history of a workload object. E.g., a ReplicaSet in a Deployment's history.

type Revisions

type Revisions []Revision

Revisions is a list of Revision objects.

func ListRevisions added in v0.4.0

func ListRevisions(ctx context.Context, c client.Client, obj client.Object) (Revisions, error)

ListRevisions returns a sorted revision history (ascending) of the given object. This is a convenient shortcut for using For and calling History.ListRevisions.

func (Revisions) ByNumber

func (r Revisions) ByNumber(number int64) (Revision, error)

ByNumber finds the Revision with the given revision number in a sorted revision list. -1 denotes the latest revision, -2 the previous one, etc.

func (Revisions) DeepCopyObject

func (r Revisions) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object.

func (Revisions) GetObjectKind

func (r Revisions) GetObjectKind() schema.ObjectKind

GetObjectKind implements runtime.Object.

func (Revisions) Predecessor

func (r Revisions) Predecessor(number int64) (Revision, error)

Predecessor finds the Revision in a sorted revision list that preceded the Revision identified by the given revision number. See also ByNumber.

type StatefulSetHistory

type StatefulSetHistory struct {
	Client client.Reader
}

StatefulSetHistory implements the History interface for StatefulSets.

func (StatefulSetHistory) ListRevisions

func (d StatefulSetHistory) ListRevisions(ctx context.Context, obj client.Object) (Revisions, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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