helper

package
v1.8.7-beta.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 api objects. Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true

Functions

func AddOrUpdateTolerationInPod

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

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

func AddToNodeAddresses

func AddToNodeAddresses(addresses *[]api.NodeAddress, addAddresses ...api.NodeAddress)

AddToNodeAddresses appends the NodeAddresses to the passed-by-pointer slice, only if they do not already exist

func GetAccessModesAsString

func GetAccessModesAsString(modes []api.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) []api.PersistentVolumeAccessMode

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

func GetPersistentVolumeClaimClass

func GetPersistentVolumeClaimClass(claim *api.PersistentVolumeClaim) string

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

func GetPersistentVolumeClass

func GetPersistentVolumeClass(volume *api.PersistentVolume) string

GetPersistentVolumeClass returns StorageClassName.

func GetStorageNodeAffinityFromAnnotation

func GetStorageNodeAffinityFromAnnotation(annotations map[string]string) (*api.NodeAffinity, error)

GetStorageNodeAffinityFromAnnotation gets the json serialized data from PersistentVolume.Annotations and converts it to the NodeAffinity type in api. TODO: update when storage node affinity graduates to beta

func GetTaintsFromNodeAnnotations

func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]api.Taint, error)

GetTaintsFromNodeAnnotations gets the json serialized taints data from Pod.Annotations and converts it to the []Taint type in api.

func GetTolerationsFromPodAnnotations

func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]api.Toleration, error)

GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations and converts it to the []Toleration type in api.

func HasAnnotation

func HasAnnotation(obj api.ObjectMeta, ann string) bool

HasAnnotation returns a bool if passed in annotation exists

func HugePageResourceName added in v1.8.0

func HugePageResourceName(pageSize resource.Quantity) api.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 HugePageSizeFromResourceName added in v1.8.0

func HugePageSizeFromResourceName(name api.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 IsDefaultNamespaceResource added in v1.8.0

func IsDefaultNamespaceResource(name api.ResourceName) bool

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

func IsExtendedResourceName added in v1.8.0

func IsExtendedResourceName(name api.ResourceName) bool

IsExtendedResourceName returns true if the resource name is not in the default namespace, or it has the opaque integer resource prefix.

func IsHugePageResourceName added in v1.8.0

func IsHugePageResourceName(name api.ResourceName) bool

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

func IsIntegerResourceName

func IsIntegerResourceName(str string) bool

IsIntegerResourceName returns true if the resource is measured in integer values

func IsOpaqueIntResourceName

func IsOpaqueIntResourceName(name api.ResourceName) bool

IsOpaqueIntResourceName returns true if the resource name has the opaque integer resource prefix.

func IsOvercommitAllowed added in v1.8.0

func IsOvercommitAllowed(name api.ResourceName) bool

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

func IsResourceQuotaScopeValidForResource

func IsResourceQuotaScopeValidForResource(scope api.ResourceQuotaScope, resource string) bool

IsResourceQuotaScopeValidForResource returns true if the resource applies to the specified scope

func IsServiceIPRequested

func IsServiceIPRequested(service *api.Service) bool

this function aims to check if the service's cluster IP is requested or not

func IsServiceIPSet

func IsServiceIPSet(service *api.Service) bool

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

func IsStandardContainerResourceName

func IsStandardContainerResourceName(str string) bool

IsStandardContainerResourceName returns true if the container can make a resource request for the specified resource

func IsStandardFinalizerName

func IsStandardFinalizerName(str string) bool

func IsStandardLimitRangeType

func IsStandardLimitRangeType(str string) bool

IsStandardLimitRangeType returns true if the type is Pod or Container

func IsStandardQuotaResourceName

func IsStandardQuotaResourceName(str string) bool

IsStandardQuotaResourceName returns true if the resource is known to the quota tracking system

func IsStandardResourceName

func IsStandardResourceName(str string) bool

IsStandardResourceName returns true if the resource is known to the system

func IsStandardResourceQuotaScope

func IsStandardResourceQuotaScope(str string) bool

IsStandardResourceQuotaScope returns true if the scope is a standard value

func LoadBalancerStatusDeepCopy

func LoadBalancerStatusDeepCopy(lb *api.LoadBalancerStatus) *api.LoadBalancerStatus

TODO: make method on LoadBalancerStatus?

func LoadBalancerStatusEqual

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

TODO: make method on LoadBalancerStatus?

func NodeSelectorRequirementsAsSelector

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

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

func NonConvertibleFields

func NonConvertibleFields(annotations map[string]string) map[string]string

NonConvertibleFields iterates over the provided map and filters out all but any keys with the "non-convertible.kubernetes.io" prefix.

func OpaqueIntResourceName

func OpaqueIntResourceName(name string) api.ResourceName

OpaqueIntResourceName returns a ResourceName with the canonical opaque integer prefix prepended. If the argument already has the prefix, it is returned unmodified.

func PersistentVolumeClaimHasClass

func PersistentVolumeClaimHasClass(claim *api.PersistentVolumeClaim) bool

PersistentVolumeClaimHasClass returns true if given claim has set StorageClassName field.

func PodAnnotationsFromSysctls

func PodAnnotationsFromSysctls(sysctls []api.Sysctl) string

PodAnnotationsFromSysctls creates an annotation value for a slice of Sysctls.

func SetMetaDataAnnotation

func SetMetaDataAnnotation(obj *api.ObjectMeta, ann string, value string)

SetMetaDataAnnotation sets the annotation and value

func StorageNodeAffinityToAlphaAnnotation

func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinity *api.NodeAffinity) error

Converts NodeAffinity type to Alpha annotation for use in PersistentVolumes TODO: update when storage node affinity graduates to beta

func SysctlsFromPodAnnotation

func SysctlsFromPodAnnotation(annotation string) ([]api.Sysctl, error)

SysctlsFromPodAnnotation parses an annotation value into a slice of Sysctls.

func SysctlsFromPodAnnotations

func SysctlsFromPodAnnotations(a map[string]string) ([]api.Sysctl, []api.Sysctl, error)

SysctlsFromPodAnnotations parses the sysctl annotations into a slice of safe Sysctls and a slice of unsafe Sysctls. This is only a convenience wrapper around SysctlsFromPodAnnotation.

func TaintToleratedByTolerations

func TaintToleratedByTolerations(taint *api.Taint, tolerations []api.Toleration) bool

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

func TolerationToleratesTaint

func TolerationToleratesTaint(toleration *api.Toleration, taint *api.Taint) bool

TolerationToleratesTaint checks if the toleration tolerates the taint.

Types

This section is empty.

Directories

Path Synopsis
NOTE: DO NOT use those helper functions through client-go, the package path will be changed in the future.
NOTE: DO NOT use those helper functions through client-go, the package path will be changed in the future.

Jump to

Keyboard shortcuts

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