Documentation
¶
Index ¶
- Constants
- func HasAnnotation(u *unstructured.Unstructured) bool
- func ResourceReferenceToObjMeta(ref ResourceReference) (object.ObjMetadata, error)
- 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) ObjMetadata() object.ObjMetadata
- func (r ResourceReference) String() string
- func (r ResourceReference) Unstructured() *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 ResourceReferenceToObjMeta ¶
func ResourceReferenceToObjMeta(ref ResourceReference) (object.ObjMetadata, error)
ResourceReferenceToObjMeta extracts the identifying information from a ResourceReference and returns it as Objmetadata. If the values don't pass validation, an error will be returned.
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 resource before applying, after waiting for the source resources 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 resource that contains the source field. SourceRef ResourceReference `json:"sourceRef"` // SourcePath is a JSONPath reference to a field in the source resource. // Example: "$.status.number" SourcePath string `json:"sourcePath"` // TargetPath is a JSONPath reference to a field in the target resource. // 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 resource field will be read and substituted into the target resource 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 resource. // 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 resource. // 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 NewResourceReference ¶
func NewResourceReference(obj *unstructured.Unstructured) ResourceReference
NewResourceReference 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) ObjMetadata ¶
func (r ResourceReference) ObjMetadata() object.ObjMetadata
ObjMetadata returns the name, namespace, group, and kind of the ResourceReference, wrapped in a new ObjMetadata object.
func (ResourceReference) String ¶
func (r ResourceReference) String() string
String returns the format GROUP[/VERSION][/namespaces/NAMESPACE]/KIND/NAME
func (ResourceReference) Unstructured ¶
func (r ResourceReference) Unstructured() *unstructured.Unstructured
Unstructured 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.