genruntime

package
Version: v2.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

+kubebuilder:validation:Optional

Index

Constants

View Source
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")
)
View Source
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?

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 CloneMapOfStringToString

func CloneMapOfStringToString(input map[string]string) map[string]string

CloneMapOfStringToString clones the given map[string]string. It is used (indirectly) by the generator when generating property conversions.

func ClonePointerToInt

func ClonePointerToInt(ptr *int) *int

ClonePointerToInt clones the given *int. It is used (indirectly) by the generator when generating property conversions.

func ClonePointerToString

func ClonePointerToString(ptr *string) *string

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

func CloneSliceOfString(slice []string) []string

CloneSliceOfString clones the given []string. It is used (indirectly) by the generator when generating property conversions.

func ExtractKubernetesResourceNameFromARMName

func ExtractKubernetesResourceNameFromARMName(armName string) string

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 GetOptionalIntValue

func GetOptionalIntValue(ptr *int) int

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

func GetOptionalStringValue(ptr *string) string

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 InterleaveStrSlice

func InterleaveStrSlice(a []string, b []string) []string

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 LookupOwnerGroupKind

func LookupOwnerGroupKind(v interface{}) (string, string)

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

func MinInt(a int, b int) int

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

func NewObjectFromExemplar(obj client.Object, scheme *runtime.Scheme) (client.Object, error)

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 SetChildResourceIDOverride

func SetChildResourceIDOverride(obj ARMMetaObject, id string)

func SetResourceID

func SetResourceID(obj ARMMetaObject, id string)

func ValidateResourceReferences

func ValidateResourceReferences(refs set.Set[ResourceReference]) error

ValidateResourceReferences calls Validate on each ResourceReference

func ValidateSecretDestinations

func ValidateSecretDestinations(destinations []*SecretDestination) error

ValidateSecretDestinations checks that no destination is writing to the same secret/key, as that could cause those secrets to overwrite one another.

func ValidateWriteOnceProperties

func ValidateWriteOnceProperties(oldObj ARMMetaObject, newObj ARMMetaObject) error

ValidateWriteOnceProperties function validates the update on WriteOnce properties.

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

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

type ARMResourceSpec interface {
	GetAPIVersion() string

	GetType() string

	GetName() string
}

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.
	// +kubebuilder:validation:Required
	Name string `json:"name,omitempty"`

	// +kubebuilder:validation:Required
	// Group is the Kubernetes group of the resource.
	Group string `json:"group,omitempty"`

	// +kubebuilder:validation:Required
	// Kind is the Kubernetes kind of the resource.
	Kind string `json:"kind,omitempty"`
}

ArbitraryOwnerReference is an owner reference to an unknown type. +kubebuilder:object:generate=true

func (ArbitraryOwnerReference) Copy

Copy makes an independent copy of the ArbitraryOwnerReference

func (*ArbitraryOwnerReference) DeepCopy

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 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 ResolvedReferences

	// ResolvedSecrets is a set of secret references which have been resolved to the corresponding
	// secret value.
	ResolvedSecrets ResolvedSecrets
}

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

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 interace with ARM using an API version specified by an end user.

type KnownResourceReference

type KnownResourceReference struct {
	// This is the name of the Kubernetes resource to reference.
	// +kubebuilder:validation:Required
	Name string `json:"name,omitempty"`
}

KnownResourceReference is a resource reference to a known type. +kubebuilder:object:generate=true

func (KnownResourceReference) Copy

Copy makes an independent copy of the KnownResourceReference

func (*KnownResourceReference) DeepCopy

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 KubernetesResource

type KubernetesResource interface {
	ARMOwned

	// 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 LocatableResource

type LocatableResource interface {
	Location() string
}

LocatableResource represents a resource with a location. TODO: The generated types should impl this. Currently only ResourceGroup has this interface and it's written manually

type MetaObject

type MetaObject interface {
	runtime.Object
	metav1.Object
	conditions.Conditioner
}

MetaObject represents an arbitrary ASO custom resource

type NamespacedResourceReference

type NamespacedResourceReference struct {
	ResourceReference
	Namespace string
}

NamespacedResourceReference is a resource reference with namespace information included

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

type PropertyBag map[string]string

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 ResolvedReferences

type ResolvedReferences struct {
	// contains filtered or unexported fields
}

ResolvedReferences is a set of references which have been resolved for a particular resource. The special self field is the fully qualified ARM ID of the resource that this ResolvedReferences applies to.

func MakeResolvedReferences

func MakeResolvedReferences(references map[ResourceReference]string) ResolvedReferences

MakeResolvedReferences creates a ResolvedReferences from the fully qualified ARM ID of the resource and and ARM IDs that the resource refers to.

func (ResolvedReferences) ARMID

ARMID looks up the fully qualified ARM ID for the given reference. If it cannot be found, false is returned for the second parameter.

func (ResolvedReferences) ARMIDOrErr

func (r ResolvedReferences) ARMIDOrErr(ref ResourceReference) (string, error)

ARMIDOrErr looks up the fully qualified ARM ID for the given reference. If it cannot be found, an error is returned.

type ResolvedSecrets

type ResolvedSecrets struct {
	// contains filtered or unexported fields
}

ResolvedSecrets is a set of secret references which have been resolved for a particular resource.

func MakeResolvedSecrets

func MakeResolvedSecrets(secrets map[SecretReference]string) ResolvedSecrets

MakeResolvedSecrets creates a ResolvedSecrets

func (ResolvedSecrets) LookupSecret

func (r ResolvedSecrets) LookupSecret(ref SecretReference) (string, error)

LookupSecret looks up the secret value for the given reference. If it cannot be found, an error is returned.

func (ResolvedSecrets) LookupSecretFromPtr

func (r ResolvedSecrets) LookupSecretFromPtr(ref *SecretReference) (string, error)

LookupSecretFromPtr looks up the secret value for the given reference. If the reference is nil, an error is returned. If the secret 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 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 (ResourceReference) Copy

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) IsDirectARMReference

func (ref ResourceReference) IsDirectARMReference() bool

func (ResourceReference) IsKubernetesReference

func (ref ResourceReference) IsKubernetesReference() bool

func (ResourceReference) String

func (ref ResourceReference) String() string

func (ResourceReference) ToNamespacedRef

func (ref ResourceReference) ToNamespacedRef(namespace string) NamespacedResourceReference

ToNamespacedRef creates a NamespacedResourceReference from this reference.

func (ResourceReference) Validate

func (ref ResourceReference) Validate() 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 {

	// SecretName 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"`
}

SecretDestination describes the location to store a single secret value

func (SecretDestination) Copy

Copy makes an independent copy of the SecretDestination

func (SecretDestination) String

func (s SecretDestination) String() string

type SecretReference

type SecretReference struct {
	// SecretName 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) Copy

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) String

func (s SecretReference) String() string

func (SecretReference) ToNamespacedRef

func (s SecretReference) ToNamespacedRef(namespace string) NamespacedSecretReference

ToNamespacedRef creates a NamespacedSecretReference from this SecretReference in the given namespace

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() error
	// UpdateValidations returns validation functions that should be run on update.
	UpdateValidations() []func(old runtime.Object) error
	// DeleteValidations returns validation functions that should be run on delete.
	DeleteValidations() []func() 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL