Documentation
¶
Index ¶
- type ARMResourceModifier
- type ARMResourceModifierFunc
- type ClaimFunc
- type Claimer
- type DeleteFunc
- type Deleter
- type ErrorClassifier
- type ErrorClassifierFunc
- type ImportResult
- type Importer
- type ImporterFunc
- type KubernetesSecretExportFunc
- type PostReconcileCheckFunc
- type PostReconcileCheckResult
- type PostReconciliationChecker
- type PreReconcileCheckFunc
- type PreReconcileCheckResult
- type PreReconcileOwnerCheckFunc
- type PreReconciliationChecker
- type PreReconciliationOwnerChecker
- type SuccessFunc
- type SuccessfulCreationHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ARMResourceModifier ¶
type ARMResourceModifier interface {
// ModifyARMResource takes a genruntime.ARMResource and returns an updated genruntime.ARMResource. The updated resource
// is then serialized and sent to ARM in the body of a PUT request.
// ctx is the current operation context.
// armClient allows making additional ARM API calls if needed to determine modifications.
// armObj is the ARM resource representation about to be sent.
// obj is the Kubernetes resource being reconciled.
// kubeClient allows access to the Kubernetes cluster.
// resolver helps resolve resource references.
// log is a logger for the current operation.
ModifyARMResource(
ctx context.Context,
armClient *genericarmclient.GenericClient,
armObj genruntime.ARMResource,
obj genruntime.ARMMetaObject,
kubeClient kubeclient.Client,
resolver *resolver.Resolver,
log logr.Logger,
) (genruntime.ARMResource, error)
}
ARMResourceModifier provides a hook allowing resources to modify the payload that will be sent to ARM just before it is sent. This extension is invoked during PUT and PATCH operations to ARM, after standard conversion but before the HTTP request. Use cases include: handling soft-delete scenarios (e.g., Key Vault), including child resources in parent payloads (e.g., VNET subnets), and conditional field population based on Azure state.
type ARMResourceModifierFunc ¶
type ARMResourceModifierFunc = func(ctx context.Context, obj genruntime.ARMMetaObject, armObj genruntime.ARMResource) (genruntime.ARMResource, error)
func CreateARMResourceModifier ¶
func CreateARMResourceModifier( host genruntime.ResourceExtension, armClient *genericarmclient.GenericClient, kubeClient kubeclient.Client, resolver *resolver.Resolver, log logr.Logger, ) ARMResourceModifierFunc
CreateARMResourceModifier returns a function that performs per-resource modifications. If the ARMResourceModifier extension has not been implemented for the resource in question, the default behavior is to return the provided genruntime.ARMResource unmodified.
type ClaimFunc ¶
type ClaimFunc = func(ctx context.Context, log logr.Logger, obj genruntime.ARMOwnedMetaObject) error
ClaimFunc is the signature of a function that can be used to create a default Claimer
func CreateClaimer ¶
func CreateClaimer( host genruntime.ResourceExtension, next ClaimFunc, ) ClaimFunc
CreateClaimer creates a ClaimFunc. If the resource in question has not implemented the Claimer interface the provided default ClaimFunc is run by default.
type Claimer ¶
type Claimer interface {
// Claim claims the resource by establishing its Azure Resource Manager ID.
// ctx is the current operation context.
// log is a logger for the current operation.
// obj is the Kubernetes resource being claimed.
// next is the default claim implementation - call this to use standard claiming logic.
Claim(ctx context.Context, log logr.Logger, obj genruntime.ARMOwnedMetaObject, next ClaimFunc) error
}
Claimer can be implemented to customize how the reconciler claims a resource. Claiming establishes the link between a Kubernetes resource and its Azure resource by setting the ARM ID. Most resources use the default claiming logic. Implement this extension when: - The resource's ARM ID doesn't follow standard construction patterns - Custom validation is required before claiming - Additional operations must be performed during the claim process
type DeleteFunc ¶
type DeleteFunc = func( ctx context.Context, log logr.Logger, resolver *resolver.Resolver, armClient *genericarmclient.GenericClient, obj genruntime.ARMMetaObject) (ctrl.Result, error)
DeleteFunc is the signature of a function that can be used to create a default Deleter
func CreateDeleter ¶
func CreateDeleter( host genruntime.ResourceExtension, next DeleteFunc, ) DeleteFunc
CreateDeleter creates a DeleteFunc. If the resource in question has not implemented the Deleter interface the provided default DeleteFunc is run by default.
type Deleter ¶
type Deleter interface {
// Delete deletes the resource from Azure, with the ability to perform custom logic before, during, or after deletion.
// ctx is the current operation context.
// log is a logger for the current operation.
// resolver helps resolve resource references.
// armClient allows making ARM API calls.
// obj is the Kubernetes resource being deleted.
// next is the default deletion implementation - call this to perform standard ARM DELETE.
// Returns a reconciliation result (e.g., requeue timing) and an error if deletion fails.
Delete(
ctx context.Context,
log logr.Logger,
resolver *resolver.Resolver,
armClient *genericarmclient.GenericClient,
obj genruntime.ARMMetaObject,
next DeleteFunc) (ctrl.Result, error)
}
Deleter can be implemented to customize how the reconciler deletes resources from Azure. This extension is invoked when a resource has a deletion timestamp, before the standard ARM DELETE operation. Implement this extension when: - Pre-deletion operations are required (e.g., canceling subscriptions, disabling features) - Multiple API calls are needed for complete deletion - Custom error handling is needed during deletion - Resources should be preserved in Azure under certain conditions
type ErrorClassifier ¶
type ErrorClassifier interface {
// ClassifyError evaluates the provided error, returning details including whether it is fatal or can be retried.
// cloudError is the error returned from ARM.
// apiVersion is the ARM API version used for the request.
// log is a logger that can be used for telemetry.
// next is the default classification implementation to call.
// Returns CloudErrorDetails with classification and an error if classification itself fails.
ClassifyError(
cloudError *genericarmclient.CloudError,
apiVersion string,
log logr.Logger,
next ErrorClassifierFunc) (core.CloudErrorDetails, error)
}
ErrorClassifier can be implemented to customize how the reconciler reacts to specific errors returned by Azure. This extension is invoked whenever an ARM API call returns an error, allowing resources to classify errors as retryable or fatal, and to provide better error messages to users. Implement this extension when: - Resource-specific error codes need special handling - Certain errors should be retried that would normally be considered fatal (or vice versa) - Error messages need resource-specific clarification - Error behavior varies by API version
type ErrorClassifierFunc ¶
type ErrorClassifierFunc func(cloudError *genericarmclient.CloudError) (core.CloudErrorDetails, error)
ErrorClassifierFunc is the signature of a function that can be used to create a DefaultErrorClassifier
func CreateErrorClassifier ¶
func CreateErrorClassifier( host genruntime.ResourceExtension, classifier ErrorClassifierFunc, apiVersion string, log logr.Logger, ) ErrorClassifierFunc
type ImportResult ¶
type ImportResult struct {
// contains filtered or unexported fields
}
ImportResult is the result of doing an import.
func ImportSkipped ¶
func ImportSkipped(because string) ImportResult
ImportSkipped creates a new ImportResult for a resource that was not imported.
func ImportSucceeded ¶
func ImportSucceeded() ImportResult
ImportSucceeded creates a new ImportResult with a resource that was imported successfully.
func (ImportResult) Skipped ¶
func (r ImportResult) Skipped() (string, bool)
Skipped returns a reason and true if the import was skipped, empty string and false otherwise.
type Importer ¶
type Importer interface {
// Import allows interception of the import process to skip or modify resources being imported.
// ctx is the current asynchronous context
// rsrc is the resource being imported.
// owner is an optional owner for the resource.
// next is a function to call to do the actual import.
// Returns an ImportResult indicating success or skip with a reason, and an error if import fails.
Import(
ctx context.Context,
rsrc genruntime.ImportableResource,
owner *genruntime.ResourceReference,
next ImporterFunc,
) (ImportResult, error)
}
Importer is an optional interface that can be implemented by resource extensions to customize the import process. This extension is invoked during 'asoctl import' operations, after retrieving the resource from Azure but before writing it to Kubernetes. It allows resources to skip import for system-managed resources, read-only configurations, or resources that only have default values. Implement this extension when: - System-managed or auto-created resources should be excluded from import - Default or empty configurations don't need management - Resources need validation before allowing import
type ImporterFunc ¶
type ImporterFunc func( ctx context.Context, resource genruntime.ImportableResource, owner *genruntime.ResourceReference, ) (ImportResult, error)
ImporterFunc is the signature of the function that does the actual import.
type KubernetesSecretExportFunc ¶ added in v2.11.0
type KubernetesSecretExportFunc = func(obj genruntime.MetaObject, additionalSecrets set.Set[string]) (*genruntime.KubernetesSecretExportResult, error)
func CreateKubernetesSecretExporter ¶ added in v2.11.0
func CreateKubernetesSecretExporter( ctx context.Context, host genruntime.ResourceExtension, armClient *genericarmclient.GenericClient, log logr.Logger, ) KubernetesSecretExportFunc
CreateKubernetesSecretExporter creates a function to create Kubernetes secrets. If the resource in question has not been configured with the genruntime.KubernetesSecretExporter interface, the returned function is a no-op.
type PostReconcileCheckFunc ¶
type PostReconcileCheckFunc func( ctx context.Context, obj genruntime.MetaObject, owner genruntime.MetaObject, resourceResolver *resolver.Resolver, armClient *genericarmclient.GenericClient, log logr.Logger, ) (PostReconcileCheckResult, error)
func CreatePostReconciliationChecker ¶
func CreatePostReconciliationChecker( host genruntime.ResourceExtension, ) (PostReconcileCheckFunc, bool)
CreatePostReconciliationChecker creates a checker that can be used to check if we want to customise the condition on the resource after reconciliation. If the resource in question has not implemented the PostReconciliationChecker interface, the provided default checker is returned directly. We also return a bool indicating whether the resource extension implements the PostReconciliationChecker interface. host is a resource extension that may implement the PostReconciliationChecker interface.
type PostReconcileCheckResult ¶
type PostReconcileCheckResult struct {
// contains filtered or unexported fields
}
func PostReconcileCheckResultFailure ¶
func PostReconcileCheckResultFailure(reason string) PostReconcileCheckResult
PostReconcileCheckResultFailure indicates post reconciliation check of a resource is currently failed by returning a PostReconcileCheckResult with action `Failure`. reason is an explanatory reason to show to the user via a warning condition on the resource.
func PostReconcileCheckResultSuccess ¶
func PostReconcileCheckResultSuccess() PostReconcileCheckResult
PostReconcileCheckResultSuccess indicates that a resource is ready after reconciliation by returning a PostReconcileCheckResult with action `Success`.
func (PostReconcileCheckResult) CreateConditionError ¶
func (r PostReconcileCheckResult) CreateConditionError() error
CreateConditionError returns an error that can be used to set a condition on the resource.
func (PostReconcileCheckResult) Message ¶
func (r PostReconcileCheckResult) Message() string
func (PostReconcileCheckResult) ReconciliationFailed ¶
func (r PostReconcileCheckResult) ReconciliationFailed() bool
func (PostReconcileCheckResult) ReconciliationSucceeded ¶
func (r PostReconcileCheckResult) ReconciliationSucceeded() bool
type PostReconciliationChecker ¶
type PostReconciliationChecker interface {
// PostReconcileCheck does a post-reconcile check to see if the resource is in a state to set 'Ready' condition.
// ARM resources should implement this if they need to defer the Ready condition until later.
// Returns PostReconcileCheckResultSuccess if the reconciliation is successful.
// Returns PostReconcileCheckResultFailure and a human-readable reason if the reconciliation should put a condition on resource.
// ctx is the current operation context.
// obj is the resource that was reconciled. The resource's status will be freshly updated.
// owner is the parent resource of obj. This can be nil in some cases like `ResourceGroups` and `Alias`.
// resourceResolver helps resolve resource references.
// armClient allows access to ARM for any required queries.
// log is the logger for the current operation.
// next is the default check implementation (usually returns success).
PostReconcileCheck(
ctx context.Context,
obj genruntime.MetaObject,
owner genruntime.MetaObject,
resourceResolver *resolver.Resolver,
armClient *genericarmclient.GenericClient,
log logr.Logger,
next PostReconcileCheckFunc,
) (PostReconcileCheckResult, error)
}
PostReconciliationChecker is implemented by resources that want to do extra status checks after a full ARM reconcile. This extension is invoked after Azure operations succeed but before the Ready condition is marked successful, allowing resources to defer readiness until additional conditions are met. Implement this extension when: - The Azure resource continues initializing after ARM operations complete - Manual approval or external processes must complete before the resource is ready - Complex validation is needed to determine true readiness
type PreReconcileCheckFunc ¶
type PreReconcileCheckFunc func( ctx context.Context, obj genruntime.MetaObject, resourceResolver *resolver.Resolver, armClient *genericarmclient.GenericClient, log logr.Logger, ) (PreReconcileCheckResult, error)
func CreatePreReconciliationChecker ¶
func CreatePreReconciliationChecker( host genruntime.ResourceExtension, ) (PreReconcileCheckFunc, bool)
CreatePreReconciliationChecker creates a checker that can be used to check if a resource is ready for reconciliation. If the resource in question has not implemented the PreReconciliationChecker interface, the provided default checker is returned directly. We also return a bool indicating whether the resource extension implements the PreReconciliationChecker interface. host is a resource extension that may implement the PreReconciliationChecker interface.
type PreReconcileCheckResult ¶
type PreReconcileCheckResult struct {
// contains filtered or unexported fields
}
func BlockReconcile ¶
func BlockReconcile(reason string) PreReconcileCheckResult
BlockReconcile indicates reconciliation of a resource is currently blocked by returning a PreReconcileCheckResult with action `Block`. The reconciliation will automatically be retried after a short delay. reason is an explanatory reason to show to the user via a warning condition on the resource.
func PostponeReconcile ¶
func PostponeReconcile() PreReconcileCheckResult
PostponeReconcile indicates reconciliation of a resource is not currently required by returning a PreReconcileCheckResult with action `Postpone`. Reconciliation will not be retried until the usual scheduled check.
func ProceedWithReconcile ¶
func ProceedWithReconcile() PreReconcileCheckResult
ProceedWithReconcile indicates that a resource is ready for reconciliation by returning a PreReconcileCheckResult with action `Proceed`.
func (PreReconcileCheckResult) BlockReconciliation ¶
func (r PreReconcileCheckResult) BlockReconciliation() bool
func (PreReconcileCheckResult) CreateConditionError ¶
func (r PreReconcileCheckResult) CreateConditionError() error
CreateConditionError returns an error that can be used to set a condition on the resource.
func (PreReconcileCheckResult) Message ¶
func (r PreReconcileCheckResult) Message() string
func (PreReconcileCheckResult) PostponeReconciliation ¶
func (r PreReconcileCheckResult) PostponeReconciliation() bool
type PreReconcileOwnerCheckFunc ¶ added in v2.16.0
type PreReconcileOwnerCheckFunc func( ctx context.Context, owner genruntime.MetaObject, resourceResolver *resolver.Resolver, armClient *genericarmclient.GenericClient, log logr.Logger, ) (PreReconcileCheckResult, error)
func CreatePreReconciliationOwnerChecker ¶ added in v2.16.0
func CreatePreReconciliationOwnerChecker( host genruntime.ResourceExtension, ) (PreReconcileOwnerCheckFunc, bool)
CreatePreReconciliationChecker creates a checker that can be used to check if a resource is ready for reconciliation. If the resource in question has not implemented the PreReconciliationChecker interface, the provided default checker is returned directly. We also return a bool indicating whether the resource extension implements the PreReconciliationChecker interface. host is a resource extension that may implement the PreReconciliationChecker interface.
type PreReconciliationChecker ¶
type PreReconciliationChecker interface {
// PreReconcileCheck does a pre-reconcile check to see if the resource is in a state that can be reconciled.
// ARM resources should implement this to avoid reconciliation attempts that cannot possibly succeed.
// Returns ProceedWithReconcile if the reconciliation should go ahead.
// Returns BlockReconcile and a human-readable reason if the reconciliation should be skipped.
// ctx is the current operation context.
// obj is the resource about to be reconciled. The resource's status will be freshly updated.
// resourceResolver helps resolve resource references.
// armClient allows access to ARM for any required queries.
// log is the logger for the current operation.
// next is the next (nested) implementation to call.
PreReconcileCheck(
ctx context.Context,
obj genruntime.MetaObject,
resourceResolver *resolver.Resolver,
armClient *genericarmclient.GenericClient,
log logr.Logger,
next PreReconcileCheckFunc,
) (PreReconcileCheckResult, error)
}
PreReconciliationChecker is implemented by resources that want to do extra checks before proceeding with a full ARM reconcile. This extension is invoked before sending any requests to Azure, giving resources the ability to block reconciliation until prerequisites are met. Implement this extension when: - Parent/owner resources must reach certain states before child creation - External dependencies must be satisfied before reconciling - Reconciliation would fail due to known prerequisites not being met
type PreReconciliationOwnerChecker ¶ added in v2.16.0
type PreReconciliationOwnerChecker interface {
// PreReconcileOwnerCheck does a pre-reconcile check to see if the owner of a resource is in a state that permits
// the resource to be reconciled. For a limited number of resources, the state of their owner can block all access
// to the resource, including GETs. One example is a Kusto Cluster, where you can't even GET the database if the
// cluster is powered off.
// Prefer to implement PreReconciliationChecker unless you specifically need to avoid GETs on the resource itself.
// ARM resources should implement this to avoid reconciliation attempts that cannot possibly succeed.
// Returns ProceedWithReconcile if the reconciliation should go ahead.
// Returns BlockReconcile and a human-readable reason if the reconciliation should be skipped.
// ctx is the current operation context.
// owner is the owner of the resource about to be reconciled. The owner's status will be freshly updated. May be nil
// if the resource has no owner, or if it has been referenced via ARMID directly.
// resourceResolver helps resolve resource references.
// armClient allows access to ARM for any required queries.
// log is the logger for the current operation.
// next is the next (nested) implementation to call.
PreReconcileOwnerCheck(
ctx context.Context,
owner genruntime.MetaObject,
resourceResolver *resolver.Resolver,
armClient *genericarmclient.GenericClient,
log logr.Logger,
next PreReconcileOwnerCheckFunc,
) (PreReconcileCheckResult, error)
}
PreReconciliationOwnerChecker is implemented by resources that want to check their owner's state before proceeding with a full ARM reconcile. This is a specialized variant of PreReconciliationChecker that only checks the owner, avoiding any GET operations on the resource itself. Implement this extension when: - The owner's state can block all access to the resource, including GET operations - You need to avoid attempting operations that will fail due to owner state - The resource cannot be accessed when its owner is in certain states (e.g., powered off, updating)
type SuccessFunc ¶
type SuccessFunc = func(obj genruntime.ARMMetaObject) error
SuccessFunc is the signature of a function that can be used to create a default SuccessfulCreationHandler
func CreateSuccessfulCreationHandler ¶
func CreateSuccessfulCreationHandler( host genruntime.ResourceExtension, log logr.Logger, ) SuccessFunc
CreateSuccessfulCreationHandler creates a SuccessFunc if the resource implements SuccessfulCreationHandler. If the resource did not implement SuccessfulCreationHandler a default handler that does nothing is returned.
type SuccessfulCreationHandler ¶
type SuccessfulCreationHandler interface {
// Success performs custom logic after the resource is successfully created in Azure for the first time.
// obj is the resource that was just created, with populated status including the Azure resource ID.
// Returns an error if the success handling fails, which will prevent the Ready condition from being set.
Success(obj genruntime.ARMMetaObject) error
}
SuccessfulCreationHandler can be implemented to customize the resource upon successful creation in Azure. This extension is invoked once after the initial ARM PUT operation succeeds, giving resources the opportunity to perform one-time initialization that depends on the Azure-assigned resource ID. Implement this extension when: - Resource ID needs custom computation or override after creation - Child resources need special ID references set on the parent - One-time initialization is required after the resource exists in Azure