convert

package
v1.3.15-beta2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CloudSecureIDLabel is the label key used to store the CloudSecure object ID.
	// This ID is the unique key in the desired state (config) cache. It is set as a label on
	// Kubernetes objects during apply so the watcher can extract it and use it as the runtime
	// cache key, allowing the reconciler to match desired vs actual state by the same ID.
	CloudSecureIDLabel = "cloud.illum.io/resource-id"

	// ManagedByLabel is the standard Kubernetes label for identifying the managing component.
	// https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
	ManagedByLabel = "app.kubernetes.io/managed-by"

	// ManagedByValue is the value used for the managed-by label.
	ManagedByValue = "illumio-cloud-operator"
)

Variables

This section is empty.

Functions

func BuildConfiguredFromMetadata

func BuildConfiguredFromMetadata(id string, metadata *pb.KubernetesObjectData) (*pb.ConfiguredKubernetesObjectData, error)

BuildConfiguredFromMetadata builds a ConfiguredKubernetesObjectData from the already-converted KubernetesObjectData for the runtime cache. Operator-added labels (cloudsecure-id, managed-by) are stripped so the runtime snapshot matches the shape of the config cache. Annotations are passed through as-is because the operator doesn't add any — SSA handles annotation ownership.

func ConvertMetaObjectToMetadata

func ConvertMetaObjectToMetadata(ctx context.Context, obj metav1.ObjectMeta, clientset kubernetes.Interface, kind, apiGroup, apiVersion string) *pb.KubernetesObjectData

ConvertMetaObjectToMetadata takes a metav1.ObjectMeta and converts it into a proto message object KubernetesMetadata.

func ConvertToApplyObject

func ConvertToApplyObject(data *pb.ConfiguredKubernetesObjectData, apiGroup, apiVersion string) (*unstructured.Unstructured, string, error)

ConvertToApplyObject converts ConfiguredKubernetesObjectData to an *unstructured.Unstructured suitable for Server-Side Apply. Proto specs are marshaled via protojson to preserve strict typing and produce camelCase field names that match Cilium's CRD schema.

func ConvertUnstructuredToCiliumResource

func ConvertUnstructuredToCiliumResource(obj *k8sUnstructured.Unstructured) (*pb.KubernetesObjectData, error)

ConvertUnstructuredToCiliumResource converts an unstructured Cilium resource to a KubernetesObjectData proto. This handles CiliumNetworkPolicy, CiliumClusterwideNetworkPolicy, and CiliumCIDRGroup.

func ExtractResourceName

func ExtractResourceName(data *pb.ConfiguredKubernetesObjectData) (string, error)

ExtractResourceName returns the plural resource name for the given configured object's kind.

func GetMetadataFromResource

func GetMetadataFromResource(logger *zap.Logger, resource unstructured.Unstructured) (*metav1.ObjectMeta, error)

GetMetadataFromResource extracts the metav1.ObjectMeta from an unstructured.Unstructured resource. It utilizes the unstructured's inherent methods to access the metadata directly.

func GetObjectMetadataFromRuntimeObject

func GetObjectMetadataFromRuntimeObject(obj runtime.Object) (*metav1.ObjectMeta, error)

GetObjectMetadataFromRuntimeObject safely extracts metadata from any Kubernetes runtime.Object. It returns a pointer to a metav1.ObjectMeta structure if successful, along with any error encountered.

func IsCiliumResource

func IsCiliumResource(kindOrResource string) bool

IsCiliumResource returns true if the input identifies a Cilium resource. Accepts both Kind (PascalCase) and resource name (lowercase plural).

func NewCoreResourceConverter

func NewCoreResourceConverter(clientset kubernetes.Interface, logger *zap.Logger) func(ctx context.Context, obj *unstructured.Unstructured) (*pb.KubernetesObjectData, error)

NewCoreResourceConverter returns a ResourceConverter for standard Kubernetes resources. It closes over clientset and logger because core resource conversion needs them to fetch additional data (Pod IPs, NetworkPolicy specs, Node provider IDs, Service details).

Types

This section is empty.

Jump to

Keyboard shortcuts

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