Documentation ¶
Index ¶
- Variables
- func CheckDuplicate(list []string) []string
- func DiffPods(pods1, pods2 []*v1.Pod) (ret []*v1.Pod)
- func DumpJSON(o interface{}) string
- func GetContainer(name string, pod *v1.Pod) *v1.Container
- func GetContainerEnvValue(container *v1.Container, key string) string
- func GetContainerEnvVar(container *v1.Container, key string) *v1.EnvVar
- func GetContainerStatus(name string, pod *v1.Pod) *v1.ContainerStatus
- func GetContainerVolumeMount(container *v1.Container, key string) *v1.VolumeMount
- func GetFastLabelSelector(ps *metav1.LabelSelector) (labels.Selector, error)
- func GetIntOrStrPointer(i intstrutil.IntOrString) *intstrutil.IntOrString
- func GetPodNames(pods []*v1.Pod) sets.String
- func GetPodVolume(pod *v1.Pod, volumeName string) *v1.Volume
- func InjectReadinessGateToPod(pod *v1.Pod, conditionType v1.PodConditionType)
- func IntAbs(i int) int
- func IsContainerImageEqual(image1, image2 string) bool
- func IsImageDigest(image string) bool
- func IsIntPlusAndMinus(i, j int) bool
- func IsJSONObjectEqual(o1, o2 interface{}) bool
- func IsPodContainerDigestEqual(containers sets.String, pod *v1.Pod) bool
- func IsPodOwnedByKruise(pod *v1.Pod) bool
- func IsRunningAndReady(pod *v1.Pod) bool
- func IsSelectorLooseOverlap(selector1, selector2 *metav1.LabelSelector) bool
- func IsSelectorOverlapping(selector1, selector2 *metav1.LabelSelector) bool
- func MergeEnvVar(original []v1.EnvVar, additional []v1.EnvVar) []v1.EnvVar
- func MergePods(pods1, pods2 []*v1.Pod) []*v1.Pod
- func MergeVolumeMounts(original, additional []v1.VolumeMount) []v1.VolumeMount
- func MergeVolumeMountsInContainer(origin *v1.Container, other v1.Container)
- func MergeVolumes(original []v1.Volume, additional []v1.Volume) []v1.Volume
- func NewClientFromManager(mgr manager.Manager, name string) client.Client
- func ParseImage(image string) (repo, tag, digest string, err error)
- func SlowStartBatch(count int, initialBatchSize int, fn func(index int) error) (int, error)
- type KeyedMutex
Constants ¶
This section is empty.
Variables ¶
var GlobalCache = cache.NewStore(func(obj interface{}) (string, error) { metaObj, ok := obj.(metav1.Object) if !ok { return "", fmt.Errorf("failed to convert obj to metav1.Object") } namespacedName := fmt.Sprintf("%s/%s", metaObj.GetNamespace(), metaObj.GetName()) runtimeObj, ok := obj.(runtime.Object) if !ok { return "", fmt.Errorf("failed to convert obj to runtime.Object") } key := fmt.Sprintf("%v/%s", runtimeObj.GetObjectKind().GroupVersionKind(), namespacedName) return key, nil })
GlobalCache using GVK/namespace/name as key
var GlobalKeyedMutex = &KeyedMutex{}
Functions ¶
func CheckDuplicate ¶ added in v0.3.1
CheckDuplicate finds if there are duplicated items in a list.
func GetContainerEnvValue ¶ added in v0.8.0
func GetContainerEnvVar ¶ added in v0.8.0
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
GetPodNames returns names of the given Pods array
func InjectReadinessGateToPod ¶ added in v0.9.0
func InjectReadinessGateToPod(pod *v1.Pod, conditionType v1.PodConditionType)
func IsContainerImageEqual ¶ added in v0.8.0
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
whether image is digest format, for example: docker.io/busybox@sha256:a9286defaba7b3a519d585ba0e37d0b2cbee74ebfe590960b0b1d6a5e97d1e1d
func IsIntPlusAndMinus ¶ added in v0.9.0
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 IsPodOwnedByKruise ¶ added in v0.9.0
func IsRunningAndReady ¶ added in v0.8.0
func IsSelectorLooseOverlap ¶ added in v0.10.0
func IsSelectorLooseOverlap(selector1, selector2 *metav1.LabelSelector) bool
whether selectors overlap (indicates that selector1, selector2 have same key, and there is an certain intersection) 1. when selector1、selector2 don't have same key, it is considered non-overlap, e.g. selector1(a=b) and selector2(c=d) 2. when selector1、selector2 have same key, and matchLabels & matchExps are intersection, it is considered overlap. For examples:
a In [b,c] And a Exist a In [b,...] [c,...] [Include any b,c,...] a NotIn [a,...] [b,....] [c,....] [All other cases are allowed except for the inclusion of both b,c...] [b,c,e] a Exist And a Exist a In [x,y,Any,...] a NotIn [a,b,Any...] a NotIn [b,c] And a Exist a NotExist a NotIn [a,b,Any...] a In [a,b] [a,c] [e,f] [Any,...] other than [b],[c],[b,c] a NotExist And a NotExist a NotIn [Any,...] When selector1 and selector2 contain the same key, except for the above case, they are considered non-overlap
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 MergeVolumeMounts ¶ added in v0.8.0
func MergeVolumeMounts(original, additional []v1.VolumeMount) []v1.VolumeMount
func MergeVolumeMountsInContainer ¶ added in v0.8.0
func MergeVolumes ¶ added in v0.8.0
func NewClientFromManager ¶ added in v0.8.0
func ParseImage ¶ added in v0.8.0
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
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 ¶
type KeyedMutex ¶ added in v0.10.1
type KeyedMutex struct {
// contains filtered or unexported fields
}
func (*KeyedMutex) Lock ¶ added in v0.10.1
func (m *KeyedMutex) Lock(key string) func()
func (*KeyedMutex) Unlock ¶ added in v0.10.1
func (m *KeyedMutex) Unlock(key string)