Documentation ¶
Index ¶
- Constants
- func HasAnnotation(u *unstructured.Unstructured) bool
- func WriteAnnotation(obj *unstructured.Unstructured, mutation ApplyTimeMutation) error
- type ApplyTimeMutation
- type FieldSubstitution
- type ResourceReference
- func (r ResourceReference) Equal(b ResourceReference) bool
- func (r ResourceReference) GroupVersionKind() schema.GroupVersionKind
- func (r ResourceReference) String() string
- func (r ResourceReference) ToObjMetadata() object.ObjMetadata
- func (r ResourceReference) ToUnstructured() *unstructured.Unstructured
Constants ¶
const (
Annotation = "config.kubernetes.io/apply-time-mutation"
)
Variables ¶
This section is empty.
Functions ¶
func HasAnnotation ¶
func HasAnnotation(u *unstructured.Unstructured) bool
func WriteAnnotation ¶
func WriteAnnotation(obj *unstructured.Unstructured, mutation ApplyTimeMutation) error
WriteAnnotation updates the supplied unstructured object to add the apply-time-mutation annotation with a multi-line yaml value.
Types ¶
type ApplyTimeMutation ¶
type ApplyTimeMutation []FieldSubstitution
ApplyTimeMutation is a list of substitutions to perform in the target object before applying, after waiting for the source objects to be reconciled. This most notibly allows status fields to be substituted into spec fields.
func ReadAnnotation ¶
func ReadAnnotation(obj *unstructured.Unstructured) (ApplyTimeMutation, error)
ReadAnnotation returns the slice of substitutions parsed from the apply-time-mutation annotation within the supplied unstructured object.
func (ApplyTimeMutation) Equal ¶
func (a ApplyTimeMutation) Equal(b ApplyTimeMutation) bool
Equal returns true if the substitutions are equivalent, ignoring order. Fulfills Equal interface from github.com/google/go-cmp
type FieldSubstitution ¶
type FieldSubstitution struct { // SourceRef is a reference to the object that contains the source field. SourceRef ResourceReference `json:"sourceRef"` // SourcePath is a JSONPath reference to a field in the source object. // Example: "$.status.number" SourcePath string `json:"sourcePath"` // TargetPath is a JSONPath reference to a field in the target object. // Example: "$.spec.member" TargetPath string `json:"targetPath"` // Token is the substring to replace in the value of the target field. // If empty, the target field value will be set to the source field value. // Example: "${project-number}" // +optional Token string `json:"token,omitempty"` }
FieldSubstitution specifies a substitution that will be performed at apply-time. The source object field will be read and substituted into the target object field, replacing the token.
type ResourceReference ¶
type ResourceReference struct { // Kind is a string value representing the REST resource this object represents. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds Kind string `json:"kind"` // APIVersion defines the versioned schema of this representation of an object. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources // +optional APIVersion string `json:"apiVersion,omitempty"` // Group is accepted as a version-less alternative to APIVersion // More info: https://kubernetes.io/docs/reference/using-api/#api-groups // +optional Group string `json:"group,omitempty"` // Name of the object. // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Name string `json:"name,omitempty"` // Namespace is optional, defaults to the namespace of the target object. // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ // +optional Namespace string `json:"namespace,omitempty"` }
ResourceReference is a reference to a KRM resource by name and kind. One of APIVersion or Group is required. Group is generally preferred, to avoid needing to update the version in lock step with the referenced resource. If neither is provided, the empty group is used.
func ResourceReferenceFromObjMetadata ¶
func ResourceReferenceFromObjMetadata(id object.ObjMetadata) ResourceReference
ResourceReferenceFromObjMetadata returns the object as a ResourceReference
func ResourceReferenceFromUnstructured ¶
func ResourceReferenceFromUnstructured(obj *unstructured.Unstructured) ResourceReference
ResourceReferenceFromUnstructured returns the object as a ResourceReference
func (ResourceReference) Equal ¶
func (r ResourceReference) Equal(b ResourceReference) bool
Equal returns true if the ResourceReference sets are equivalent, ignoring version. Fulfills Equal interface from github.com/google/go-cmp
func (ResourceReference) GroupVersionKind ¶
func (r ResourceReference) GroupVersionKind() schema.GroupVersionKind
GroupVersionKind satisfies the ObjectKind interface for all objects that embed TypeMeta. Prefers Group over APIVersion.
func (ResourceReference) String ¶
func (r ResourceReference) String() string
String returns the format GROUP[/VERSION][/namespaces/NAMESPACE]/KIND/NAME
func (ResourceReference) ToObjMetadata ¶
func (r ResourceReference) ToObjMetadata() object.ObjMetadata
ToUnstructured returns the name, namespace, group, and kind of the ResourceReference, wrapped in a new ObjMetadata object.
func (ResourceReference) ToUnstructured ¶
func (r ResourceReference) ToUnstructured() *unstructured.Unstructured
ToUnstructured returns the name, namespace, group, version, and kind of the ResourceReference, wrapped in a new Unstructured object. This is useful for performing operations with sigs.k8s.io/controller-runtime/pkg/client's unstructured Client.