Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeAppRevisionHash(appRevision *v1beta1.ApplicationRevision) (string, error)
- func ComputeComponentRevisionHash(comp *types.ComponentManifest) (string, error)
- func DeepEqualRevision(old, new *v1beta1.ApplicationRevision) bool
- func GetAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)
- func GetSortedAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)
- func Setup(mgr ctrl.Manager, args core.Args) error
- func SprintComponentManifest(cm *types.ComponentManifest) string
- type AppHandler
- func (h *AppHandler) ApplyPolicies(ctx context.Context, af *appfile.Appfile) error
- func (h *AppHandler) CheckWorkflowRestart(ctx monitorContext.Context, app *v1beta1.Application)
- func (h *AppHandler) Delete(ctx context.Context, cluster string, owner string, ...) error
- func (h *AppHandler) Dispatch(ctx context.Context, cluster string, owner string, ...) error
- func (h *AppHandler) FinalizeAndApplyAppRevision(ctx context.Context) error
- func (h *AppHandler) GenerateApplicationSteps(ctx monitorContext.Context, app *v1beta1.Application, ...) (*wfTypes.WorkflowInstance, []wfTypes.TaskRunner, error)
- func (h *AppHandler) PrepareCurrentAppRevision(ctx context.Context, af *appfile.Appfile) error
- func (h *AppHandler) ProduceArtifacts(ctx context.Context, comps []*types.ComponentManifest, ...) error
- func (h *AppHandler) UpdateAppLatestRevisionStatus(ctx context.Context) error
- func (h *AppHandler) UpdateApplicationRevisionStatus(ctx context.Context, appRev *v1beta1.ApplicationRevision, ...)
- type DispatchOptions
- type Reconciler
- type SortDispatchOptions
- type StageType
- type TraitFilter
Constants ¶
const ( // ComponentNamespaceContextKey is the key in context that defines the override namespace of component ComponentNamespaceContextKey contextKey = iota // ComponentContextKey is the key in context that records the component ComponentContextKey // ReplicaKeyContextKey is the key in context that records the replica key ReplicaKeyContextKey // OriginalAppKey is the key in the context that records the in coming original app OriginalAppKey )
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" )
Variables ¶
var ( // DisableAllComponentRevision disable component revision creation DisableAllComponentRevision = false // DisableAllApplicationRevision disable application revision creation DisableAllApplicationRevision = false )
var ( // DisableResourceApplyDoubleCheck optimize applyComponentFunc by disable post resource existing check after dispatch DisableResourceApplyDoubleCheck = false )
var ( // EnableResourceTrackerDeleteOnlyTrigger optimize ResourceTracker mutate event trigger by only receiving deleting events EnableResourceTrackerDeleteOnlyTrigger = true )
Functions ¶
func ComputeAppRevisionHash ¶
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 ¶
func ComputeComponentRevisionHash(comp *types.ComponentManifest) (string, error)
ComputeComponentRevisionHash to compute component hash
func DeepEqualRevision ¶
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 ¶
func GetAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)
GetAppRevisions get application revisions by label
func GetSortedAppRevisions ¶
func GetSortedAppRevisions(ctx context.Context, cli client.Client, appName string, appNs string) ([]v1beta1.ApplicationRevision, error)
GetSortedAppRevisions get application revisions by revision number
func SprintComponentManifest ¶
func SprintComponentManifest(cm *types.ComponentManifest) string
SprintComponentManifest formats and returns the resulting string.
Types ¶
type AppHandler ¶
type AppHandler struct {
// contains filtered or unexported fields
}
AppHandler handles application reconcile
func NewAppHandler ¶
func NewAppHandler(ctx context.Context, r *Reconciler, app *v1beta1.Application, parser *appfile.Parser) (*AppHandler, error)
NewAppHandler create new app handler
func (*AppHandler) ApplyPolicies ¶
ApplyPolicies will render policies into manifests from appfile and dispatch them
func (*AppHandler) CheckWorkflowRestart ¶
func (h *AppHandler) CheckWorkflowRestart(ctx monitorContext.Context, app *v1beta1.Application)
CheckWorkflowRestart check if application workflow need restart and return the desired rev to be set in status 1. If workflow status is empty, it means no previous running record, the workflow will restart (cold start) 2. If workflow status is not empty, and publishVersion is set, the desired rev will be the publishVersion 3. If workflow status is not empty, the desired rev will be the ApplicationRevision name. For backward compatibility, the legacy style <rev>:<hash> will be recognized and reduced into <rev>
func (*AppHandler) Delete ¶
func (h *AppHandler) Delete(ctx context.Context, cluster string, owner string, manifest *unstructured.Unstructured) error
Delete delete manifests from k8s.
func (*AppHandler) Dispatch ¶
func (h *AppHandler) Dispatch(ctx context.Context, cluster string, owner string, manifests ...*unstructured.Unstructured) error
Dispatch apply manifests into k8s.
func (*AppHandler) FinalizeAndApplyAppRevision ¶
func (h *AppHandler) FinalizeAndApplyAppRevision(ctx context.Context) error
FinalizeAndApplyAppRevision finalise AppRevision object and apply it
func (*AppHandler) GenerateApplicationSteps ¶
func (h *AppHandler) GenerateApplicationSteps(ctx monitorContext.Context, app *v1beta1.Application, appParser *appfile.Parser, af *appfile.Appfile) (*wfTypes.WorkflowInstance, []wfTypes.TaskRunner, error)
GenerateApplicationSteps generate application steps. nolint:gocyclo
func (*AppHandler) PrepareCurrentAppRevision ¶
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 ¶
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 ¶
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 ¶
func (h *AppHandler) UpdateApplicationRevisionStatus(ctx context.Context, appRev *v1beta1.ApplicationRevision, wfStatus *common.WorkflowStatus)
UpdateApplicationRevisionStatus update application revision status
type DispatchOptions ¶
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) SetupWithManager ¶
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager install to manager
type SortDispatchOptions ¶
type SortDispatchOptions []DispatchOptions
SortDispatchOptions describe the sorting for options
func (SortDispatchOptions) Len ¶
func (s SortDispatchOptions) Len() int
func (SortDispatchOptions) Less ¶
func (s SortDispatchOptions) Less(i, j int) bool
func (SortDispatchOptions) Swap ¶
func (s SortDispatchOptions) Swap(i, j int)
type StageType ¶
type StageType int
StageType is a valid value for TraitDefinitionSpec.Stage
func ParseStageType ¶
ParseStageType parse the StageType from a string
type TraitFilter ¶
TraitFilter is used to filter trait object.
func ByTraitType ¶
func ByTraitType(readyTraits, checkTraits []*unstructured.Unstructured) TraitFilter
ByTraitType returns a filter that does not match the given type and belongs to readyTraits.