Documentation ¶
Index ¶
- Constants
- Variables
- func IsRevisionWorkload(status v1alpha2.WorkloadStatus, w []Workload) bool
- func SetAppWorkloadInstanceName(componentName string, w *unstructured.Unstructured, revision int)
- func Setup(mgr ctrl.Manager, args core.Args, l logging.Logger) error
- type ComponentHandler
- func (c *ComponentHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface)
- func (c *ComponentHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface)
- func (c *ComponentHandler) Generic(_ event.GenericEvent, _ workqueue.RateLimitingInterface)
- func (c *ComponentHandler) IsRevisionDiff(mt klog.KMetadata, curComp *v1alpha2.Component) (bool, int64)
- func (c *ComponentHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface)
- func (c *ComponentHandler) UpdateStatus(ctx context.Context, comp *v1alpha2.Component, opts ...client.UpdateOption) error
- type ComponentRenderFn
- type ComponentRenderer
- type ControllerHooks
- type ControllerHooksFn
- type GarbageCollector
- type GarbageCollectorFn
- type GenerationUnchanged
- type OAMApplicationReconciler
- func (r *OAMApplicationReconciler) ACReconcile(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, log logging.Logger) (result reconcile.Result)
- func (r *OAMApplicationReconciler) Reconcile(req reconcile.Request) (reconcile.Result, error)
- func (r *OAMApplicationReconciler) UpdateStatus(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, ...) error
- type Parameter
- type ParameterResolveFn
- type ParameterResolver
- type ReconcilerOption
- func WithApplicator(a WorkloadApplicator) ReconcilerOption
- func WithApplyOnceOnlyMode(mode core.ApplyOnceOnlyMode) ReconcilerOption
- func WithGarbageCollector(gc GarbageCollector) ReconcilerOption
- func WithPosthook(name string, hook ControllerHooks) ReconcilerOption
- func WithPrehook(name string, hook ControllerHooks) ReconcilerOption
- func WithRecorder(er event.Recorder) ReconcilerOption
- func WithRenderer(r ComponentRenderer) ReconcilerOption
- type ResourceRenderFn
- type ResourceRenderer
- type RevisionHookRequest
- type Trait
- type Workload
- type WorkloadApplicator
- type WorkloadApplyFns
Constants ¶
const ContentTypeJSON = "application/json"
ContentTypeJSON : json
const ControllerRevisionComponentLabel = "controller.oam.dev/component"
ControllerRevisionComponentLabel indicate which component the revision belong to This label is to filter revision by client api
Variables ¶
var ( // ErrInvaildOperationType describes the error that Operator of DataOperation is not in defined DataOperator ErrInvaildOperationType = errors.New("invaild type in operation") // ErrInvaildOperationValueAndValueFrom describes the error that both value and valueFrom in DataOperation are empty ErrInvaildOperationValueAndValueFrom = errors.New("invaild value and valueFrom in operation: both are empty") )
var ( // ErrDataOutputNotExist is an error indicating the DataOutput specified doesn't not exist ErrDataOutputNotExist = errors.New("DataOutput does not exist") )
Functions ¶
func IsRevisionWorkload ¶
func IsRevisionWorkload(status v1alpha2.WorkloadStatus, w []Workload) bool
IsRevisionWorkload check is a workload is an old revision Workload which shouldn't be garbage collected.
func SetAppWorkloadInstanceName ¶ added in v1.0.0
func SetAppWorkloadInstanceName(componentName string, w *unstructured.Unstructured, revision int)
SetAppWorkloadInstanceName sets the name of the workload instance depends on the component revision and the workload kind
Types ¶
type ComponentHandler ¶
type ComponentHandler struct { Client client.Client Logger logging.Logger RevisionLimit int CustomRevisionHookURL string }
ComponentHandler will watch component change and generate Revision automatically.
func (*ComponentHandler) Create ¶
func (c *ComponentHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface)
Create implements EventHandler
func (*ComponentHandler) Delete ¶
func (c *ComponentHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface)
Delete implements EventHandler
func (*ComponentHandler) Generic ¶
func (c *ComponentHandler) Generic(_ event.GenericEvent, _ workqueue.RateLimitingInterface)
Generic implements EventHandler
func (*ComponentHandler) IsRevisionDiff ¶
func (c *ComponentHandler) IsRevisionDiff(mt klog.KMetadata, curComp *v1alpha2.Component) (bool, int64)
IsRevisionDiff check whether there's any different between two component revision
func (*ComponentHandler) Update ¶
func (c *ComponentHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface)
Update implements EventHandler
func (*ComponentHandler) UpdateStatus ¶ added in v0.3.3
func (c *ComponentHandler) UpdateStatus(ctx context.Context, comp *v1alpha2.Component, opts ...client.UpdateOption) error
UpdateStatus updates v1alpha2.Component's Status with retry.RetryOnConflict
type ComponentRenderFn ¶
type ComponentRenderFn func(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) ([]Workload, *v1alpha2.DependencyStatus, error)
A ComponentRenderFn renders an ApplicationConfiguration's Components into workloads and traits.
func (ComponentRenderFn) Render ¶
func (fn ComponentRenderFn) Render(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) ([]Workload, *v1alpha2.DependencyStatus, error)
Render an ApplicationConfiguration's Components into workloads and traits.
type ComponentRenderer ¶
type ComponentRenderer interface {
Render(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) ([]Workload, *v1alpha2.DependencyStatus, error)
}
A ComponentRenderer renders an ApplicationConfiguration's Components into workloads and traits.
type ControllerHooks ¶
type ControllerHooks interface {
Exec(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, logger logging.Logger) (reconcile.Result, error)
}
A ControllerHooks provide customized reconcile logic for an ApplicationConfiguration
type ControllerHooksFn ¶
type ControllerHooksFn func(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, logger logging.Logger) (reconcile.Result, error)
ControllerHooksFn reconciles an ApplicationConfiguration
type GarbageCollector ¶
type GarbageCollector interface {
Eligible(namespace string, ws []v1alpha2.WorkloadStatus, w []Workload) []unstructured.Unstructured
}
A GarbageCollector returns resource eligible for garbage collection. A resource is considered eligible if a reference exists in the supplied slice of workload statuses, but not in the supplied slice of workloads.
type GarbageCollectorFn ¶
type GarbageCollectorFn func(namespace string, ws []v1alpha2.WorkloadStatus, w []Workload) []unstructured.Unstructured
A GarbageCollectorFn returns resource eligible for garbage collection.
func (GarbageCollectorFn) Eligible ¶
func (fn GarbageCollectorFn) Eligible(namespace string, ws []v1alpha2.WorkloadStatus, w []Workload) []unstructured.Unstructured
Eligible resources.
type GenerationUnchanged ¶
type GenerationUnchanged struct{}
GenerationUnchanged indicates the resource being applied has no generation changed comparing to the existing one.
func (*GenerationUnchanged) Error ¶
func (e *GenerationUnchanged) Error() string
type OAMApplicationReconciler ¶
type OAMApplicationReconciler struct {
// contains filtered or unexported fields
}
An OAMApplicationReconciler reconciles OAM ApplicationConfigurations by rendering and instantiating their Components and Traits.
func NewReconciler ¶
func NewReconciler(m ctrl.Manager, dm discoverymapper.DiscoveryMapper, log logging.Logger, o ...ReconcilerOption) *OAMApplicationReconciler
NewReconciler returns an OAMApplicationReconciler that reconciles ApplicationConfigurations by rendering and instantiating their Components and Traits.
func (*OAMApplicationReconciler) ACReconcile ¶ added in v1.0.0
func (r *OAMApplicationReconciler) ACReconcile(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, log logging.Logger) (result reconcile.Result)
ACReconcile contains all the reconcile logic of an AC, it can be used by other controller
func (*OAMApplicationReconciler) Reconcile ¶
Reconcile an OAM ApplicationConfigurations by rendering and instantiating its Components and Traits.
func (*OAMApplicationReconciler) UpdateStatus ¶ added in v0.3.3
func (r *OAMApplicationReconciler) UpdateStatus(ctx context.Context, ac *v1alpha2.ApplicationConfiguration, opts ...client.UpdateOption) error
UpdateStatus updates v1alpha2.ApplicationConfiguration's Status with retry.RetryOnConflict
type Parameter ¶
type Parameter struct { // Name of this parameter. Name string // Value of this parameter. Value intstr.IntOrString // FieldPaths that should be set to this parameter's value. FieldPaths []string }
A Parameter may be used to set the supplied paths to the supplied value.
type ParameterResolveFn ¶
type ParameterResolveFn func([]v1alpha2.ComponentParameter, []v1alpha2.ComponentParameterValue) ([]Parameter, error)
A ParameterResolveFn resolves the parameters accepted by a component and the parameter values supplied to a component into configured parameters.
func (ParameterResolveFn) Resolve ¶
func (fn ParameterResolveFn) Resolve(cp []v1alpha2.ComponentParameter, cpv []v1alpha2.ComponentParameterValue) ([]Parameter, error)
Resolve the supplied parameters.
type ParameterResolver ¶
type ParameterResolver interface {
Resolve([]v1alpha2.ComponentParameter, []v1alpha2.ComponentParameterValue) ([]Parameter, error)
}
A ParameterResolver resolves the parameters accepted by a component and the parameter values supplied to a component into configured parameters.
type ReconcilerOption ¶
type ReconcilerOption func(*OAMApplicationReconciler)
A ReconcilerOption configures a Reconciler.
func WithApplicator ¶
func WithApplicator(a WorkloadApplicator) ReconcilerOption
WithApplicator specifies how the Reconciler should apply workloads and traits.
func WithApplyOnceOnlyMode ¶ added in v0.3.3
func WithApplyOnceOnlyMode(mode core.ApplyOnceOnlyMode) ReconcilerOption
WithApplyOnceOnlyMode indicates whether workloads and traits should be affected if no spec change is made in the ApplicationConfiguration.
func WithGarbageCollector ¶
func WithGarbageCollector(gc GarbageCollector) ReconcilerOption
WithGarbageCollector specifies how the Reconciler should garbage collect workloads and traits when an ApplicationConfiguration is edited to remove them.
func WithPosthook ¶
func WithPosthook(name string, hook ControllerHooks) ReconcilerOption
WithPosthook register a post-hook to the Reconciler
func WithPrehook ¶
func WithPrehook(name string, hook ControllerHooks) ReconcilerOption
WithPrehook register a pre-hook to the Reconciler
func WithRecorder ¶
func WithRecorder(er event.Recorder) ReconcilerOption
WithRecorder specifies how the Reconciler should record events.
func WithRenderer ¶
func WithRenderer(r ComponentRenderer) ReconcilerOption
WithRenderer specifies how the Reconciler should render workloads and traits.
type ResourceRenderFn ¶
type ResourceRenderFn func(data []byte, p ...Parameter) (*unstructured.Unstructured, error)
A ResourceRenderFn renders a Kubernetes-compliant YAML resource into an Unstructured object, optionally setting the supplied parameters.
func (ResourceRenderFn) Render ¶
func (fn ResourceRenderFn) Render(data []byte, p ...Parameter) (*unstructured.Unstructured, error)
Render the supplied Kubernetes YAML resource.
type ResourceRenderer ¶
type ResourceRenderer interface {
Render(data []byte, p ...Parameter) (*unstructured.Unstructured, error)
}
A ResourceRenderer renders a Kubernetes-compliant YAML resource into an Unstructured object, optionally setting the supplied parameters.
type RevisionHookRequest ¶ added in v0.3.0
type RevisionHookRequest struct { RelatedApps []reconcile.Request `json:"relatedApps"` Comp *v1alpha2.Component `json:"component"` }
RevisionHookRequest is request body for custom component revision hook
type Trait ¶
type Trait struct { Object unstructured.Unstructured // HasDep indicates whether this resource has dependencies and unready to be applied. HasDep bool // Definition indicates the trait's definition Definition v1alpha2.TraitDefinition // Record the DataOutputs of this trait, key is name of DataOutput. DataOutputs map[string]v1alpha2.DataOutput // Record the DataInputs of this trait. DataInputs []v1alpha2.DataInput }
A Trait produced by an OAM ApplicationConfiguration.
type Workload ¶
type Workload struct { // ComponentName that produced this workload. ComponentName string // ComponentRevisionName of current component ComponentRevisionName string // A Workload object. Workload *unstructured.Unstructured // SkipApply indicates that the workload should not be applied SkipApply bool // HasDep indicates whether this resource has dependencies and unready to be applied. HasDep bool // Traits associated with this workload. Traits []*Trait // RevisionEnabled means multiple workloads of same component will possibly be alive. RevisionEnabled bool // Scopes associated with this workload. Scopes []unstructured.Unstructured // Record the DataOutputs of this workload, key is name of DataOutput. DataOutputs map[string]v1alpha2.DataOutput // Record the DataInputs of this workload. DataInputs []v1alpha2.DataInput }
A Workload produced by an OAM ApplicationConfiguration.
func (Workload) Status ¶
func (w Workload) Status() v1alpha2.WorkloadStatus
Status produces the status of this workload and its traits, suitable for use in the status of an ApplicationConfiguration.
type WorkloadApplicator ¶
type WorkloadApplicator interface { // Apply a workload and its traits. Apply(ctx context.Context, status []v1alpha2.WorkloadStatus, w []Workload, ao ...apply.ApplyOption) error // Finalize implements pre-delete hooks on workloads Finalize(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) error }
A WorkloadApplicator creates or updates or finalizes workloads and their traits.
type WorkloadApplyFns ¶
type WorkloadApplyFns struct { ApplyFn func(ctx context.Context, status []v1alpha2.WorkloadStatus, w []Workload, ao ...apply.ApplyOption) error FinalizeFn func(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) error }
A WorkloadApplyFns creates or updates or finalizes workloads and their traits.
func (WorkloadApplyFns) Apply ¶
func (fn WorkloadApplyFns) Apply(ctx context.Context, status []v1alpha2.WorkloadStatus, w []Workload, ao ...apply.ApplyOption) error
Apply a workload and its traits. It employes the same mechanism as `kubectl apply`, that is, for each resource being applied, computing a three-way diff merge in client side based on its current state, modified stated and last-applied-state which is tracked through an specific annotaion. If the resource doesn't exist before, Apply will create it.
func (WorkloadApplyFns) Finalize ¶
func (fn WorkloadApplyFns) Finalize(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) error
Finalize workloads and its traits/scopes.