Documentation ¶
Overview ¶
+kubebuilder:validation:Optional
Index ¶
- Constants
- func ARMSpecNames(specs []ARMResourceSpec) []string
- func AddAnnotation(obj MetaObject, k string, v string)
- func AddLabel(obj MetaObject, k string, v string)
- func AddToMap(m map[string]string, k string, v string) map[string]string
- func ApplyObjAndEnsureOwner(ctx context.Context, c client.Client, owner client.Object, obj client.Object) (controllerutil.OperationResult, error)
- func ApplyObjsAndEnsureOwner(ctx context.Context, client client.Client, owner client.Object, ...) ([]controllerutil.OperationResult, error)
- func CheckARMIDMatchesSubscription(subscriptionID string, armID *arm.ResourceID) bool
- func CheckTargetOwnedByObj(obj client.Object, target client.Object) error
- func CloneMapOfStringToString(input map[string]string) map[string]string
- func ClonePointerToInt(ptr *int) *int
- func ClonePointerToString(ptr *string) *string
- func CloneSliceOfCondition(slice []conditions.Condition) []conditions.Condition
- func CloneSliceOfString(slice []string) []string
- func ConvertJSONToString(json v1.JSON) string
- func ConvertStringToJSON(s string) v1.JSON
- func ExtractKubernetesResourceNameFromARMName(armName string) string
- func GetAPIVersion(metaObject ARMMetaObject, scheme *runtime.Scheme) (string, error)
- func GetAndParseResourceID(obj ARMMetaObject) (*arm.ResourceID, error)
- func GetChildResourceIDOverride(obj ARMMetaObject) (string, bool)
- func GetIntFromFloat(f float64) int
- func GetOptionalIntValue(ptr *int) int
- func GetOptionalStringValue(ptr *string) string
- func GetOriginalGVK(obj ARMMetaObject) schema.GroupVersionKind
- func GetReadyCondition(obj conditions.Conditioner) *conditions.Condition
- func GetResourceID(obj ARMMetaObject) (string, bool)
- func GetResourceIDOrDefault(obj ARMMetaObject) string
- func GetResourceTypeAndProvider(res ARMMetaObject) (string, []string, error)
- func InterleaveStrSlice(a []string, b []string) []string
- func IsResourceCreatedSuccessfully(obj ARMMetaObject) bool
- func LookupOptionalConfigMapReferenceValue(resolved Resolved[ConfigMapReference, string], ref *ConfigMapReference, ...) (string, error)
- func LookupOwnerGroupKind(v interface{}) (string, string)
- func MinInt(a int, b int) int
- func NewObjectFromExemplar(obj client.Object, scheme *runtime.Scheme) (client.Object, error)
- func RawNames(specs []any) []string
- func RemoveAnnotation(obj MetaObject, k string)
- func RemoveLabel(obj MetaObject, k string)
- func SetChildResourceIDOverride(obj ARMMetaObject, id string)
- func SetResourceID(obj ARMMetaObject, id string)
- func ToEnum[T ~string](str string, enumMap map[string]T) T
- func ValidateCreate(validations []func() (admission.Warnings, error)) (admission.Warnings, error)
- func ValidateDelete(validations []func() (admission.Warnings, error)) (admission.Warnings, error)
- func ValidateOwner(obj ARMMetaObject) (admission.Warnings, error)
- func ValidateResourceReferences(refs set.Set[ResourceReference]) (admission.Warnings, error)
- func ValidateUpdate(old runtime.Object, ...) (admission.Warnings, error)
- func ValidateWriteOnceProperties(oldObj ARMMetaObject, newObj ARMMetaObject) (admission.Warnings, error)
- func VerifyResourceOwnerARMID(resource ARMMetaObject) error
- type ARMMetaObject
- func NewEmptyVersionedResource(metaObject ARMMetaObject, scheme *runtime.Scheme) (ARMMetaObject, error)
- func NewEmptyVersionedResourceFromGVK(scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ARMMetaObject, error)
- func ObjAsOriginalVersion(obj ARMMetaObject, scheme *runtime.Scheme) (ARMMetaObject, error)
- func ObjAsVersion(obj ARMMetaObject, scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ARMMetaObject, error)
- type ARMOwned
- type ARMOwnedMetaObject
- type ARMResource
- type ARMResourceSpec
- type ARMResourceStatus
- type ARMTransformer
- type ArbitraryOwnerReference
- type ConfigMapDestination
- type ConfigMapReference
- func (c ConfigMapReference) AsNamespacedRef(namespace string) NamespacedConfigMapReference
- func (c ConfigMapReference) Copy() ConfigMapReference
- func (in *ConfigMapReference) DeepCopy() *ConfigMapReference
- func (in *ConfigMapReference) DeepCopyInto(out *ConfigMapReference)
- func (c ConfigMapReference) Index() []string
- func (c ConfigMapReference) String() string
- type ConvertToARMResolvedDetails
- type ConvertibleSpec
- type ConvertibleStatus
- func GetVersionedStatus(metaObject ARMMetaObject, scheme *runtime.Scheme) (ConvertibleStatus, error)
- func NewEmptyVersionedStatus(metaObject ARMMetaObject, scheme *runtime.Scheme) (ConvertibleStatus, error)
- func NewEmptyVersionedStatusFromGVK(metaObject ARMMetaObject, scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ConvertibleStatus, error)
- type Defaulter
- type FromARMConverter
- type GroupVersionKindAware
- type ImportableARMResource
- type ImportableResource
- type Indexer
- type KnownResourceReference
- func (ref KnownResourceReference) AsResourceReference(group string, kind string) *ResourceReference
- func (ref KnownResourceReference) Copy() KnownResourceReference
- func (in *KnownResourceReference) DeepCopy() *KnownResourceReference
- func (in *KnownResourceReference) DeepCopyInto(out *KnownResourceReference)
- type KubernetesConfigExporter
- type KubernetesOwnerReference
- func (ref KubernetesOwnerReference) AsResourceReference(group string, kind string) *ResourceReference
- func (ref KubernetesOwnerReference) Copy() KubernetesOwnerReference
- func (in *KubernetesOwnerReference) DeepCopy() *KubernetesOwnerReference
- func (in *KubernetesOwnerReference) DeepCopyInto(out *KubernetesOwnerReference)
- type KubernetesResource
- type KubernetesSecretExportResult
- type KubernetesSecretExporter
- type LocatableResource
- type MetaObject
- type NamespacedConfigMapReference
- type NamespacedResourceReference
- type NamespacedSecretMapReference
- type NamespacedSecretReference
- type PropertyBag
- type Reconciler
- type Resolved
- type ResourceExtension
- type ResourceOperation
- type ResourceReference
- func (ref ResourceReference) AsNamespacedRef(namespace string) NamespacedResourceReference
- func (ref ResourceReference) Copy() ResourceReference
- func (in *ResourceReference) DeepCopy() *ResourceReference
- func (in *ResourceReference) DeepCopyInto(out *ResourceReference)
- func (ref ResourceReference) GroupKind() schema.GroupKind
- func (ref ResourceReference) IsDirectARMReference() bool
- func (ref ResourceReference) IsKubernetesReference() bool
- func (ref ResourceReference) String() string
- func (ref ResourceReference) Validate() (admission.Warnings, error)
- type ResourceScope
- type SecretDestination
- type SecretMapReference
- func (s SecretMapReference) AsNamespacedRef(namespace string) NamespacedSecretMapReference
- func (s SecretMapReference) Copy() SecretMapReference
- func (in *SecretMapReference) DeepCopy() *SecretMapReference
- func (in *SecretMapReference) DeepCopyInto(out *SecretMapReference)
- func (c SecretMapReference) Index() []string
- func (s SecretMapReference) String() string
- type SecretReference
- func (s SecretReference) AsNamespacedRef(namespace string) NamespacedSecretReference
- func (s SecretReference) Copy() SecretReference
- func (in *SecretReference) DeepCopy() *SecretReference
- func (in *SecretReference) DeepCopyInto(out *SecretReference)
- func (c SecretReference) Index() []string
- func (s SecretReference) String() string
- type SupportedResourceOperations
- type ToARMConverter
- type Validator
Constants ¶
const ( // ResourceScopeLocation is a resource that is deployed into a location ResourceScopeLocation = ResourceScope("location") // ResourceScopeResourceGroup is a resource that is deployed into a resource group ResourceScopeResourceGroup = ResourceScope("resourcegroup") // ResourceScopeExtension is an extension resource. Extension resources can have any resource as their parent. ResourceScopeExtension = ResourceScope("extension") // ResourceScopeTenant is an Azure resource rooted to the tenant (examples include subscription, managementGroup, etc) ResourceScopeTenant = ResourceScope("tenant") )
const ( ResourceOperationGet = ResourceOperation("GET") ResourceOperationHead = ResourceOperation("HEAD") ResourceOperationPut = ResourceOperation("PUT") ResourceOperationDelete = ResourceOperation("DELETE") )
const ( ResourceIDAnnotation = "serviceoperator.azure.com/resource-id" // ChildResourceIDOverrideAnnotation is an annotation that can be used to force child resources // to be owned by a different resource ID than it would normally. This is primarily used for // resources like SubscriptionAlias + Subscription, where the create API doesn't use the same // ResourceID as needed by child resources of the subscription. // When present, this takes precedent over the resources AzureName() and Type. // TODO: Currently this annotation can only be used on the root resource in a resource hierarchy. // TODO: For example if A owns B owns C, this annotation can be used on A but not on B or C. ChildResourceIDOverrideAnnotation = "serviceoperator.azure.com/child-resource-id-override" )
TODO: It's weird that this is isn't with the other annotations TODO: Should we move them all here (so they're exported?) Or shold we move them TODO: to serviceoperator-internal.azure.com to signify they are internal?
const ReconcilerFinalizer = "serviceoperator.azure.com/finalizer"
Variables ¶
This section is empty.
Functions ¶
func ARMSpecNames ¶
func ARMSpecNames(specs []ARMResourceSpec) []string
ARMSpecNames returns a slice of names from the given ARMResourceSpec slice.
func AddAnnotation ¶
func AddAnnotation(obj MetaObject, k string, v string)
AddAnnotation adds the specified annotation to the object. Empty string annotations are not allowed. Attempting to add an annotation with a value of empty string will result in the removal of that annotation.
func AddLabel ¶
func AddLabel(obj MetaObject, k string, v string)
AddLabel adds the specified label to the object. Empty string labels are not allowed. Attempting to add a label with a value of empty string will result in the removal of that label.
func ApplyObjAndEnsureOwner ¶
func ApplyObjAndEnsureOwner(ctx context.Context, c client.Client, owner client.Object, obj client.Object) (controllerutil.OperationResult, error)
ApplyObjAndEnsureOwner applies the object (similar to kubectl apply). If the object does not exist it is created. If it exists, it is updated.
func ApplyObjsAndEnsureOwner ¶
func ApplyObjsAndEnsureOwner(ctx context.Context, client client.Client, owner client.Object, objs []client.Object) ([]controllerutil.OperationResult, error)
ApplyObjsAndEnsureOwner applies the specified collection of objects (similar to kubectl apply). If the objects do not exist they are created. If they exist, they are updated. An attempt is made to apply each object before returning an error.
func CheckARMIDMatchesSubscription ¶
func CheckARMIDMatchesSubscription(subscriptionID string, armID *arm.ResourceID) bool
func CheckTargetOwnedByObj ¶
CheckTargetOwnedByObj raises an error if the target object is not owned by obj.
func CloneMapOfStringToString ¶
CloneMapOfStringToString clones the given map[string]string. It is used (indirectly) by the generator when generating property conversions.
func ClonePointerToInt ¶
ClonePointerToInt clones the given *int. It is used (indirectly) by the generator when generating property conversions.
func ClonePointerToString ¶
ClonePointerToString clones the given *string. It is used (indirectly) by the generator when generating property conversions.
func CloneSliceOfCondition ¶
func CloneSliceOfCondition(slice []conditions.Condition) []conditions.Condition
CloneSliceOfCondition clones the given []conditions.Condition. It is used (indirectly) by the generator when generating property conversions.
func CloneSliceOfString ¶
CloneSliceOfString clones the given []string. It is used (indirectly) by the generator when generating property conversions.
func ConvertJSONToString ¶
ConvertJSONToString returns the string value of the given v1.JSON.
func ConvertStringToJSON ¶
ConvertStringToJSON returns the v1.JSON value of the given string.
func ExtractKubernetesResourceNameFromARMName ¶
ExtractKubernetesResourceNameFromARMName extracts the Kubernetes resource name from an ARM name. See https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/child-resource-name-type#outside-parent-resource for details on the format of the name field in ARM templates.
func GetAPIVersion ¶
func GetAPIVersion(metaObject ARMMetaObject, scheme *runtime.Scheme) (string, error)
GetAPIVersion returns the ARM API version that should be used with the resource
func GetAndParseResourceID ¶
func GetAndParseResourceID(obj ARMMetaObject) (*arm.ResourceID, error)
GetAndParseResourceID gets the ARM ID from the given MetaObject and parses it into its constituent parts
func GetChildResourceIDOverride ¶
func GetChildResourceIDOverride(obj ARMMetaObject) (string, bool)
func GetIntFromFloat ¶
GetIntFromFloat returns the int value of the given float64. Primarily used when initializing Spec properties from Status properties.
func GetOptionalIntValue ¶
GetOptionalIntValue clones the given *int, or returns 0 if the pointer is nil. It is used (indirectly) by the generator when generating property conversions.
func GetOptionalStringValue ¶
GetOptionalStringValue clones the given *string, or returns empty string if the pointer is nil. It is used (indirectly) by the generator when generating property conversions.
func GetOriginalGVK ¶
func GetOriginalGVK(obj ARMMetaObject) schema.GroupVersionKind
GetOriginalGVK gets the GVK the original GVK the object was created with.
func GetReadyCondition ¶
func GetReadyCondition(obj conditions.Conditioner) *conditions.Condition
GetReadyCondition gets the ready condition from the object
func GetResourceID ¶
func GetResourceID(obj ARMMetaObject) (string, bool)
TODO: We really want these methods to be on ARMMetaObject itself -- should update code generator to make them at some point
func GetResourceIDOrDefault ¶
func GetResourceIDOrDefault(obj ARMMetaObject) string
func GetResourceTypeAndProvider ¶
func GetResourceTypeAndProvider(res ARMMetaObject) (string, []string, error)
GetResourceTypeAndProvider returns the provider and the array of resource types which represent the resource. For example: Microsoft.Compute/virtualMachineScaleSets would return ("Microsoft.Compute", []string{"virtualMachineScaleSets"}, nil)
func InterleaveStrSlice ¶
InterleaveStrSlice interleaves the elements of the two provided slices. The resulting slice looks like: []{<element 1 from a>, <element 1 from b>, <element 2 from a>, <element 2 from b>...}. If one slice is longer than the other, the elements are interleaved until the shorter slice is out of elements, at which point all remaining elements are from the longer slice.
func IsResourceCreatedSuccessfully ¶
func IsResourceCreatedSuccessfully(obj ARMMetaObject) bool
func LookupOptionalConfigMapReferenceValue ¶
func LookupOptionalConfigMapReferenceValue(resolved Resolved[ConfigMapReference, string], ref *ConfigMapReference, value *string) (string, error)
LookupOptionalConfigMapReferenceValue looks up a ConfigMapReference if it's not nil, or else returns the provided value
func LookupOwnerGroupKind ¶
LookupOwnerGroupKind looks up an owners group and kind annotations using reflection. This is primarily used to convert from a KnownResourceReference to the more general ResourceReference
func MinInt ¶
MinInt returns the minimum of the two provided ints. The fact that this doesn't exist in the Go standard library is depressing.
func NewObjectFromExemplar ¶
NewObjectFromExemplar creates a new client.Object with the same GVK as the provided client.Object. The supplied client.Object is not changed and the returned client.Object is empty.
func RemoveAnnotation ¶
func RemoveAnnotation(obj MetaObject, k string)
RemoveAnnotation removes the specified annotation from the object
func RemoveLabel ¶
func RemoveLabel(obj MetaObject, k string)
RemoveLabel removes the specified label from the object
func SetChildResourceIDOverride ¶
func SetChildResourceIDOverride(obj ARMMetaObject, id string)
func SetResourceID ¶
func SetResourceID(obj ARMMetaObject, id string)
func ToEnum ¶
ToEnum does a case-insensitive conversion of a string to an enum using a provided conversion map. If the required value is not found, a literal cast will be used to return the enum.
func ValidateCreate ¶
func ValidateDelete ¶
func ValidateOwner ¶
func ValidateOwner(obj ARMMetaObject) (admission.Warnings, error)
ValidateOwner calls Validate on the resource Owner
func ValidateResourceReferences ¶
ValidateResourceReferences calls Validate on each ResourceReference
func ValidateUpdate ¶
func ValidateWriteOnceProperties ¶
func ValidateWriteOnceProperties(oldObj ARMMetaObject, newObj ARMMetaObject) (admission.Warnings, error)
ValidateWriteOnceProperties function validates the update on WriteOnce properties.
func VerifyResourceOwnerARMID ¶
func VerifyResourceOwnerARMID(resource ARMMetaObject) error
Types ¶
type ARMMetaObject ¶
type ARMMetaObject interface { MetaObject KubernetesResource }
ARMMetaObject represents an arbitrary ASO resource that is an ARM resource
func NewEmptyVersionedResource ¶
func NewEmptyVersionedResource(metaObject ARMMetaObject, scheme *runtime.Scheme) (ARMMetaObject, error)
NewEmptyVersionedResource returns a new blank resource based on the passed metaObject; the original API version used (if available) from when the resource was first created is used to identify the version to return. Returns an empty resource.
func NewEmptyVersionedResourceFromGVK ¶
func NewEmptyVersionedResourceFromGVK(scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ARMMetaObject, error)
NewEmptyVersionedResourceFromGVK creates a new empty versioned resource from the specified GVK
func ObjAsOriginalVersion ¶
func ObjAsOriginalVersion(obj ARMMetaObject, scheme *runtime.Scheme) (ARMMetaObject, error)
ObjAsOriginalVersion returns the obj as the original API version used to create it.
func ObjAsVersion ¶
func ObjAsVersion(obj ARMMetaObject, scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ARMMetaObject, error)
ObjAsVersion returns the object as the specified version, or an error if it cannot be converted to the requested version.
type ARMOwned ¶
type ARMOwned interface { // Owner returns the ResourceReference of the owner, or nil if there is no owner Owner() *ResourceReference }
type ARMOwnedMetaObject ¶
type ARMOwnedMetaObject interface { MetaObject ARMOwned }
ARMOwnedMetaObject represents an arbitrary ASO resource that is owned by an ARM resource
type ARMResource ¶
type ARMResource interface { Spec() ARMResourceSpec Status() ARMResourceStatus GetID() string // TODO: Should this be on Status instead? }
func NewARMResource ¶
func NewARMResource(spec ARMResourceSpec, status ARMResourceStatus, id string) ARMResource
type ARMResourceSpec ¶
ARMResourceSpec is an ARM resource specification. This interface contains methods to access properties common to all ARM Resource Specs. An Azure Deployment is made of these.
type ARMResourceStatus ¶
type ARMResourceStatus interface { }
ARMResourceStatus is an ARM resource status
func NewEmptyARMStatus ¶
func NewEmptyARMStatus(metaObject ARMMetaObject, scheme *runtime.Scheme) (ARMResourceStatus, error)
NewEmptyARMStatus returns an empty ARM status object ready for deserialization from ARM; the original API version used when the resource was first created is used to create the appropriate version
type ARMTransformer ¶
type ARMTransformer interface { ToARMConverter FromARMConverter }
TODO: Consider ArmSpecTransformer and ARMTransformer, so we don't have to pass owningName/name through all the calls ARMTransformer is a type which can be converted to/from an Arm object shape. Each CRD resource must implement these methods.
type ArbitraryOwnerReference ¶
type ArbitraryOwnerReference struct { // This is the name of the Kubernetes resource to reference. Name string `json:"name,omitempty"` // Group is the Kubernetes group of the resource. Group string `json:"group,omitempty"` // Kind is the Kubernetes kind of the resource. Kind string `json:"kind,omitempty"` // Ownership across namespaces is not supported. // +kubebuilder:validation:Pattern="(?i)(^(/subscriptions/([^/]+)(/resourcegroups/([^/]+))?)?/providers/([^/]+)/([^/]+/[^/]+)(/([^/]+/[^/]+))*$|^/subscriptions/([^/]+)(/resourcegroups/([^/]+))?$)" ARMID string `json:"armId,omitempty"` }
TODO: This type and ResourceReference are almost exactly the same now... ArbitraryOwnerReference is an owner reference to an unknown type. +kubebuilder:object:generate=true
func (ArbitraryOwnerReference) AsResourceReference ¶
func (ref ArbitraryOwnerReference) AsResourceReference() *ResourceReference
AsResourceReference transforms this ArbitraryOwnerReference into a ResourceReference
func (ArbitraryOwnerReference) Copy ¶
func (ref ArbitraryOwnerReference) Copy() ArbitraryOwnerReference
Copy makes an independent copy of the ArbitraryOwnerReference
func (*ArbitraryOwnerReference) DeepCopy ¶
func (in *ArbitraryOwnerReference) DeepCopy() *ArbitraryOwnerReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArbitraryOwnerReference.
func (*ArbitraryOwnerReference) DeepCopyInto ¶
func (in *ArbitraryOwnerReference) DeepCopyInto(out *ArbitraryOwnerReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ConfigMapDestination ¶
type ConfigMapDestination struct { // Name is the name of the Kubernetes ConfigMap to write to. // The ConfigMap will be created in the same namespace as the resource. // +kubebuilder:validation:Required Name string `json:"name,omitempty"` // Key is the key in the ConfigMap being referenced // +kubebuilder:validation:Required Key string `json:"key,omitempty"` }
ConfigMapDestination describes the location to store a single configmap value Note: This is similar to: SecretDestination in secrets.go. Changes to one may need to be made to the others as well.
func (ConfigMapDestination) Copy ¶
func (c ConfigMapDestination) Copy() ConfigMapDestination
Copy makes an independent copy of the ConfigMapDestination
func (ConfigMapDestination) String ¶
func (c ConfigMapDestination) String() string
type ConfigMapReference ¶
type ConfigMapReference struct { // Name is the name of the Kubernetes configmap being referenced. // The configmap must be in the same namespace as the resource // +kubebuilder:validation:Required Name string `json:"name,omitempty"` // Key is the key in the Kubernetes configmap being referenced // +kubebuilder:validation:Required Key string `json:"key,omitempty"` }
ConfigMapReference is a reference to a Kubernetes configmap and key in the same namespace as the resource it is on. +kubebuilder:object:generate=true
func (ConfigMapReference) AsNamespacedRef ¶
func (c ConfigMapReference) AsNamespacedRef(namespace string) NamespacedConfigMapReference
AsNamespacedRef creates a NamespacedSecretReference from this SecretReference in the given namespace
func (ConfigMapReference) Copy ¶
func (c ConfigMapReference) Copy() ConfigMapReference
Copy makes an independent copy of the ConfigMapReference
func (*ConfigMapReference) DeepCopy ¶
func (in *ConfigMapReference) DeepCopy() *ConfigMapReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapReference.
func (*ConfigMapReference) DeepCopyInto ¶
func (in *ConfigMapReference) DeepCopyInto(out *ConfigMapReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (ConfigMapReference) Index ¶
func (c ConfigMapReference) Index() []string
func (ConfigMapReference) String ¶
func (c ConfigMapReference) String() string
type ConvertToARMResolvedDetails ¶
type ConvertToARMResolvedDetails struct { // Name is the name of the resource // TODO: We might be able to remove this in favor of using AzureName() everywhere in the future Name string // ResolvedReferences is a set of references which have been resolved to their ARM IDs. ResolvedReferences Resolved[ResourceReference, string] // ResolvedSecrets is a set of secret references which have been resolved to the corresponding // secret value. ResolvedSecrets Resolved[SecretReference, string] // ResolvedSecretMaps is a set of secret references which have been resolved to the corresponding secrets. ResolvedSecretMaps Resolved[SecretMapReference, map[string]string] // ResolvedConfigMaps is a set of config map references which have been resolved to the corresponding // config map value. ResolvedConfigMaps Resolved[ConfigMapReference, string] }
ConvertToARMResolvedDetails contains resolved references and names for use in converting a Kubernetes type to an ARM type.
type ConvertibleSpec ¶
type ConvertibleSpec interface { // ConvertSpecTo will populate the passed Spec by copying over all available information from this one ConvertSpecTo(destination ConvertibleSpec) error // ConvertSpecFrom will populate this spec by copying over all available information from the passed one ConvertSpecFrom(source ConvertibleSpec) error }
ConvertibleSpec is implemented by Spec types to allow conversion among the different versions of a given spec
Why do we need both directions of conversion?
Each version of a resource is in a different package, so the implementations of this interface will necessarily be referencing types from other packages. If we tried to use an interface with a single method, we'd inevitably end up with circular package references:
+----------------+ +----------------+ | v1 | | v2 | | PersonSpec | --- import v2 ---> | PersonSpec | | | | | | ConvertTo() | <--- import v1 --- | ConvertTo() | +----------------+ +----------------+
Instead, we have to have support for both directions, so that we can always operate from one side of the package reference chain:
+----------------+ +----------------+ | v1 | | v2 | | PersonSpec | | PersonSpec | | | | | | ConvertTo() | --- import v2 ---> | | | ConvertFrom() | | | +----------------+ +----------------+
func GetVersionedSpec ¶
func GetVersionedSpec(metaObject ARMMetaObject, scheme *runtime.Scheme) (ConvertibleSpec, error)
GetVersionedSpec returns a versioned spec for the provided resource; the original API version used when the resource was first created is used to identify the version to return TODO: This is currently unused
func GetVersionedSpecFromGVK ¶
func GetVersionedSpecFromGVK(metaObject ARMMetaObject, scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ConvertibleSpec, error)
GetVersionedSpecFromGVK returns a versioned spec for the provided resource; the original API version used when the resource was first created is used to identify the version to return
type ConvertibleStatus ¶
type ConvertibleStatus interface { // ConvertStatusTo will populate the passed Status by copying over all available information from this one ConvertStatusTo(destination ConvertibleStatus) error // ConvertStatusFrom will populate this status by copying over all available information from the passed one ConvertStatusFrom(source ConvertibleStatus) error }
ConvertibleStatus is implemented by status types to allow conversion among the different versions of a given status
Why do we need both directions of conversion? See ConvertibleSpec for details.
func GetVersionedStatus ¶
func GetVersionedStatus(metaObject ARMMetaObject, scheme *runtime.Scheme) (ConvertibleStatus, error)
GetVersionedStatus returns a versioned status for the provided resource; the original API version used when the resource was first created is used to identify the version to return
func NewEmptyVersionedStatus ¶
func NewEmptyVersionedStatus(metaObject ARMMetaObject, scheme *runtime.Scheme) (ConvertibleStatus, error)
NewEmptyVersionedStatus returns a blank versioned status for the provided resource; the original API version used when the resource was first created is used to identify the version to return
func NewEmptyVersionedStatusFromGVK ¶
func NewEmptyVersionedStatusFromGVK(metaObject ARMMetaObject, scheme *runtime.Scheme, gvk schema.GroupVersionKind) (ConvertibleStatus, error)
NewEmptyVersionedStatusFromGVK returns a blank versioned status for the provided resource and GVK
type Defaulter ¶
type Defaulter interface {
// CustomDefault performs custom defaults that are run in addition to the code generated defaults.
CustomDefault()
}
Defaulter is similar to controller-runtime/pkg/webhook/admission Defaulter. Implementing this interface allows you to hook into the code generated defaults and add custom handcrafted defaults.
type FromARMConverter ¶
type FromARMConverter interface { NewEmptyARMValue() ARMResourceStatus PopulateFromARM(owner ArbitraryOwnerReference, input interface{}) error }
type GroupVersionKindAware ¶
type GroupVersionKindAware interface { // OriginalGVK returns the GroupVersionKind originally used to create the resource (regardless of any conversions) OriginalGVK() *schema.GroupVersionKind }
GroupVersionKindAware is implemented by resources that are aware of which version of the resource was originally specified. This allows us to interface with ARM using an API version specified by an end user.
type ImportableARMResource ¶
type ImportableARMResource interface { ImportableResource ARMMetaObject }
ImportableARMResource represents an ARM based resource that can be imported into the operator
type ImportableResource ¶
type ImportableResource interface { // InitializeSpec initializes the Spec of the resource from the provided Status. InitializeSpec(status ConvertibleStatus) error }
ImportableResource is implemented by any resource that can be imported into the operator
type Indexer ¶
type Indexer interface { // Index returns the index of the Indexer. The index can be passed to a registration.Index to // build an index for the controller-runtime client. If Index returns nil, there is nothing to index. // See controller-runtime mgr.GetFieldIndexer().IndexField() for more details. Index() []string }
type KnownResourceReference ¶
type KnownResourceReference struct { // This is the name of the Kubernetes resource to reference. Name string `json:"name,omitempty"` // +kubebuilder:validation:Pattern="(?i)(^(/subscriptions/([^/]+)(/resourcegroups/([^/]+))?)?/providers/([^/]+)/([^/]+/[^/]+)(/([^/]+/[^/]+))*$|^/subscriptions/([^/]+)(/resourcegroups/([^/]+))?$)" ARMID string `json:"armId,omitempty"` }
KnownResourceReference is a resource reference to a known type. +kubebuilder:object:generate=true
func (KnownResourceReference) AsResourceReference ¶
func (ref KnownResourceReference) AsResourceReference(group string, kind string) *ResourceReference
AsResourceReference transforms this KnownResourceReference into a ResourceReference
func (KnownResourceReference) Copy ¶
func (ref KnownResourceReference) Copy() KnownResourceReference
Copy makes an independent copy of the KnownResourceReference
func (*KnownResourceReference) DeepCopy ¶
func (in *KnownResourceReference) DeepCopy() *KnownResourceReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KnownResourceReference.
func (*KnownResourceReference) DeepCopyInto ¶
func (in *KnownResourceReference) DeepCopyInto(out *KnownResourceReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type KubernetesConfigExporter ¶
type KubernetesConfigExporter interface { // ExportKubernetesConfigMaps provides a list of Kubernetes ConfigMaps for the operator to create once the resource which // implements this interface is successfully provisioned. This method is invoked once a resource has been // successfully created in Azure, but before the Ready condition has been marked successful. ExportKubernetesConfigMaps( ctx context.Context, obj MetaObject, armClient *genericarmclient.GenericClient, log logr.Logger) ([]client.Object, error) }
KubernetesConfigExporter defines a resource which can create configmaps in Kubernetes
type KubernetesOwnerReference ¶
type KubernetesOwnerReference struct { // +kubebuilder:validation:Required // This is the name of the Kubernetes resource to reference. Name string `json:"name,omitempty"` }
KubernetesOwnerReference is a resource reference to a known type in Kuberentes. Most types support ARM references as well but some (such as SQL users) do not. +kubebuilder:object:generate=true
func (KubernetesOwnerReference) AsResourceReference ¶
func (ref KubernetesOwnerReference) AsResourceReference(group string, kind string) *ResourceReference
AsResourceReference transforms this KnownResourceReference into a ResourceReference
func (KubernetesOwnerReference) Copy ¶
func (ref KubernetesOwnerReference) Copy() KubernetesOwnerReference
Copy makes an independent copy of the KubernetesOwnerReference
func (*KubernetesOwnerReference) DeepCopy ¶
func (in *KubernetesOwnerReference) DeepCopy() *KubernetesOwnerReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesOwnerReference.
func (*KubernetesOwnerReference) DeepCopyInto ¶
func (in *KubernetesOwnerReference) DeepCopyInto(out *KubernetesOwnerReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type KubernetesResource ¶
type KubernetesResource interface { ARMOwned SupportedResourceOperations // AzureName returns the Azure name of the resource AzureName() string // GetType returns the type of the resource according to Azure. For example Microsoft.Resources/resourceGroups or // Microsoft.Network/networkSecurityGroups/securityRules GetType() string // GetResourceScope returns the ResourceScope of the resource. GetResourceScope() ResourceScope // GetAPIVersion returns the API Version of the resource GetAPIVersion() string // GetSpec returns the specification of the resource GetSpec() ConvertibleSpec // GetStatus returns the current status of the resource GetStatus() ConvertibleStatus // NewEmptyStatus returns a blank status ready for population NewEmptyStatus() ConvertibleStatus // SetStatus updates the status of the resource SetStatus(status ConvertibleStatus) error }
KubernetesResource is an Azure resource. This interface contains the common set of methods that apply to all ASO ARM resources.
type KubernetesSecretExportResult ¶
type KubernetesSecretExportResult struct { // Objs is the set of objects (secrets) to export. // Only secrets defined on the operatorSpec.secrets are included here. Secrets referenced via a "secret expression" // in operatorSpec.secretExpressions are returned in RawSecrets for later use. Objs []client.Object // RawSecrets contains the raw secret values from Azure. // The keys are the "names" of the secrets as defined on operatorSpec.secrets (JSON-cased), and the // values are the actual secrets. So for example ManagedCluster has "adminCredentials" and "userCredentials". // This will ONLY contain secrets that were requested via additionalSecrets, NOT secrets requested via // self.spec.operatorSpec.secrets. RawSecrets map[string]string }
type KubernetesSecretExporter ¶
type KubernetesSecretExporter interface { // ExportKubernetesSecrets provides a list of Kubernetes resource for the operator to create once the resource which // implements this interface is successfully provisioned. This method is invoked once a resource has been // successfully created in Azure, but before the Ready condition has been marked successful. ExportKubernetesSecrets( ctx context.Context, obj MetaObject, additionalSecrets set.Set[string], armClient *genericarmclient.GenericClient, log logr.Logger, ) (*KubernetesSecretExportResult, error) }
KubernetesSecretExporter defines a resource which can create retrieve secrets from Azure and export them to Kubernetes secrets.
type LocatableResource ¶
type LocatableResource interface {
Location() string
}
LocatableResource represents a resource with a location.
type MetaObject ¶
type MetaObject interface { runtime.Object metav1.Object conditions.Conditioner }
MetaObject represents an arbitrary ASO custom resource
type NamespacedConfigMapReference ¶
type NamespacedConfigMapReference struct { ConfigMapReference Namespace string }
NamespacedConfigMapReference is a ConfigMapReference with namespace information included
func (NamespacedConfigMapReference) String ¶
func (s NamespacedConfigMapReference) String() string
type NamespacedResourceReference ¶
type NamespacedResourceReference struct { ResourceReference Namespace string }
NamespacedResourceReference is a resource reference with namespace information included
type NamespacedSecretMapReference ¶
type NamespacedSecretMapReference struct { SecretMapReference Namespace string }
NamespacedSecretMapReference is an SecretMapReference with namespace information included
func (NamespacedSecretMapReference) String ¶
func (s NamespacedSecretMapReference) String() string
type NamespacedSecretReference ¶
type NamespacedSecretReference struct { SecretReference Namespace string }
NamespacedSecretReference is a SecretReference with namespace information included
func (NamespacedSecretReference) String ¶
func (s NamespacedSecretReference) String() string
type PropertyBag ¶
PropertyBag is an unordered set of stashed information that used for properties not directly supported by storage resources, allowing for full fidelity round trip conversions
func NewPropertyBag ¶
func NewPropertyBag(originals ...PropertyBag) PropertyBag
PropertyBag returns a new property bag originals is a (potentially empty) sequence of existing property bags who's content will be copied into the new property bag. In the case of key overlaps, values from bags later in the parameter list overwrite the earlier value.
func (PropertyBag) Add ¶
func (bag PropertyBag) Add(property string, value interface{}) error
Add is used to add a value into the bag; exact formatting depends on the type. Any existing value will be overwritten. property is the name of the item to put into the bag value is the instance to be stashed away for later
func (PropertyBag) Contains ¶
func (bag PropertyBag) Contains(name string) bool
Contains returns true if the specified name is present in the bag; false otherwise
func (PropertyBag) Pull ¶
func (bag PropertyBag) Pull(property string, destination interface{}) error
Pull removes a value from the bag, using it to populate the destination property is the name of the item to remove and return destination should be a pointer to where the value is to be placed If the item is present and successfully deserialized, returns no error (nil); otherwise returns an error. If an error happens deserializing an item from the bag, it is still removed from the bag.
func (PropertyBag) Remove ¶
func (bag PropertyBag) Remove(property string)
Remove ensures the property bag doesn't contain a value for the specified name property is the name of the item to remove It is not an error to try and remove an item that's not present
type Reconciler ¶
type Reconciler interface { // CreateOrUpdate performs create or update of the resource. This must be idempotent. In the event the CreateOrUpdate // takes a long time, CreateOrUpdate should return quickly but set an annotation or ready condition that can be used on subsequent // calls to monitor the ongoing CreateOrUpdate. CreateOrUpdate( ctx context.Context, log logr.Logger, eventRecorder record.EventRecorder, obj MetaObject) (ctrl.Result, error) // Delete performs deletion of the resource. This must be idempotent. Removal of the common finalizer is performed elsewhere. // Delete should concern itself with issuing and tracking the resource deletion. Delete( ctx context.Context, log logr.Logger, eventRecorder record.EventRecorder, obj MetaObject) (ctrl.Result, error) // Claim performs resource specific claim actions. This must be idempotent. // A standard finalizer is added to all resources, Claim // should deal with any resource specific claiming actions (such as setting a resource ID annotation, etc). // If Claim returns an error then reconciliation will be retried according to the returned Ready condition until // no error is returned. Once Claim succeeds CreateOrUpdate is called. Claim( ctx context.Context, log logr.Logger, eventRecorder record.EventRecorder, obj MetaObject) error // UpdateStatus fetches the resource's status but performs no other actions. This is primarily called if the // reconcile-policy annotation was set in such a way that it blocks CreateOrUpdate UpdateStatus( ctx context.Context, log logr.Logger, eventRecorder record.EventRecorder, obj MetaObject) error }
Reconciler performs create/delete actions against a particular kind of resource.
type Resolved ¶
type Resolved[T reference, V any] struct { // contains filtered or unexported fields }
Resolved is a set of references which have been resolved for a particular resource.
func MakeResolved ¶
MakeResolved creates a Resolved
func (Resolved[T, V]) Lookup ¶
Lookup looks up the value for the given reference. If it cannot be found, an error is returned.
func (Resolved[T, V]) LookupFromPtr ¶
LookupFromPtr looks up the value for the given reference. If the reference is nil, an error is returned. If the value cannot be found, an error is returned
type ResourceExtension ¶
type ResourceExtension interface { // GetExtendedResources returns the KubernetesResource slice for Resource versions GetExtendedResources() []KubernetesResource }
ResourceExtension defines extended functionality of a resource used by the reconciler
type ResourceOperation ¶
type ResourceOperation string
func (ResourceOperation) IsSupportedBy ¶
func (o ResourceOperation) IsSupportedBy(obj SupportedResourceOperations) bool
type ResourceReference ¶
type ResourceReference struct { // Group is the Kubernetes group of the resource. Group string `json:"group,omitempty"` // Kind is the Kubernetes kind of the resource. Kind string `json:"kind,omitempty"` // Name is the Kubernetes name of the resource. Name string `json:"name,omitempty"` // +kubebuilder:validation:Pattern="(?i)(^(/subscriptions/([^/]+)(/resourcegroups/([^/]+))?)?/providers/([^/]+)/([^/]+/[^/]+)(/([^/]+/[^/]+))*$|^/subscriptions/([^/]+)(/resourcegroups/([^/]+))?$)" // ARMID is a string of the form /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. // The /resourcegroups/{resourceGroupName} bit is optional as some resources are scoped at the subscription level // ARMID is mutually exclusive with Group, Kind, Namespace and Name. ARMID string `json:"armId,omitempty"` }
ResourceReference represents a resource reference, either to a Kubernetes resource or directly to an Azure resource via ARMID +kubebuilder:object:generate=true
func CreateResourceReferenceFromARMID ¶
func CreateResourceReferenceFromARMID(armID string) ResourceReference
CreateResourceReferenceFromARMID creates a new ResourceReference from a string representing an ARM ID
func (ResourceReference) AsNamespacedRef ¶
func (ref ResourceReference) AsNamespacedRef(namespace string) NamespacedResourceReference
AsNamespacedRef creates a NamespacedResourceReference from this reference.
func (ResourceReference) Copy ¶
func (ref ResourceReference) Copy() ResourceReference
Copy makes an independent copy of the ResourceReference
func (*ResourceReference) DeepCopy ¶
func (in *ResourceReference) DeepCopy() *ResourceReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceReference.
func (*ResourceReference) DeepCopyInto ¶
func (in *ResourceReference) DeepCopyInto(out *ResourceReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (ResourceReference) GroupKind ¶
func (ref ResourceReference) GroupKind() schema.GroupKind
GroupKind returns the GroupKind of the resource reference
func (ResourceReference) IsDirectARMReference ¶
func (ref ResourceReference) IsDirectARMReference() bool
IsDirectARMReference returns true if this ResourceReference is referring to an ARMID directly.
func (ResourceReference) IsKubernetesReference ¶
func (ref ResourceReference) IsKubernetesReference() bool
IsKubernetesReference returns true if this ResourceReference is referring to a Kubernetes resource.
func (ResourceReference) String ¶
func (ref ResourceReference) String() string
func (ResourceReference) Validate ¶
func (ref ResourceReference) Validate() (admission.Warnings, error)
TODO: We wouldn't need this if controller-gen supported DUs or OneOf better, see: https://github.com/kubernetes-sigs/controller-tools/issues/461 Validate validates the ResourceReference to ensure that it is structurally valid.
type ResourceScope ¶
type ResourceScope string
type SecretDestination ¶
type SecretDestination struct { // Name is the name of the Kubernetes secret to write to. // The secret will be created in the same namespace as the resource. // +kubebuilder:validation:Required Name string `json:"name,omitempty"` // Key is the key in the Kubernetes secret being referenced. // +kubebuilder:validation:Required Key string `json:"key,omitempty"` }
SecretDestination describes the location to store a single secret value. Note: This is similar to: ConfigMapDestination in configmaps.go. Changes to one may need to be made to the others as well.
func (SecretDestination) Copy ¶
func (s SecretDestination) Copy() SecretDestination
Copy makes an independent copy of the SecretDestination
func (SecretDestination) String ¶
func (s SecretDestination) String() string
type SecretMapReference ¶
type SecretMapReference struct { // Name is the name of the Kubernetes secret being referenced. // The secret must be in the same namespace as the resource // +kubebuilder:validation:Required Name string `json:"name"` }
SecretMapReference is a reference to a Kubernetes secret in the same namespace as the resource it is on. +kubebuilder:object:generate=true
func (SecretMapReference) AsNamespacedRef ¶
func (s SecretMapReference) AsNamespacedRef(namespace string) NamespacedSecretMapReference
AsNamespacedRef creates a NamespacedSecretReference from this SecretReference in the given namespace
func (SecretMapReference) Copy ¶
func (s SecretMapReference) Copy() SecretMapReference
Copy makes an independent copy of the SecretMapReference
func (*SecretMapReference) DeepCopy ¶
func (in *SecretMapReference) DeepCopy() *SecretMapReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretMapReference.
func (*SecretMapReference) DeepCopyInto ¶
func (in *SecretMapReference) DeepCopyInto(out *SecretMapReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (SecretMapReference) Index ¶
func (c SecretMapReference) Index() []string
func (SecretMapReference) String ¶
func (s SecretMapReference) String() string
type SecretReference ¶
type SecretReference struct { // Name is the name of the Kubernetes secret being referenced. // The secret must be in the same namespace as the resource // +kubebuilder:validation:Required Name string `json:"name"` // Key is the key in the Kubernetes secret being referenced // +kubebuilder:validation:Required Key string `json:"key"` }
SecretReference is a reference to a Kubernetes secret and key in the same namespace as the resource it is on. +kubebuilder:object:generate=true
func (SecretReference) AsNamespacedRef ¶
func (s SecretReference) AsNamespacedRef(namespace string) NamespacedSecretReference
AsNamespacedRef creates a NamespacedSecretReference from this SecretReference in the given namespace
func (SecretReference) Copy ¶
func (s SecretReference) Copy() SecretReference
Copy makes an independent copy of the SecretReference
func (*SecretReference) DeepCopy ¶
func (in *SecretReference) DeepCopy() *SecretReference
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretReference.
func (*SecretReference) DeepCopyInto ¶
func (in *SecretReference) DeepCopyInto(out *SecretReference)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (SecretReference) Index ¶
func (c SecretReference) Index() []string
func (SecretReference) String ¶
func (s SecretReference) String() string
type SupportedResourceOperations ¶
type SupportedResourceOperations interface { // GetSupportedOperations gets the set of supported resource operations GetSupportedOperations() []ResourceOperation }
type ToARMConverter ¶
type ToARMConverter interface { // ConvertToARM converts this to an ARM resource. ConvertToARM(resolved ConvertToARMResolvedDetails) (interface{}, error) }
type Validator ¶
type Validator interface { // CreateValidations returns validation functions that should be run on create. CreateValidations() []func() (admission.Warnings, error) // UpdateValidations returns validation functions that should be run on update. UpdateValidations() []func(old runtime.Object) (admission.Warnings, error) // DeleteValidations returns validation functions that should be run on delete. DeleteValidations() []func() (admission.Warnings, error) }
Validator is similar to controller-runtime/pkg/webhook/admission Validator. Implementing this interface allows you to hook into the code generated validations and add custom handcrafted validations.
Source Files ¶
- admissions.go
- arm_id.go
- arm_transformer.go
- base_types.go
- configmaps.go
- conversion_helpers.go
- convertible.go
- convertible_spec.go
- convertible_status.go
- enum.go
- finalizer.go
- group_version_kind_aware.go
- helpers.go
- importable_resource.go
- indexer.go
- kubernetes_config_exporter.go
- kubernetes_resource.go
- kubernetes_secret_exporter.go
- owner.go
- property_bag.go
- reconciler.go
- resolved.go
- resource_extension.go
- resource_reference.go
- root_resources.go
- secrets.go
- zz_generated.deepcopy.go