Documentation
¶
Index ¶
- Variables
- func ApplyOwnerReference(child *unstructured.Unstructured, owner *unstructured.Unstructured) error
- func CalculateHash(ctx context.Context, resource unstructured.Unstructured) (string, error)
- func CreateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
- func DeleteResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
- func ExtractMetadataSubmaps(metadata map[string]interface{}) (map[string]string, map[string]string)
- func ExtractResourceNames(unstrucList *unstructured.UnstructuredList) []string
- func GetAnnotation(un *unstructured.Unstructured, key string) (string, error)
- func GetLabel(un *unstructured.Unstructured, key string) (string, error)
- func GetLiveResource(ctx context.Context, object *unstructured.Unstructured, pluralName string) (*unstructured.Unstructured, error)
- func GetLoggableResource(obj *unstructured.Unstructured) map[string]interface{}
- func GetResource(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, ...) (*unstructured.Unstructured, error)
- func GetSecret(ctx context.Context, client k8sClient.Client, namespace, secretName string) (*corev1.Secret, error)
- func IsValidKubernetesManifestFile(fileName string) bool
- func IsValidKubernetesNamespace(name string) bool
- func ListLiveResource(ctx context.Context, apiGroup string, version string, pluralName string, ...) (unstructured.UnstructuredList, error)
- func ListPodsMetadataOnly(ctx context.Context, c k8sClient.Client, namespace, labels string) (*metav1.PartialObjectMetadataList, error)
- func ListResources(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, ...) (unstructured.UnstructuredList, error)
- func MetaGVKToSchemaGVK(metaGVK metav1.GroupVersionKind) schema.GroupVersionKind
- func NewKubectl() kube.Kubectl
- func NewPodDisruptionBudget(name, namespace string, maxUnavailable int32, ...) *policyv1.PodDisruptionBudget
- func PatchAnnotations(ctx context.Context, c client.Client, obj *unstructured.Unstructured, ...) error
- func PatchLabels(ctx context.Context, c client.Client, obj *unstructured.Unstructured, ...) error
- func PatchResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured, ...) error
- func RawExtensionToUnstructured(rawExtension runtime.RawExtension) (*unstructured.Unstructured, error)
- func SchemaGVKToMetaGVK(schemaGVK schema.GroupVersionKind) metav1.GroupVersionKind
- func SetAndPatchAnnotations(ctx context.Context, c client.Client, obj *unstructured.Unstructured, ...) error
- func SetAndPatchLabels(ctx context.Context, c client.Client, obj *unstructured.Unstructured, ...) error
- func SetAnnotations(target *unstructured.Unstructured, annotationsToSet map[string]string) error
- func SetClientSets(restConfig *rest.Config) error
- func SetLabels(target *unstructured.Unstructured, labelsToSet map[string]string) error
- func StartConfigMapWatcher(ctx context.Context, config *rest.Config) error
- func UpdateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
- type GenericStatus
- type ResourceFilter
- type ResourceType
Constants ¶
This section is empty.
Variables ¶
var DynamicClient *dynamic.DynamicClient
var KubernetesClient *clientkube.Clientset
var NumaplaneClient *versioned.Clientset
Functions ¶
func ApplyOwnerReference ¶ added in v0.22.0
func ApplyOwnerReference(child *unstructured.Unstructured, owner *unstructured.Unstructured) error
func CalculateHash ¶ added in v0.22.0
func CalculateHash(ctx context.Context, resource unstructured.Unstructured) (string, error)
Calculate the sha256 hash of a Resource's definition
func CreateResource ¶ added in v0.8.0
func CreateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
CreateResource creates the resource in the kubernetes cluster
func DeleteResource ¶ added in v0.8.0
func DeleteResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
DeleteResource deletes the resource from the kubernetes cluster
func ExtractMetadataSubmaps ¶ added in v0.28.0
ExtractMetadataSubmaps extracts labels and annotations from a metadata map and converts them to map[string]string. Returns (labels, annotations) - if not found returns empty map
func ExtractResourceNames ¶ added in v0.10.0
func ExtractResourceNames(unstrucList *unstructured.UnstructuredList) []string
ExtractResourceNames extracts the names of the resources from an UnstructuredList
func GetAnnotation ¶ added in v0.29.0
func GetAnnotation(un *unstructured.Unstructured, key string) (string, error)
GetAnnotation returns the annotation identified by "key"
func GetLabel ¶ added in v0.2.0
func GetLabel(un *unstructured.Unstructured, key string) (string, error)
GetLabel returns the label identified by "key"
func GetLiveResource ¶ added in v0.8.0
func GetLiveResource( ctx context.Context, object *unstructured.Unstructured, pluralName string, ) (*unstructured.Unstructured, error)
GetLiveResource converts the generic object to unstructured object and fetches the resource from the API server
func GetLoggableResource ¶ added in v0.27.2
func GetLoggableResource(obj *unstructured.Unstructured) map[string]interface{}
GetLoggableResource returns a map containing only the essential parts of a Kubernetes object for logging purposes, excluding noisy metadata like managedFields
func GetResource ¶
func GetResource(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, namespacedName k8stypes.NamespacedName) (*unstructured.Unstructured, error)
GetResource retrieves the resource from the informer cache, if it's not found then it fetches from the API server.
func GetSecret ¶
func GetSecret(ctx context.Context, client k8sClient.Client, namespace, secretName string) (*corev1.Secret, error)
GetSecret gets secret using the kubernetes client
func ListLiveResource ¶ added in v0.8.0
func ListPodsMetadataOnly ¶ added in v0.14.0
func ListResources ¶ added in v0.8.0
func ListResources(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, namespace string, opts ...client.ListOption) (unstructured.UnstructuredList, error)
ListResources retrieves the list of resources from the informer cache, if it's not found then it fetches from the API server.
func MetaGVKToSchemaGVK ¶ added in v0.22.0
func MetaGVKToSchemaGVK(metaGVK metav1.GroupVersionKind) schema.GroupVersionKind
func NewKubectl ¶
func NewPodDisruptionBudget ¶ added in v0.2.0
func NewPodDisruptionBudget(name, namespace string, maxUnavailable int32, ownerReference []metav1.OwnerReference) *policyv1.PodDisruptionBudget
func PatchAnnotations ¶ added in v0.29.0
func PatchAnnotations(ctx context.Context, c client.Client, obj *unstructured.Unstructured, annotations map[string]string) error
PatchAnnotations patches a Kubernetes resource to add/update one or more annotations
func PatchLabels ¶ added in v0.29.0
func PatchLabels(ctx context.Context, c client.Client, obj *unstructured.Unstructured, labels map[string]string) error
PatchLabels patches a Kubernetes resource to add/update one or more labels
func PatchResource ¶ added in v0.8.0
func PatchResource( ctx context.Context, c client.Client, obj *unstructured.Unstructured, patch string, patchType k8stypes.PatchType, ) error
func RawExtensionToUnstructured ¶ added in v0.26.1
func RawExtensionToUnstructured(rawExtension runtime.RawExtension) (*unstructured.Unstructured, error)
func SchemaGVKToMetaGVK ¶ added in v0.22.0
func SchemaGVKToMetaGVK(schemaGVK schema.GroupVersionKind) metav1.GroupVersionKind
func SetAndPatchAnnotations ¶ added in v0.29.0
func SetAndPatchAnnotations(ctx context.Context, c client.Client, obj *unstructured.Unstructured, annotations map[string]string) error
SetAndPatchAnnotations sets the annotations on an unstructured object and then patches them into the live object
func SetAndPatchLabels ¶ added in v0.29.0
func SetAndPatchLabels(ctx context.Context, c client.Client, obj *unstructured.Unstructured, labels map[string]string) error
SetAndPatchLabels sets the labels on an unstructured object and then patches them into the live object
func SetAnnotations ¶ added in v0.29.0
func SetAnnotations(target *unstructured.Unstructured, annotationsToSet map[string]string) error
SetAnnotations sets one or more annotations on an unstructured object
func SetClientSets ¶ added in v0.10.0
func SetLabels ¶ added in v0.29.0
func SetLabels(target *unstructured.Unstructured, labelsToSet map[string]string) error
SetLabels sets one or more labels on an unstructured object
func StartConfigMapWatcher ¶
StartConfigMapWatcher will start a watcher for ConfigMaps with the given label key and value
func UpdateResource ¶ added in v0.8.0
func UpdateResource(ctx context.Context, c client.Client, obj *unstructured.Unstructured) error
UpdateResource updates the resource in the kubernetes cluster
Types ¶
type GenericStatus ¶
type GenericStatus struct {
Phase string `json:"phase,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
func ParseStatus ¶
func ParseStatus(obj *unstructured.Unstructured) (GenericStatus, error)
type ResourceFilter ¶ added in v0.22.0
type ResourceFilter struct {
IncludedResources []ResourceType
}
ResourceFilter filter resources based on allowed Resource Types
func (*ResourceFilter) IsExcludedResource ¶ added in v0.22.0
func (n *ResourceFilter) IsExcludedResource(group, kind, _ string) bool
type ResourceType ¶ added in v0.22.0
func ParseResourceFilter ¶ added in v0.22.0
func ParseResourceFilter(rules string) ([]ResourceType, error)
ParseResourceFilter parse the given rules to generate the list of resources we allow or watch. The rules are delimited by ';', and each rule is composed by both 'group' and 'kind' which can be empty. For example, 'group=apps,kind=Deployment;group=,kind=ConfigMap'. Note that empty rule is valid.