utils

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpJSON

func DumpJSON(o interface{}) string

DumpJSON returns the JSON encoding

func GetContainer

func GetContainer(name string, pod *v1.Pod) *v1.Container

func GetContainerEnvValue

func GetContainerEnvValue(container *v1.Container, key string) string

func GetContainerEnvVar

func GetContainerEnvVar(container *v1.Container, key string) *v1.EnvVar

func GetContainerStatus

func GetContainerStatus(name string, pod *v1.Pod) *v1.ContainerStatus

func GetContainerVolumeMount

func GetContainerVolumeMount(container *v1.Container, key string) *v1.VolumeMount

func GetNamespace

func GetNamespace() string

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodContainerImageIDs

func GetPodContainerImageIDs(pod *v1.Pod) map[string]string

func GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func IsContainerImageEqual

func IsContainerImageEqual(image1, image2 string) bool

1. image1, image2 are digest image, compare repo+digest 2. image1, image2 are normal image, compare repo+tag 3. image1, image2 are digest+normal image, don't support compare it, return false

func IsImageDigest

func IsImageDigest(image string) bool

whether image is digest format, for example: docker.io/busybox@sha256:a9286defaba7b3a519d585ba0e37d0b2cbee74ebfe590960b0b1d6a5e97d1e1d

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.

func IsRunningAndReady

func IsRunningAndReady(pod *v1.Pod) bool

func MergeEnvVar

func MergeEnvVar(original []v1.EnvVar, additional []v1.EnvVar) []v1.EnvVar

func MergeVolumeMounts

func MergeVolumeMounts(original, additional []v1.VolumeMount) []v1.VolumeMount

func MergeVolumes

func MergeVolumes(original []v1.Volume, additional []v1.Volume) []v1.Volume

func ParseImage

func ParseImage(image string) (repo, tag, digest string, err error)

parse container images, 1. docker.io/busybox@sha256:a9286defaba7b3a519d585ba0e37d0b2cbee74ebfe590960b0b1d6a5e97d1e1d repo=docker.io/busybox, tag="", digest=sha256:a9286defaba7b3a519d585ba0e37d0b2cbee74ebfe590960b0b1d6a5e97d1e1d 2. docker.io/busybox:latest repo=docker.io/busybox, tag=latest, digest=""

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)

func ValidatedLabelSelectorAsSelector

func ValidatedLabelSelectorAsSelector(ps *metav1.LabelSelector) (labels.Selector, error)

Types

type ActivePods

type ActivePods []*v1.Pod

ActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.

func (ActivePods) Len

func (s ActivePods) Len() int

func (ActivePods) Less

func (s ActivePods) Less(i, j int) bool

func (ActivePods) Swap

func (s ActivePods) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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