applicationconfiguration

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const ControllerRevisionComponentLabel = "controller.oam.dev/component"

ControllerRevisionComponentLabel indicate which component the revision belong to This label is to filter revision by client api

Variables

View Source
var (
	// ErrDataOutputNotExist is an error indicating the DataOutput specified doesn't not exist
	ErrDataOutputNotExist = errors.New("DataOutput does not exist")
)

Functions

func ConstructRevisionName

func ConstructRevisionName(componentName string, revision int64) string

ConstructRevisionName will generate revisionName from componentName will be <componentName>-v<RevisionNumber>, for example: comp-v1

func ExtractComponentName

func ExtractComponentName(revisionName string) string

ExtractComponentName will extract componentName from revisionName

func IsRevisionWorkload

func IsRevisionWorkload(status v1alpha2.WorkloadStatus) bool

IsRevisionWorkload check is a workload is an old revision Workload which shouldn't be garbage collected. TODO(wonderflow): Do we have a better way to recognize it's a revisionWorkload which can't be garbage collected by AppConfig?

func SetWorkloadInstanceName

func SetWorkloadInstanceName(traitDefs []v1alpha2.TraitDefinition, w *unstructured.Unstructured, c *v1alpha2.Component,
	existingWorkload *unstructured.Unstructured) error

SetWorkloadInstanceName will set metadata.name for workload CR according to createRevision flag in traitDefinition

func Setup

func Setup(mgr ctrl.Manager, args controller.Args) error

Setup adds a controller that reconciles ApplicationConfigurations.

Types

type ComponentHandler

type ComponentHandler struct {
	Client        client.Client
	RevisionLimit int
}

ComponentHandler will watch component change and generate Revision automatically.

func (*ComponentHandler) Create

Create implements EventHandler

func (*ComponentHandler) Delete

Delete implements EventHandler

func (*ComponentHandler) Generic

Generic implements EventHandler

func (*ComponentHandler) IsRevisionDiff

func (c *ComponentHandler) IsRevisionDiff(mt metav1.Object, curComp *v1alpha2.Component) (bool, int64)

IsRevisionDiff check whether there's any different between two component revision

func (*ComponentHandler) Update

Update implements EventHandler

type ComponentRenderFn

A ComponentRenderFn renders an ApplicationConfiguration's Components into workloads and traits.

func (ComponentRenderFn) Render

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) (reconcile.Result, error)
}

A ControllerHooks provide customized reconcile logic for an ApplicationConfiguration

type ControllerHooksFn

type ControllerHooksFn func(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) (reconcile.Result, error)

ControllerHooksFn reconciles an ApplicationConfiguration

func (ControllerHooksFn) Exec

Exec the customized reconcile logic on the 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

NewReconciler returns an OAMApplicationReconciler that reconciles ApplicationConfigurations by rendering and instantiating their Components and Traits.

func (*OAMApplicationReconciler) Reconcile

func (r *OAMApplicationReconciler) Reconcile(req reconcile.Request) (result reconcile.Result, returnErr error)

Reconcile an OAM ApplicationConfigurations by rendering and instantiating its Components and Traits. NOTE(negz): We don't validate anything against their definitions at the controller level. We assume this will be done by validating admission webhooks.

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

A ParameterResolveFn resolves the parameters accepted by a component and the parameter values supplied to a component into configured parameters.

func (ParameterResolveFn) Resolve

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 WithApplyOnceOnly

func WithApplyOnceOnly(applyOnceOnly bool) ReconcilerOption

WithApplyOnceOnly indicates whether workloads and traits should be affected if no spec change is made in the ApplicationConfiguration.

func WithRecorder

func WithRecorder(er event.Recorder) ReconcilerOption

WithRecorder specifies how the Reconciler should record events.

func WithSetSync added in v0.9.1

func WithSetSync(syncTime time.Duration) ReconcilerOption

WithSetSync set Reconciler exec interval

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

A Trait produced by an OAM ApplicationConfiguration.

type VolumeClaim added in v0.9.1

type VolumeClaim struct {
}

type VolumeClaimRenderFn added in v0.9.1

type VolumeClaimRenderFn func(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) error

func (VolumeClaimRenderFn) Render added in v0.9.1

type VolumeClaimRenderer added in v0.9.1

type VolumeClaimRenderer interface {
	Render(ctx context.Context, ac *v1alpha2.ApplicationConfiguration) error
}

type Workload

type Workload struct {
	// ComponentName that produced this workload.
	ComponentName string

	// ComponentRevisionName of current component
	ComponentRevisionName string

	// A Workload object.
	Workload *unstructured.Unstructured

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

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.

Jump to

Keyboard shortcuts

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