util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 20 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDuplicate added in v0.3.1

func CheckDuplicate(list []string) []string

CheckDuplicate finds if there are duplicated items in a list.

func DiffPods added in v0.9.0

func DiffPods(pods1, pods2 []*v1.Pod) (ret []*v1.Pod)

DiffPods returns pods in pods1 but not in pods2

func DumpJSON

func DumpJSON(o interface{}) string

DumpJSON returns the JSON encoding

func GetContainer added in v0.8.0

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

func GetContainerEnvValue added in v0.8.0

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

func GetContainerEnvVar added in v0.8.0

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

func GetContainerStatus added in v0.9.0

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

func GetContainerVolumeMount added in v0.8.0

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

func GetFastLabelSelector added in v0.8.0

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

func GetIntOrStrPointer added in v0.7.0

func GetIntOrStrPointer(i intstrutil.IntOrString) *intstrutil.IntOrString

func GetPodNames added in v0.6.1

func GetPodNames(pods []*v1.Pod) sets.String

GetPodNames returns names of the given Pods array

func GetPodVolume added in v0.8.0

func GetPodVolume(pod *v1.Pod, volumeName string) *v1.Volume

func InjectReadinessGateToPod added in v0.9.0

func InjectReadinessGateToPod(pod *v1.Pod, conditionType v1.PodConditionType)

func IntAbs added in v0.9.0

func IntAbs(i int) int

IntAbs returns the abs number of the given int number

func IsContainerImageEqual added in v0.8.0

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 added in v0.8.0

func IsImageDigest(image string) bool

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

func IsIntPlusAndMinus added in v0.9.0

func IsIntPlusAndMinus(i, j int) bool

func IsJSONObjectEqual added in v0.9.0

func IsJSONObjectEqual(o1, o2 interface{}) bool

IsJSONObjectEqual checks if two objects are equal after encoding json

func IsPodContainerDigestEqual added in v0.8.0

func IsPodContainerDigestEqual(containers sets.String, pod *v1.Pod) bool

func IsPodOwnedByKruise added in v0.9.0

func IsPodOwnedByKruise(pod *v1.Pod) bool

func IsRunningAndReady added in v0.8.0

func IsRunningAndReady(pod *v1.Pod) bool

func IsSelectorOverlapping added in v0.8.0

func IsSelectorOverlapping(selector1, selector2 *metav1.LabelSelector) bool

whether selector overlaps, the criteria: if exist one same key has different value and not overlap, then it is judged non-overlap, for examples:

  • a=b and a=c
  • a in [b,c] and a not in [b,c...]
  • a not in [b] and a not exist
  • a=b,c=d,e=f and a=x,c=d,e=f

then others is overlap:

  • a=b and c=d

func MergeEnvVar added in v0.8.0

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

func MergePods added in v0.6.1

func MergePods(pods1, pods2 []*v1.Pod) []*v1.Pod

MergePods merges two pods arrays

func MergeVolumeMounts added in v0.8.0

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

func MergeVolumeMountsInContainer added in v0.8.0

func MergeVolumeMountsInContainer(origin *v1.Container, other v1.Container)

func MergeVolumes added in v0.8.0

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

func NewClientFromManager added in v0.8.0

func NewClientFromManager(mgr manager.Manager, name string) client.Client

func ParseImage added in v0.8.0

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 SlowStartBatch added in v0.3.0

func SlowStartBatch(count int, initialBatchSize int, fn func(index int) error) (int, error)

SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.

It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently with its index.

If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.

It returns the number of successful calls to the function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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