Documentation ¶
Index ¶
- func AddAnnotation(obj runtime.Object, key, value string) error
- func AddLabel(obj runtime.Object, key, value string) error
- func AsStructured[T any](obj *unstructured.Unstructured) (*T, error)
- func ClearNamespace(ctx context.Context, c client.Client, ns string) error
- func DeleteAnnotation(obj runtime.Object, key string) error
- func DeleteLabel(obj runtime.Object, key string) error
- func EnsureNamespace(ctx context.Context, c client.Client, ns string) error
- func GetAnnotation(obj runtime.Object, key string) string
- func GetGVKFromResource(resource ResourceIdentifier) (schema.GroupVersionKind, error)
- func GetKindForObject(obj runtime.Object, trimList bool) string
- func GetLabel(obj runtime.Object, key string) string
- func GetRuntimeNamespace() string
- func GetUnstructuredFromResource(ctx context.Context, resource ResourceIdentifier) (*unstructured.Unstructured, error)
- func IsGVKNamespaced(gvk schema.GroupVersionKind, restmapper meta.RESTMapper) (bool, error)
- func IsUnstructuredObject(obj runtime.Object) bool
- type ResourceIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAnnotation ¶
AddAnnotation add annotation to runtime.Object
func AsStructured ¶
func AsStructured[T any](obj *unstructured.Unstructured) (*T, error)
AsStructured convert unstructured to structured
func ClearNamespace ¶
ClearNamespace clear namespace if exists.
func DeleteAnnotation ¶
DeleteAnnotation delete annotation from runtime.Object
func DeleteLabel ¶
DeleteLabel delete Label from runtime.Object
func EnsureNamespace ¶
EnsureNamespace ensure namespace existence. If not, create it.
func GetAnnotation ¶
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 ¶
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 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 ¶
IsUnstructuredObject check if runtime.Object is unstructured