polymorphichelpers

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChangeCauseAnnotation = "kubernetes.io/change-cause"
)
View Source
const (
	RestartedEnv = "RESTARTED_AT"
)

Variables

This section is empty.

Functions

func CalculatePartitionReplicas added in v1.0.5

func CalculatePartitionReplicas(partition *intstrutil.IntOrString, replicasPointer *int32) (int, error)

CalculatePartitionReplicas returns absolute value of partition for workload. This func can solve some corner cases about percentage-type partition, such as: - if partition > "0%" and replicas > 0, we will ensure at least 1 old pod is reserved. - if partition < "100%" and replicas > 1, we will ensure at least 1 pod is upgraded.

func GetFirstPod

func GetFirstPod(client coreclient.PodsGetter, namespace string, selector string, timeout time.Duration, sortBy func([]*corev1.Pod) sort.Interface) (*corev1.Pod, int, error)

GetFirstPod returns a pod matching the namespace and label selector and the number of all pods that match the label selector.

func MakeLabels

func MakeLabels(labels map[string]string) string

func SelectorsForObject

func SelectorsForObject(object runtime.Object) (namespace string, selector labels.Selector, err error)

SelectorsForObject returns the pod label selector for a given object

func UpdateResourceEnv

func UpdateResourceEnv(object runtime.Object)

Types

type AdvancedDaemonSetHistoryViewer added in v1.0.2

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

func (*AdvancedDaemonSetHistoryViewer) ViewHistory added in v1.0.2

func (h *AdvancedDaemonSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

type AdvancedDaemonSetRollbacker added in v1.0.2

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

func (*AdvancedDaemonSetRollbacker) Rollback added in v1.0.2

func (r *AdvancedDaemonSetRollbacker) Rollback(obj runtime.Object,
	updatedAnnotations map[string]string,
	toRevision int64,
	dryRunStrategy cmdutil.DryRunStrategy) (string, error)

type AdvancedStatefulSetHistoryViewer

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

func (*AdvancedStatefulSetHistoryViewer) ViewHistory

func (h *AdvancedStatefulSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

type AdvancedStatefulSetRollbacker

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

func (*AdvancedStatefulSetRollbacker) Rollback

func (r *AdvancedStatefulSetRollbacker) Rollback(obj runtime.Object,
	updatedAnnotations map[string]string,
	toRevision int64,
	dryRunStrategy cmdutil.DryRunStrategy) (string, error)

type AdvancedStatefulSetStatusViewer

type AdvancedStatefulSetStatusViewer struct{}

AdvancedStatefulSetStatusViewer implements the StatusViewer interface

func (*AdvancedStatefulSetStatusViewer) DetailStatus added in v1.0.4

func (s *AdvancedStatefulSetStatusViewer) DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)

DetailStatus returns a message describing advanced statefulset status, and a bool value indicating if the status is considered done.

func (*AdvancedStatefulSetStatusViewer) Status

Status returns a message describing advanced statefulset status, and a bool value indicating if the status is considered done.

type AttachablePodForObjectFunc

type AttachablePodForObjectFunc func(restClientGetter genericclioptions.RESTClientGetter, object runtime.Object, timeout time.Duration) (*v1.Pod, error)

AttachablePodForObjectFunc is a function type that can tell you how to get the pod for which to attach a given object

var AttachablePodForObjectFn AttachablePodForObjectFunc = attachablePodForObject

AttachablePodForObjectFn gives a way to easily override the function for unit testing if needed.

type CanBeExposedFunc

type CanBeExposedFunc func(kind schema.GroupKind) error

CanBeExposedFunc is a function type that can tell you whether a given GroupKind is capable of being exposed

var CanBeExposedFn CanBeExposedFunc = canBeExposed

CanBeExposedFn gives a way to easily override the function for unit testing if needed

type CloneSetHistoryViewer

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

func (*CloneSetHistoryViewer) ViewHistory

func (h *CloneSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

TODO impl ViewHistory func for CloneSet

type CloneSetRollbacker

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

func (*CloneSetRollbacker) Rollback

func (r *CloneSetRollbacker) Rollback(obj runtime.Object,
	updatedAnnotations map[string]string,
	toRevision int64,
	dryRunStrategy cmdutil.DryRunStrategy) (string, error)

type CloneSetStatusViewer

type CloneSetStatusViewer struct{}

CloneSetViewer implements the StatusViewer interface

func (*CloneSetStatusViewer) DetailStatus added in v1.0.4

func (s *CloneSetStatusViewer) DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)

DetailStatus returns a message describing cloneset detail status, and a bool value indicating if the status is considered done.

func (*CloneSetStatusViewer) Status

Status returns a message describing cloneset status, and a bool value indicating if the status is considered done.

type DaemonSetHistoryViewer

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

func (*DaemonSetHistoryViewer) ViewHistory

func (h *DaemonSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

ViewHistory returns a revision-to-history map as the revision history of a deployment TODO: this should be a describer

type DaemonSetRollbacker

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

func (*DaemonSetRollbacker) Rollback

func (r *DaemonSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRunStrategy cmdutil.DryRunStrategy) (string, error)

type DaemonSetStatusViewer

type DaemonSetStatusViewer struct{}

DaemonSetStatusViewer implements the StatusViewer interface.

func (*DaemonSetStatusViewer) DetailStatus added in v1.0.4

func (s *DaemonSetStatusViewer) DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)

DetailStatus returns a message describing daemon set status, and a bool value indicating if the status is considered done.

func (*DaemonSetStatusViewer) Status

Status returns a message describing daemon set status, and a bool value indicating if the status is considered done.

type DeploymentHistoryViewer

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

func (*DeploymentHistoryViewer) ViewHistory

func (h *DeploymentHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

ViewHistory returns a revision-to-replicaset map as the revision history of a deployment TODO: this should be a describer

type DeploymentRollbacker

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

func (*DeploymentRollbacker) Rollback

func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRunStrategy cmdutil.DryRunStrategy) (string, error)

type DeploymentStatusViewer

type DeploymentStatusViewer struct{}

DeploymentStatusViewer implements the StatusViewer interface.

func (*DeploymentStatusViewer) DetailStatus added in v1.0.4

func (s *DeploymentStatusViewer) DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)

DetailStatus returns a message describing deployment detail status, and a bool value indicating if the status is considered done.

func (*DeploymentStatusViewer) Status

Status returns a message describing deployment status, and a bool value indicating if the status is considered done.

type HistoryViewer

type HistoryViewer interface {
	ViewHistory(namespace, name string, revision int64) (string, error)
}

HistoryViewer provides an interface for resources have historical information.

func HistoryViewerFor

HistoryViewerFor returns an implementation of HistoryViewer interface for the given schema kind

type HistoryViewerFunc

type HistoryViewerFunc func(restClientGetter genericclioptions.RESTClientGetter, mapping *meta.RESTMapping) (HistoryViewer, error)

HistoryViewerFunc is a function type that can tell you how to view change history

var HistoryViewerFn HistoryViewerFunc = historyViewer

HistoryViewerFn gives a way to easily override the function for unit testing if needed

type HistoryVisitor

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

func (*HistoryVisitor) VisitAdvancedDaemonSet added in v1.0.2

func (v *HistoryVisitor) VisitAdvancedDaemonSet(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitAdvancedStatefulSet

func (v *HistoryVisitor) VisitAdvancedStatefulSet(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitCloneSet

func (v *HistoryVisitor) VisitCloneSet(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitCronJob

func (v *HistoryVisitor) VisitCronJob(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitDaemonSet

func (v *HistoryVisitor) VisitDaemonSet(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitDeployment

func (v *HistoryVisitor) VisitDeployment(elem internalapps.GroupKindElement)

func (*HistoryVisitor) VisitJob

func (v *HistoryVisitor) VisitJob(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitPod

func (v *HistoryVisitor) VisitPod(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitReplicaSet

func (v *HistoryVisitor) VisitReplicaSet(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitReplicationController

func (v *HistoryVisitor) VisitReplicationController(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitRollout added in v1.1.0

func (v *HistoryVisitor) VisitRollout(kind internalapps.GroupKindElement)

func (*HistoryVisitor) VisitStatefulSet

func (v *HistoryVisitor) VisitStatefulSet(kind internalapps.GroupKindElement)

type LogsForObjectFunc

type LogsForObjectFunc func(restClientGetter genericclioptions.RESTClientGetter, object, options runtime.Object, timeout time.Duration, allContainers bool) (map[v1.ObjectReference]rest.ResponseWrapper, error)

LogsForObjectFunc is a function type that can tell you how to get logs for a runtime.object

var LogsForObjectFn LogsForObjectFunc = logsForObject

LogsForObjectFn gives a way to easily override the function for unit testing if needed.

type MapBasedSelectorForObjectFunc

type MapBasedSelectorForObjectFunc func(object runtime.Object) (string, error)

MapBasedSelectorForObjectFunc will call the provided function on mapping the baesd selector for object, return "" if object is not supported, or return an error.

var MapBasedSelectorForObjectFn MapBasedSelectorForObjectFunc = mapBasedSelectorForObject

MapBasedSelectorForObjectFn gives a way to easily override the function for unit testing if needed

type ObjectApproverFunc added in v1.0.2

type ObjectApproverFunc func(runtime.Object) ([]byte, error)

ObjectApproverFunc is a function type that marks the object in a given info as approved.

var ObjectApproverFn ObjectApproverFunc = defaultObjectApprover

ObjectApproverFn gives a way to easily override the function for unit testing if needed. Returns the patched object in bytes and any error that occurred during the encoding or in case the object is already approved.

type ObjectPauserFunc

type ObjectPauserFunc func(runtime.Object) ([]byte, error)

ObjectPauserFunc is a function type that marks the object in a given info as paused.

var ObjectPauserFn ObjectPauserFunc = defaultObjectPauser

ObjectPauserFn gives a way to easily override the function for unit testing if needed. Returns the patched object in bytes and any error that occurred during the encoding or in case the object is already paused.

type ObjectRestarterFunc

type ObjectRestarterFunc func(runtime.Object) ([]byte, error)

ObjectRestarterFunc is a function type that updates an annotation in a deployment to restart it..

var ObjectRestarterFn ObjectRestarterFunc = defaultObjectRestarter

ObjectRestarterFn gives a way to easily override the function for unit testing if needed. Returns the patched object in bytes and any error that occurred during the encoding.

type ObjectResumerFunc

type ObjectResumerFunc func(runtime.Object) ([]byte, error)

ObjectResumerFunc is a function type that marks the object in a given info as resumed.

var ObjectResumerFn ObjectResumerFunc = defaultObjectResumer

ObjectResumerFn gives a way to easily override the function for unit testing if needed. Returns the patched object in bytes and any error that occurred during the encoding or in case the object is already resumed.

type PortsForObjectFunc

type PortsForObjectFunc func(object runtime.Object) ([]string, error)

PortsForObjectFunc returns the ports associated with the provided object

var PortsForObjectFn PortsForObjectFunc = portsForObject

PortsForObjectFn gives a way to easily override the function for unit testing if needed

type ProtocolsForObjectFunc

type ProtocolsForObjectFunc func(object runtime.Object) (map[string]string, error)

ProtocolsForObjectFunc will call the provided function on the protocols for the object, return nil-map if no protocols for the object, or return an error.

var ProtocolsForObjectFn ProtocolsForObjectFunc = protocolsForObject

ProtocolsForObjectFn gives a way to easily override the function for unit testing if needed

type RollbackVisitor

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

func (*RollbackVisitor) VisitAdvancedDaemonSet added in v1.0.2

func (v *RollbackVisitor) VisitAdvancedDaemonSet(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitAdvancedStatefulSet

func (v *RollbackVisitor) VisitAdvancedStatefulSet(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitCloneSet

func (v *RollbackVisitor) VisitCloneSet(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitCronJob

func (v *RollbackVisitor) VisitCronJob(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitDaemonSet

func (v *RollbackVisitor) VisitDaemonSet(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitDeployment

func (v *RollbackVisitor) VisitDeployment(elem internalapps.GroupKindElement)

func (*RollbackVisitor) VisitJob

func (v *RollbackVisitor) VisitJob(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitPod

func (v *RollbackVisitor) VisitPod(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitReplicaSet

func (v *RollbackVisitor) VisitReplicaSet(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitReplicationController

func (v *RollbackVisitor) VisitReplicationController(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitRollout added in v1.1.0

func (v *RollbackVisitor) VisitRollout(kind internalapps.GroupKindElement)

func (*RollbackVisitor) VisitStatefulSet

func (v *RollbackVisitor) VisitStatefulSet(kind internalapps.GroupKindElement)

type Rollbacker

type Rollbacker interface {
	Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRunStrategy cmdutil.DryRunStrategy) (string, error)
}

Rollbacker provides an interface for resources that can be rolled back.

func RollbackerFor

RollbackerFor returns an implementation of Rollbacker interface for the given schema kind

type RollbackerFunc

type RollbackerFunc func(restClientGetter genericclioptions.RESTClientGetter, mapping *meta.RESTMapping) (Rollbacker, error)

RollbackerFunc gives a way to change the rollback version of the specified RESTMapping type

var RollbackerFn RollbackerFunc = rollbacker

RollbackerFn gives a way to easily override the function for unit testing if needed

type RolloutRollbacker added in v1.1.0

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

func (*RolloutRollbacker) Rollback added in v1.1.0

func (r *RolloutRollbacker) Rollback(obj runtime.Object,
	updatedAnnotations map[string]string,
	toRevision int64,
	dryRunStrategy cmdutil.DryRunStrategy) (string, error)

RolloutRollbacker.Rollback never be called

type StatefulSetHistoryViewer

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

func (*StatefulSetHistoryViewer) ViewHistory

func (h *StatefulSetHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error)

ViewHistory returns a list of the revision history of a statefulset TODO: this should be a describer

type StatefulSetRollbacker

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

func (*StatefulSetRollbacker) Rollback

func (r *StatefulSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRunStrategy cmdutil.DryRunStrategy) (string, error)

toRevision is a non-negative integer, with 0 being reserved to indicate rolling back to previous configuration

type StatefulSetStatusViewer

type StatefulSetStatusViewer struct{}

StatefulSetStatusViewer implements the StatusViewer interface.

func (*StatefulSetStatusViewer) DetailStatus added in v1.0.4

func (s *StatefulSetStatusViewer) DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)

func (*StatefulSetStatusViewer) Status

Status returns a message describing statefulset status, and a bool value indicating if the status is considered done.

type StatusViewer

type StatusViewer interface {
	Status(c kubernetes.Interface, obj runtime.Unstructured, revision int64) (string, bool, error)
	DetailStatus(c kubernetes.Interface, obj runtime.Unstructured, detail bool, revision int64) (string, bool, error)
}

StatusViewer provides an interface for resources that have rollout status.

func StatusViewerFor

func StatusViewerFor(kind schema.GroupKind) (StatusViewer, error)

StatusViewerFor returns a StatusViewer for the resource specified by kind.

type StatusViewerFunc

type StatusViewerFunc func(mapping *meta.RESTMapping) (StatusViewer, error)

StatusViewerFunc is a function type that can tell you how to print rollout status

var StatusViewerFn StatusViewerFunc = statusViewer

StatusViewerFn gives a way to easily override the function for unit testing if needed

type UpdatePodSpecForObjectFunc

type UpdatePodSpecForObjectFunc func(obj runtime.Object, fn func(*v1.PodSpec) error) (bool, error)

UpdatePodSpecForObjectFunc will call the provided function on the pod spec this object supports, return false if no pod spec is supported, or return an error.

var UpdatePodSpecForObjectFn UpdatePodSpecForObjectFunc = updatePodSpecForObject

UpdatePodSpecForObjectFn gives a way to easily override the function for unit testing if needed

Jump to

Keyboard shortcuts

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