package meta import "fmt" // Much of this file was originally forked from github.com/fluxcd/pkg/meta to // avoid the dependency tangle-ups that can occur in a large K8s Golang repository, // in the view that it is better to fork and iterate on a small bit of code to // avoid depending on a large bit of code. // LocalObjectReference contains enough information to locate the referenced // Kubernetes resource object. type LocalObjectReference struct { // Name of the referent. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +required Name string `json:"name"` } // NamespacedObjectReference contains enough information to locate the referenced // Kubernetes resource object in any namespace. type NamespacedObjectReference struct { // Name of the referent. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +required Name string `json:"name"` // Namespace of the referent, when not specified it acts as LocalObjectReference. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +optional Namespace string `json:"namespace,omitempty"` } // String implements Stringer for NamespacedObjectReference so it can be passed // directly to string templates func (nor NamespacedObjectReference) String() string { if nor.Namespace == "" { return nor.Name } return fmt.Sprintf("%s/%s", nor.Namespace, nor.Name) } // NamespacedObjectKindReference contains enough information to locate the typed // referenced Kubernetes resource object in any namespace. type NamespacedObjectKindReference struct { // API version of the referent, if not specified the Kubernetes preferred version will be used. // +optional APIVersion string `json:"apiVersion,omitempty"` // Kind of the referent. // +required Kind string `json:"kind"` // Name of the referent. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +required Name string `json:"name"` // Namespace of the referent, when not specified it acts as LocalObjectReference. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=253 // +optional Namespace string `json:"namespace,omitempty"` }