application

package
v1.6.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 82 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigMapKeyComponents is the key in ConfigMap Data field for containing data of components
	ConfigMapKeyComponents = "components"
	// ConfigMapKeyPolicy is the key in ConfigMap Data field for containing data of policies
	ConfigMapKeyPolicy = "policies"
	// ManifestKeyWorkload is the key in Component Manifest for containing workload cr.
	ManifestKeyWorkload = "StandardWorkload"
	// ManifestKeyTraits is the key in Component Manifest for containing Trait cr.
	ManifestKeyTraits = "Traits"
	// ManifestKeyScopes is the key in Component Manifest for containing scope cr reference.
	ManifestKeyScopes = "Scopes"
	// ComponentNamespaceContextKey is the key in context that defines the override namespace of component
	ComponentNamespaceContextKey = contextKey("component-namespace")
	// ComponentContextKey is the key in context that records the component
	ComponentContextKey = contextKey("component")
	// ReplicaKeyContextKey is the key in context that records the replica key
	ReplicaKeyContextKey = contextKey("replica-key")
)

Variables

View Source
var (
	// EnableReconcileLoopReduction optimize application reconcile loop by fusing phase transition
	EnableReconcileLoopReduction = false
	// EnableResourceTrackerDeleteOnlyTrigger optimize ResourceTracker mutate event trigger by only receiving deleting events
	EnableResourceTrackerDeleteOnlyTrigger = true
)
View Source
var (
	// DisableAllComponentRevision disable component revision creation
	DisableAllComponentRevision = false
	// DisableAllApplicationRevision disable application revision creation
	DisableAllApplicationRevision = false
)
View Source
var (
	// DisableResourceApplyDoubleCheck optimize applyComponentFunc by disable post resource existing check after dispatch
	DisableResourceApplyDoubleCheck = false
)

Functions

func ComputeAppRevisionHash added in v1.0.0

func ComputeAppRevisionHash(appRevision *v1beta1.ApplicationRevision) (string, error)

ComputeAppRevisionHash computes a single hash value for an appRevision object Spec of Application/WorkloadDefinitions/ComponentDefinitions/TraitDefinitions/ScopeDefinitions will be taken into compute

func ComputeComponentRevisionHash added in v1.1.0

func ComputeComponentRevisionHash(comp *types.ComponentManifest) (string, error)

ComputeComponentRevisionHash to compute component hash

func DeepEqualRevision added in v1.0.0

func DeepEqualRevision(old, new *v1beta1.ApplicationRevision) bool

DeepEqualRevision will compare the spec of Application and Definition to see if the Application is the same revision Spec of AC and Component will not be compared as they are generated by the application and definitions Note the Spec compare can only work when the RawExtension are decoded well in the RawExtension.Object instead of in RawExtension.Raw(bytes)

func GetAppRevisions added in v1.3.0

func GetAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)

GetAppRevisions get application revisions by label

func GetSortedAppRevisions added in v1.3.0

func GetSortedAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)

GetSortedAppRevisions get application revisions by revision number

func Setup

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

Setup adds a controller that reconciles AppRollout.

func SprintComponentManifest added in v1.1.0

func SprintComponentManifest(cm *types.ComponentManifest) string

SprintComponentManifest formats and returns the resulting string.

Types

type AppHandler added in v1.1.0

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

AppHandler handles application reconcile

func NewAppHandler added in v1.2.0

func NewAppHandler(ctx context.Context, r *Reconciler, app *v1beta1.Application, parser *appfile.Parser) (*AppHandler, error)

NewAppHandler create new app handler

func (*AppHandler) ApplyPolicies added in v1.3.0

func (h *AppHandler) ApplyPolicies(ctx context.Context, af *appfile.Appfile) error

ApplyPolicies will render policies into manifests from appfile and dispatch them

func (*AppHandler) Delete added in v1.2.0

func (h *AppHandler) Delete(ctx context.Context, cluster string, owner string, manifest *unstructured.Unstructured) error

Delete delete manifests from k8s.

func (*AppHandler) Dispatch added in v1.1.0

func (h *AppHandler) Dispatch(ctx context.Context, cluster string, owner string, manifests ...*unstructured.Unstructured) error

Dispatch apply manifests into k8s.

func (*AppHandler) FinalizeAndApplyAppRevision added in v1.1.0

func (h *AppHandler) FinalizeAndApplyAppRevision(ctx context.Context) error

FinalizeAndApplyAppRevision finalise AppRevision object and apply it

func (*AppHandler) GenerateApplicationSteps added in v1.1.1

GenerateApplicationSteps generate application steps. nolint:gocyclo

func (*AppHandler) HandleComponentsRevision added in v1.1.0

func (h *AppHandler) HandleComponentsRevision(ctx context.Context, compManifests []*types.ComponentManifest) error

HandleComponentsRevision manages Component revisions 1. if update component create a new component Revision 2. check all componentTrait rely on componentRevName, if yes fill it

func (*AppHandler) PrepareCurrentAppRevision added in v1.1.0

func (h *AppHandler) PrepareCurrentAppRevision(ctx context.Context, af *appfile.Appfile) error

PrepareCurrentAppRevision will generate a pure revision without metadata and rendered result the generated revision will be compare with the last revision to see if there's any difference.

func (*AppHandler) ProduceArtifacts added in v1.1.1

func (h *AppHandler) ProduceArtifacts(ctx context.Context, comps []*types.ComponentManifest, policies []*unstructured.Unstructured) error

ProduceArtifacts will produce Application artifacts that will be saved in configMap.

func (*AppHandler) UpdateAppLatestRevisionStatus added in v1.1.0

func (h *AppHandler) UpdateAppLatestRevisionStatus(ctx context.Context) error

UpdateAppLatestRevisionStatus only call to update app's latest revision status after applying manifests successfully otherwise it will override previous revision which is used during applying to do GC jobs

func (*AppHandler) UpdateApplicationRevisionStatus added in v1.3.0

func (h *AppHandler) UpdateApplicationRevisionStatus(ctx context.Context, appRev *v1beta1.ApplicationRevision, succeed bool, wfStatus *common.WorkflowStatus)

UpdateApplicationRevisionStatus update application revision status

type DispatchOptions added in v1.6.0

type DispatchOptions struct {
	Workload          *unstructured.Unstructured
	Traits            []*unstructured.Unstructured
	OverrideNamespace string
	Stage             StageType
}

DispatchOptions is the options for dispatch

type Reconciler

type Reconciler struct {
	client.Client

	Scheme   *runtime.Scheme
	Recorder event.Recorder
	// contains filtered or unexported fields
}

Reconciler reconciles an Application object

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile process app event nolint:gocyclo

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager install to manager

type SortDispatchOptions added in v1.6.0

type SortDispatchOptions []DispatchOptions

SortDispatchOptions describe the sorting for options

func (SortDispatchOptions) Len added in v1.6.0

func (s SortDispatchOptions) Len() int

func (SortDispatchOptions) Less added in v1.6.0

func (s SortDispatchOptions) Less(i, j int) bool

func (SortDispatchOptions) Swap added in v1.6.0

func (s SortDispatchOptions) Swap(i, j int)

type StageType added in v1.6.0

type StageType int

StageType is a valid value for TraitDefinitionSpec.Stage

const (
	// PreDispatch means that pre dispatch for manifests
	PreDispatch StageType = iota
	// DefaultDispatch means that default dispatch for manifests
	DefaultDispatch
	// PostDispatch means that post dispatch for manifests
	PostDispatch
)

func ParseStageType added in v1.6.0

func ParseStageType(s string) (StageType, error)

ParseStageType parse the StageType from a string

type TraitFilter added in v1.6.0

type TraitFilter func(trait appfile.Trait) bool

TraitFilter is used to filter trait object.

func ByTraitType added in v1.6.0

func ByTraitType(readyTraits, checkTraits []*unstructured.Unstructured) TraitFilter

ByTraitType returns a filter that does not match the given type and belongs to readyTraits.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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