utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFlagValueRaw

func FindFlagValueRaw(command []string, flag string) []string

FindFlagValueRaw returns the value of a specific flag in a commands slice. The following flag representations are supported:

--flag=foo
--flag foo
--flag
-flag=foo
-flag foo
-flag

Notable ambiguous behavior:

--flag="foo"           -> `"foo"`
--flag=foo --flag2=bar -> "foo --flag2=bar"
--flag=   foo          -> "foo"
--flag=                -> ""

func FindInnerValue

func FindInnerValue(values []string, flag string) []string

FindInnerValue returns the value of a specific flag when the format is flag1=value1,flag3=value3,flag3=value3

func GetCommandOptionFromDeployment

func GetCommandOptionFromDeployment(ctx context.Context, c client.Client, deploymentName, containerName, namespace, option string) ([]string, error)

GetCommandOptionFromDeployment returns command and args from a specific deployment container.

func GetContainerFromDeployment

func GetContainerFromDeployment(deployment *appsv1.Deployment, containerName string) (container corev1.Container, found bool)

GetContainerFromDeployment returns a container object with a specific cainerName, if such container is not present it retuns found=false

func GetContainerFromStatefulSet

func GetContainerFromStatefulSet(statefulSet *appsv1.StatefulSet, containerName string) (container corev1.Container, found bool)

GetContainerFromStatefulSet returns a container object with a specific cainerName, if such container is not present it retuns found=false

func GetFileDataFromVolume

func GetFileDataFromVolume(ctx context.Context, c client.Client, namespace string, volume corev1.Volume, fileName string) ([]byte, error)

GetFileDataFromVolume returns byte slice of the value of a specific Data field in a ConfigMap or Secret volume

func GetKubeletCommand

func GetKubeletCommand(ctx context.Context, podExecutor pod.PodExecutor) (string, error)

GetKubeletCommand returns the used kubelet command

func GetKubeletConfig

func GetKubeletConfig(ctx context.Context, podExecutor pod.PodExecutor, rawKubeletCommand string) (*config.KubeletConfig, error)

GetKubeletConfig returns the kubelet config specified in the kubelet command's option `--config`

func GetNamespaces

func GetNamespaces(ctx context.Context, c client.Client) (map[string]corev1.Namespace, error)

GetNamespaces returns a map containing all namespaces, where the names of the namespaces are used as a keys.

func GetNodeConfigz

func GetNodeConfigz(ctx context.Context, coreV1RESTClient rest.Interface, nodeName string) (*config.KubeletConfig, error)

GetNodeConfigz returns the runtime kubelet config

func GetNodes

func GetNodes(ctx context.Context, c client.Client, limit int64) ([]corev1.Node, error)

GetNodes return all nodes. It retrieves pods by portions set by limit.

func GetObjectsMetadata

func GetObjectsMetadata(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, namespace string, selector labels.Selector, limit int64) ([]metav1.PartialObjectMetadata, error)

GetObjectsMetadata returns the object metadata for all resources of a given group version kind for a namespace, or all namespaces if it's set to "". It retrieves objects by portions set by limit.

func GetPodSecurityPolicies

func GetPodSecurityPolicies(ctx context.Context, c client.Client, limit int64) ([]policyv1beta1.PodSecurityPolicy, error)

GetPodSecurityPolicies returns all pod security policies. It retrieves policies by portions set by limit.

func GetPods

func GetPods(ctx context.Context, c client.Client, namespace string, selector labels.Selector, limit int64) ([]corev1.Pod, error)

GetPods return all pods for a given namespace, or all namespaces if it's set to empty string "". It retrieves pods by portions set by limit.

func GetVolumeConfigByteSliceByMountPath

func GetVolumeConfigByteSliceByMountPath(ctx context.Context, c client.Client, deployment *appsv1.Deployment, containerName, mountPath string) ([]byte, error)

GetVolumeConfigByteSliceByMountPath returns the byte slice data of a specific volume in a deployment by the volumes mountPath and containerName

func GetVolumeFromDeployment

func GetVolumeFromDeployment(deployment *appsv1.Deployment, volumeName string) (volume corev1.Volume, found bool)

GetVolumeFromDeployment returns a volume object with a specific volumeName, if such volume is not present it retuns found=false

func GetVolumeFromStatefulSet

func GetVolumeFromStatefulSet(statefulSet *appsv1.StatefulSet, volumeName string) (volume corev1.Volume, found bool)

GetVolumeFromStatefulSet returns a volume object with a specific volumeName, if such volume is not present it retuns found=false

func IsFlagSet

func IsFlagSet(rawCommand, option string) bool

IsFlagSet returns true if a specific flag is set in the command

func NodeReadyStatus

func NodeReadyStatus(node corev1.Node) bool

NodeReadyStatus returns true if the given node has NodeReady status condition true and false in every other case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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