convert

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FieldManager identifies cloud-operator as the owner of fields in Server-Side Apply.
	// It is also used by the watcher to check managedFields ownership on K8s objects.
	FieldManager = "illumio-cloud-operator"
)

Variables

This section is empty.

Functions

func BuildConfiguredFromMetadata

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

BuildConfiguredFromMetadata builds a ConfiguredKubernetesObjectData from the already-converted KubernetesObjectData for the runtime cache. Labels and annotations are copied as-is so the reconciler can detect drift via proto.Equal.

func CacheKey added in v1.5.0

func CacheKey(kind, namespace, name string) string

CacheKey builds a cache key from kind, namespace, and name. Both config and runtime caches use this key format so lookups match without needing labels or reverse indexes.

func CacheKeyForObject added in v1.5.0

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

CacheKeyForObject computes a cache key from a configured object's kind, namespace, and name.

func ConvertMetaObjectToMetadata

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

ConvertMetaObjectToMetadata takes a metav1.ObjectMeta and converts it into a proto message object KubernetesObjectData. rawObj is the already-listed unstructured object, used to read kind-specific data (e.g. Pod IPs) without extra API calls.

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 ConvertUnstructuredToAWSResource added in v1.5.0

func ConvertUnstructuredToAWSResource(logger *zap.Logger, obj *k8sUnstructured.Unstructured) (*pb.KubernetesObjectData, error)

ConvertUnstructuredToAWSResource converts an unstructured AWS ClusterNetworkPolicy (networking.k8s.aws/v1alpha1) to a KubernetesObjectData proto.

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 ExtractKind added in v1.5.0

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

ExtractKind returns the Kubernetes kind string for a configured object.

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 IsAWSResource added in v1.5.0

func IsAWSResource(kindOrResource string) bool

IsAWSResource returns true if the input identifies an AWS VPC CNI policy resource. Accepts both Kind (PascalCase) and resource name (lowercase plural).

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 NewAWSResourceConverter added in v1.5.0

func NewAWSResourceConverter(logger *zap.Logger) func(ctx context.Context, obj *k8sUnstructured.Unstructured) (*pb.KubernetesObjectData, error)

NewAWSResourceConverter returns a ResourceConverter for AWS VPC CNI policy resources. It closes over logger so conversion can warn on unexpected values (e.g. unknown policy types) without failing the conversion.

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