Documentation ¶
Index ¶
- Constants
- Variables
- type AccessPermissions
- type ApplyResponse
- type ApplyResult
- type CompletionRunner
- type DefinitionManager
- type DeleteResult
- type Dependency
- type DependencyDefinitions
- type GenericController
- type ReconcileParameters
- type ReconcileState
- type ResourceDefinition
- type ResourceManager
- type ResourceSpec
- type Status
- func (s *Status) IsCompleting() bool
- func (s *Status) IsCreating() bool
- func (s *Status) IsFailed() bool
- func (s *Status) IsPending() bool
- func (s *Status) IsRecreating() bool
- func (s *Status) IsSucceeded() bool
- func (s *Status) IsTerminating() bool
- func (s *Status) IsUpdating() bool
- func (s *Status) IsVerifying() bool
- type StatusAccessor
- type StatusUpdater
- type SucceededAccessor
- type VerifyResponse
- type VerifyResult
Constants ¶
const (
AccessPermissionAnnotation = "/access-permissions"
)
const LastAppliedAnnotation = "/last-applied-spec"
Variables ¶
var ( ApplyAwaitingVerification = ApplyResponse{Result: ApplyResultAwaitingVerification} ApplySucceeded = ApplyResponse{Result: ApplyResultSucceeded} ApplyError = ApplyResponse{Result: ApplyResultError} )
var ( VerifyError = VerifyResponse{Result: VerifyResultError} VerifyMissing = VerifyResponse{Result: VerifyResultMissing} VerifyRecreateRequired = VerifyResponse{Result: VerifyResultRecreateRequired} VerifyUpdateRequired = VerifyResponse{Result: VerifyResultUpdateRequired} VerifyInProgress = VerifyResponse{Result: VerifyResultInProgress} VerifyDeleting = VerifyResponse{Result: VerifyResultDeleting} VerifyReady = VerifyResponse{Result: VerifyResultReady} )
var NoDependencies = DependencyDefinitions{ Dependencies: []*Dependency{}, Owner: nil, }
A shortcut for objects with no dependencies
Functions ¶
This section is empty.
Types ¶
type AccessPermissions ¶
type AccessPermissions string
type ApplyResponse ¶
type ApplyResponse struct { Result ApplyResult Status interface{} }
The Result of a create or update operation, along with Status information, if present
func ApplyAwaitingVerificationWithStatus ¶
func ApplyAwaitingVerificationWithStatus(status interface{}) ApplyResponse
func ApplySucceededWithStatus ¶
func ApplySucceededWithStatus(status interface{}) ApplyResponse
type ApplyResult ¶
type ApplyResult string
The Result of a create or update operation
const ( ApplyResultAwaitingVerification ApplyResult = "AwaitingVerification" ApplyResultSucceeded ApplyResult = "Succeeded" ApplyResultError ApplyResult = "Error" )
type CompletionRunner ¶
A handler that is invoked after the resource has been successfully created and it has been verified to be ready for consumption (ReconcileState=Success) This is typically used for example to create secrets with authentication information
type DefinitionManager ¶
type DefinitionManager interface { // returns a ResourceDefinition GetDefinition(ctx context.Context, namespacedName types.NamespacedName) *ResourceDefinition // returns the dependencies for a resource GetDependencies(ctx context.Context, thisInstance runtime.Object) (*DependencyDefinitions, error) }
DefinitionManager is used to retrieve the required custom resource definitions and convert them into a state that can be consumed and updated (where applicable) generically
type DeleteResult ¶
type DeleteResult string
The Result of a delete operation
const ( DeleteAlreadyDeleted DeleteResult = "AlreadyDeleted" DeleteSucceeded DeleteResult = "Succeeded" DeleteAwaitingVerification DeleteResult = "AwaitingVerification" DeleteError DeleteResult = "Error" )
type Dependency ¶
type Dependency struct { // This can be an empty resource definition object of the required Kind InitialInstance runtime.Object NamespacedName types.NamespacedName // A function to return whether the object has been successfully applied. The current object will only // continue once this returns true for all dependencies SucceededAccessor SucceededAccessor }
The information required to pull the resource definition of a dependency from kubernetes and determine whether it has been successfully applied or not
type DependencyDefinitions ¶
type DependencyDefinitions struct { Owner *Dependency Dependencies []*Dependency }
Details of the owner and the dependencies of the resource
type GenericController ¶
type GenericController struct { Parameters ReconcileParameters ResourceKind string KubeClient client.Client Log logr.Logger Recorder record.EventRecorder Scheme *runtime.Scheme ResourceManager ResourceManager DefinitionManager DefinitionManager FinalizerName string AnnotationBaseName string CompletionRunner func(*GenericController) CompletionRunner }
GenericController is a generic implementation of a Kubebuilder controller
func CreateGenericController ¶
func CreateGenericController( parameters ReconcileParameters, resourceKind string, kubeClient client.Client, logger logr.Logger, recorder record.EventRecorder, scheme *runtime.Scheme, resourceManager ResourceManager, defMgr DefinitionManager, finalizerName string, annotationBaseName string, completionRunner func(*GenericController) CompletionRunner) (*GenericController, error)
type ReconcileParameters ¶
type ReconcileState ¶
type ReconcileState string
const ( Pending ReconcileState = "Pending" Creating ReconcileState = "Creating" Updating ReconcileState = "Updating" Verifying ReconcileState = "Verifying" Completing ReconcileState = "Completing" Succeeded ReconcileState = "Succeeded" Recreating ReconcileState = "Recreating" Failed ReconcileState = "Failed" Terminating ReconcileState = "Terminating" )
type ResourceDefinition ¶
type ResourceDefinition struct { // This can be an empty resource definition object of the required Kind InitialInstance runtime.Object // A function to get the Status of the kubernetes object StatusAccessor StatusAccessor // A function to update the Status of a kubernetes object instance StatusUpdater StatusUpdater }
Details of the current resource being reconciled
type ResourceManager ¶
type ResourceManager interface { // Creates an external resource, though it doesn't verify the readiness for consumption Create(context.Context, ResourceSpec) (ApplyResponse, error) // Updates an external resource Update(context.Context, ResourceSpec) (ApplyResponse, error) // Verifies the state of the external resource Verify(context.Context, ResourceSpec) (VerifyResponse, error) // Deletes external resource Delete(context.Context, ResourceSpec) (DeleteResult, error) }
ResourceManager is a common abstraction for the controller to interact with external resources The ResourceManager cannot modify the runtime.Object kubernetes object it only needs to query or mutate the external resource, return the Result of the operation
type ResourceSpec ¶
type Status ¶
type Status struct { State ReconcileState Message string StatusPayload interface{} }
func (*Status) IsCompleting ¶
func (*Status) IsCreating ¶
func (*Status) IsRecreating ¶
func (*Status) IsSucceeded ¶
func (*Status) IsTerminating ¶
func (*Status) IsUpdating ¶
func (*Status) IsVerifying ¶
type StatusAccessor ¶
fetches the Status of the instance of runtime.Object
type StatusUpdater ¶
updates the Status of the instance of runtime.Object with Status
type SucceededAccessor ¶
fetches a boolean flag to indicate whether the resource is in a succeeded (i.e. ready) state
func AsSuccessAccessor ¶
func AsSuccessAccessor(s StatusAccessor) SucceededAccessor
unfortunately if doesn't seem possible to make this an extension method with a receiver unfortunately if doesn't seem possible to make this an extension method with a receiver
type VerifyResponse ¶
type VerifyResponse struct { Result VerifyResult Status interface{} }
func VerifyReadyWithStatus ¶
func VerifyReadyWithStatus(status interface{}) VerifyResponse
type VerifyResult ¶
type VerifyResult string
The Result of a verify operation
const ( VerifyResultMissing VerifyResult = "Missing" VerifyResultRecreateRequired VerifyResult = "RecreateRequired" VerifyResultUpdateRequired VerifyResult = "UpdateRequired" VerifyResultInProgress VerifyResult = "InProgress" VerifyResultDeleting VerifyResult = "Deleting" VerifyResultReady VerifyResult = "Ready" VerifyResultError VerifyResult = "Error" )