crdtools

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertDownwardAPIFieldLabel

func ConvertDownwardAPIFieldLabel(version, label, value string) (string, string, error)

ConvertDownwardAPIFieldLabel converts the specified downward API field label and its value in the pod of the specified version to the internal version, and returns the converted label and value. This function returns an error if the conversion fails.

func ExtractFieldPathAsString

func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error)

ExtractFieldPathAsString extracts the field from the given object and returns it as a string. The object must be a pointer to an API type.

func FindStatusCondition

func FindStatusCondition(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) *corev1.PodCondition

FindStatusCondition finds the conditionType in conditions.

func FormatMap

func FormatMap(m map[string]string) (fmtStr string)

FormatMap formats map[string]string to a string.

func FromEndpoints

func FromEndpoints(endpoints []*corev1.Endpoints) []corev1.EnvVar

FromEndpoints builds environment variables that a container is started with, which tell the container where to find the services it may need, which are provided as an argument.

func IsServiceIPSet

func IsServiceIPSet(service *corev1.Service) bool

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

func IsStatusConditionFalse

func IsStatusConditionFalse(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) bool

IsStatusConditionFalse returns true when the conditionType is present and set to `metav1.ConditionFalse`

func IsStatusConditionPresentAndEqual

func IsStatusConditionPresentAndEqual(conditions []corev1.PodCondition, conditionType corev1.PodConditionType, status corev1.ConditionStatus) bool

IsStatusConditionPresentAndEqual returns true when conditionType is present and equal to status.

func IsStatusConditionTrue

func IsStatusConditionTrue(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) bool

IsStatusConditionTrue returns true when the conditionType is present and set to `metav1.ConditionTrue`

func RemoveStatusCondition

func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string)

RemoveStatusCondition removes the corresponding conditionType from conditions. conditions must be non-nil.

func SetPodStatusCondition

func SetPodStatusCondition(conditions *[]corev1.PodCondition, newCondition corev1.PodCondition)

SetPodStatusCondition sets the corresponding condition in conditions to newCondition. conditions must be non-nil.

  1. if the condition of the specified type already exists (all fields of the existing condition are updated to newCondition, LastTransitionTime is set to now if the new status differs from the old status)
  2. if a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)

func SplitMaybeSubscriptedPath

func SplitMaybeSubscriptedPath(fieldPath string) (string, string, bool)

SplitMaybeSubscriptedPath checks whether the specified fieldPath is subscripted, and

  • if yes, this function splits the fieldPath into path and subscript, and returns (path, subscript, true).
  • if no, this function returns (fieldPath, "", false).

Example inputs and outputs:

  • "metadata.annotations['myKey']" --> ("metadata.annotations", "myKey", true)
  • "metadata.annotations['a[b]c']" --> ("metadata.annotations", "a[b]c", true)
  • "metadata.labels[”]" --> ("metadata.labels", "", true)
  • "metadata.labels" --> ("metadata.labels", "", false)

Types

This section is empty.

Jump to

Keyboard shortcuts

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