helper

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAnnotations

func AddAnnotations(obj metav1.Object, annotations map[string]string)

AddAnnotations adds the given annotations to the given object. if obj is nil or annotations are nil, it's a no-op.

func CreateNamespaceIfNotExist

func CreateNamespaceIfNotExist(ctx context.Context, k8sClient client.Client, namespace string) error

CreateNamespaceIfNotExist creates a namespace in case it doesn't exist.

func DeleteObject

func DeleteObject(ctx context.Context, k8sClient client.Client, obj *unstructured.Unstructured) (bool, error)

DeleteObject tries to delete the given object from k8s. returns error and true/false if object was deleted or not.

func GetClusterId added in v0.7.0

func GetClusterId(ctx context.Context, runtimeClient client.Client, clusterName string) (string, error)

func GetRootPolicy added in v0.7.0

func GetRootPolicy(ctx context.Context, runtimeClient client.Client, namespacedName string) (*policyv1.Policy,
	error,
)

get the root policy from the cluster policy label value(namespace.name)

func HasAnnotation

func HasAnnotation(obj metav1.Object, annotation string) bool

HasAnnotation returns a bool if the given annotation exists in annotations.

func HasLabel

func HasLabel(obj metav1.Object, label string) bool

HasLabel returns a bool if the given label exists in labels.

func UpdateObject

func UpdateObject(ctx context.Context, k8sClient client.Client, obj *unstructured.Unstructured) error

UpdateObject function updates a given k8s object.

Types

type LabelsField

type LabelsField struct {
	Labels map[string]struct{} `json:"f:labels"`
}

LabelsField presents a "f:labels" field subfield of metadataField.

type MetadataField

type MetadataField struct {
	LabelsField `json:"f:metadata"`
}

MetadataField presents a "f:metadata" field subfield of v1.FieldsV1.

Jump to

Keyboard shortcuts

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