k8s

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAnnotation

func AddAnnotation(obj runtime.Object, key, value string) error

AddAnnotation add annotation to runtime.Object

func AddLabel

func AddLabel(obj runtime.Object, key, value string) error

AddLabel add label to runtime.Object

func AsStructured

func AsStructured[T any](obj *unstructured.Unstructured) (*T, error)

AsStructured convert unstructured to structured

func ClearNamespace

func ClearNamespace(ctx context.Context, c client.Client, ns string) error

ClearNamespace clear namespace if exists.

func DeleteAnnotation

func DeleteAnnotation(obj runtime.Object, key string) error

DeleteAnnotation delete annotation from runtime.Object

func DeleteLabel

func DeleteLabel(obj runtime.Object, key string) error

DeleteLabel delete Label from runtime.Object

func EnsureNamespace

func EnsureNamespace(ctx context.Context, c client.Client, ns string) error

EnsureNamespace ensure namespace existence. If not, create it.

func GetAnnotation

func GetAnnotation(obj runtime.Object, key string) string

GetAnnotation get annotation from runtime.Object

func GetGVKFromResource

func GetGVKFromResource(resource ResourceIdentifier) (schema.GroupVersionKind, error)

GetGVKFromResource returns the GVK for the provided resource identifier.

func GetKindForObject

func GetKindForObject(obj runtime.Object, trimList bool) string

GetKindForObject extract kind from runtime.Object If kind already set, directly use it. Otherwise, use reflection to retrieve it from the struct type. If trimList set to true, the returned kind will be trimmed.

func GetLabel

func GetLabel(obj runtime.Object, key string) string

GetLabel get label from runtime.Object

func GetRuntimeNamespace

func GetRuntimeNamespace() string

GetRuntimeNamespace get namespace of the current running pod, fall back to default vela system

func GetUnstructuredFromResource

func GetUnstructuredFromResource(ctx context.Context, resource ResourceIdentifier) (*unstructured.Unstructured, error)

GetUnstructuredFromResource returns an unstructured object for the provided resource identifier.

func IsGVKNamespaced

func IsGVKNamespaced(gvk schema.GroupVersionKind, restmapper meta.RESTMapper) (bool, error)

IsGVKNamespaced returns true if the object having the provided GVK is namespace scoped.

func IsUnstructuredObject

func IsUnstructuredObject(obj runtime.Object) bool

IsUnstructuredObject check if runtime.Object is unstructured

Types

type ResourceIdentifier

type ResourceIdentifier struct {
	Group      string `json:"group"`
	Resource   string `json:"resource"`
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
}

ResourceIdentifier .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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