helper

package
v0.0.0-...-dcfb068 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const NoteLengthLimit = 1024
View Source
const TimestampLayout = time.RFC3339Nano

Variables

View Source
var Semantic = conversion.EqualitiesOrDie(
	func(a, b resource.Quantity) bool {

		return a.Cmp(b) == 0
	},
	func(a, b metav1.MicroTime) bool {
		return a.UTC() == b.UTC()
	},
	func(a, b metav1.Time) bool {
		return a.UTC() == b.UTC()
	},
	func(a, b labels.Selector) bool {
		return a.String() == b.String()
	},
	func(a, b fields.Selector) bool {
		return a.String() == b.String()
	},
)

Semantic can do semantic deep equality checks for core objects. Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true

Functions

func AddOrUpdateTolerationInPod

func AddOrUpdateTolerationInPod(pod *v1.Pod, toleration *v1.Toleration) bool

AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list. Returns true if something was updated, false otherwise.

func AddOrUpdateTolerationInPodSpec

func AddOrUpdateTolerationInPodSpec(spec *v1.PodSpec, toleration *v1.Toleration) bool

AddOrUpdateTolerationInPodSpec tries to add a toleration to the toleration list in PodSpec. Returns true if something was updated, false otherwise.

func BetweenInSeconds

func BetweenInSeconds(from, to time.Time) float64

BetweenInSeconds gets the time between the specified time scope in seconds.

func DecodeInto

func DecodeInto(obj runtime.Object, into interface{}) error

DecodeInto decodes configuration whose type is runtime.Object to the interface into.

func DeepCopyMap

func DeepCopyMap(m map[string]string) map[string]string

DeepCopyMap performs a deep copy of the given map m.

func FindMatchingUntoleratedTaint

func FindMatchingUntoleratedTaint(taints []v1.Taint, tolerations []v1.Toleration, inclusionFilter taintsFilterFunc) (v1.Taint, bool)

FindMatchingUntoleratedTaint checks if the given tolerations tolerates all the filtered taints, and returns the first taint without a toleration

func GetAccessModesAsString

func GetAccessModesAsString(modes []v1.PersistentVolumeAccessMode) string

GetAccessModesAsString returns a string representation of an array of access modes. modes, when present, are always in the same order: RWO,ROX,RWX.

func GetAccessModesFromString

func GetAccessModesFromString(modes string) []v1.PersistentVolumeAccessMode

GetAccessModesFromString returns an array of AccessModes from a string created by GetAccessModesAsString

func GetAvoidPodsFromNodeAnnotations

func GetAvoidPodsFromNodeAnnotations(annotations map[string]string) (v1.AvoidPods, error)

GetAvoidPodsFromNodeAnnotations scans the list of annotations and returns the pods that needs to be avoided for this node from scheduling

func GetMatchingTolerations

func GetMatchingTolerations(taints []v1.Taint, tolerations []v1.Toleration) (bool, []v1.Toleration)

GetMatchingTolerations returns true and list of Tolerations matching all Taints if all are tolerated, or false otherwise.

func GetPersistentVolumeClaimClass

func GetPersistentVolumeClaimClass(claim *v1.PersistentVolumeClaim) string

GetPersistentVolumeClaimClass returns StorageClassName. If no storage class was requested, it returns "".

func GetPersistentVolumeClass

func GetPersistentVolumeClass(volume *v1.PersistentVolume) string

GetPersistentVolumeClass returns StorageClassName.

func HugePageResourceName

func HugePageResourceName(pageSize resource.Quantity) v1.ResourceName

HugePageResourceName returns a ResourceName with the canonical hugepage prefix prepended for the specified page size. The page size is converted to its canonical representation.

func HugePageSizeFromMedium

func HugePageSizeFromMedium(medium v1.StorageMedium) (resource.Quantity, error)

HugePageSizeFromMedium returns the page size for the specified huge page medium. If the specified input is not a valid huge page medium an error is returned.

func HugePageSizeFromResourceName

func HugePageSizeFromResourceName(name v1.ResourceName) (resource.Quantity, error)

HugePageSizeFromResourceName returns the page size for the specified huge page resource name. If the specified input is not a valid huge page resource name an error is returned.

func HugePageUnitSizeFromByteSize

func HugePageUnitSizeFromByteSize(size int64) (string, error)

HugePageUnitSizeFromByteSize returns hugepage size has the format. `size` must be guaranteed to divisible into the largest units that can be expressed. <size><unit-prefix>B (1024 = "1KB", 1048576 = "1MB", etc).

func IsAttachableVolumeResourceName

func IsAttachableVolumeResourceName(name v1.ResourceName) bool

IsAttachableVolumeResourceName returns true when the resource name is prefixed in attachable volume

func IsExtendedResourceName

func IsExtendedResourceName(name v1.ResourceName) bool

IsExtendedResourceName returns true if: 1. the resource name is not in the default namespace; 2. resource name does not have "requests." prefix, to avoid confusion with the convention in quota

func IsHugePageMedium

func IsHugePageMedium(medium v1.StorageMedium) bool

IsHugePageMedium returns true if the volume medium is in 'HugePages[-size]' format

func IsHugePageResourceName

func IsHugePageResourceName(name v1.ResourceName) bool

IsHugePageResourceName returns true if the resource name has the huge page resource prefix.

func IsNativeResource

func IsNativeResource(name v1.ResourceName) bool

IsNativeResource returns true if the resource name is in the *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are implicitly in the kubernetes.io/ namespace.

func IsOvercommitAllowed

func IsOvercommitAllowed(name v1.ResourceName) bool

IsOvercommitAllowed returns true if the resource is in the default namespace and is not hugepages.

func IsPrefixedNativeResource

func IsPrefixedNativeResource(name v1.ResourceName) bool

IsPrefixedNativeResource returns true if the resource name is in the *kubernetes.io/ namespace.

func IsScalarResourceName

func IsScalarResourceName(name v1.ResourceName) bool

IsScalarResourceName validates the resource for Extended, Hugepages, Native and AttachableVolume resources

func IsServiceIPSet

func IsServiceIPSet(service *v1.Service) bool

IsServiceIPSet aims to check if the service's ClusterIP is set or not the objective is not to perform validation here

func LoadBalancerStatusEqual

func LoadBalancerStatusEqual(l, r *v1.LoadBalancerStatus) bool

LoadBalancerStatusEqual evaluates the given load balancers' ingress IP addresses and hostnames and returns true if equal or false if otherwise TODO: make method on LoadBalancerStatus?

func MatchNodeSelectorTerms

func MatchNodeSelectorTerms(
	nodeSelectorTerms []v1.NodeSelectorTerm,
	nodeLabels labels.Set,
	nodeFields fields.Set,
) bool

MatchNodeSelectorTerms checks whether the node labels and fields match node selector terms in ORed; nil or empty term matches no objects.

func MatchTopologySelectorTerms

func MatchTopologySelectorTerms(topologySelectorTerms []v1.TopologySelectorTerm, lbls labels.Set) bool

MatchTopologySelectorTerms checks whether given labels match topology selector terms in ORed; nil or empty term matches no objects; while empty term list matches all objects.

func NodeSelectorRequirementKeysExistInNodeSelectorTerms

func NodeSelectorRequirementKeysExistInNodeSelectorTerms(reqs []v1.NodeSelectorRequirement, terms []v1.NodeSelectorTerm) bool

NodeSelectorRequirementKeysExistInNodeSelectorTerms checks if a NodeSelectorTerm with key is already specified in terms

func NodeSelectorRequirementsAsFieldSelector

func NodeSelectorRequirementsAsFieldSelector(nsm []v1.NodeSelectorRequirement) (fields.Selector, error)

NodeSelectorRequirementsAsFieldSelector converts the []NodeSelectorRequirement core type into a struct that implements fields.Selector.

func NodeSelectorRequirementsAsSelector

func NodeSelectorRequirementsAsSelector(nsm []v1.NodeSelectorRequirement) (labels.Selector, error)

NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement api type into a struct that implements labels.Selector.

func ScopedResourceSelectorRequirementsAsSelector

func ScopedResourceSelectorRequirementsAsSelector(ssr v1.ScopedResourceSelectorRequirement) (labels.Selector, error)

ScopedResourceSelectorRequirementsAsSelector converts the ScopedResourceSelectorRequirement api type into a struct that implements labels.Selector.

func SinceDuration

func SinceDuration(start time.Time) string

SinceDuration gets the duration since the specified start.

func SinceInSeconds

func SinceInSeconds(start time.Time) float64

SinceInSeconds gets the time since the specified start in seconds.

func TolerationsTolerateTaint

func TolerationsTolerateTaint(tolerations []v1.Toleration, taint *v1.Taint) bool

TolerationsTolerateTaint checks if taint is tolerated by any of the tolerations.

func TolerationsTolerateTaintsWithFilter

func TolerationsTolerateTaintsWithFilter(tolerations []v1.Toleration, taints []v1.Taint, applyFilter taintsFilterFunc) bool

TolerationsTolerateTaintsWithFilter checks if given tolerations tolerates all the taints that apply to the filter in given taint list. DEPRECATED: Please use FindMatchingUntoleratedTaint instead.

func TopologySelectorRequirementsAsSelector

func TopologySelectorRequirementsAsSelector(tsm []v1.TopologySelectorLabelRequirement) (labels.Selector, error)

TopologySelectorRequirementsAsSelector converts the []TopologySelectorLabelRequirement api type into a struct that implements labels.Selector.

func TruncateMessage

func TruncateMessage(message string) string

TruncateMessage truncates a message if it hits the NoteLengthLimit.

Types

This section is empty.

Jump to

Keyboard shortcuts

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