assemble

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCheckManageWorkloadTrait added in v1.1.8

func HandleCheckManageWorkloadTrait(appRev v1beta1.ApplicationRevision, comps []*types.ComponentManifest)

HandleCheckManageWorkloadTrait will checkout every trait whether a manage-workload trait, if yes set label and annotation in trait

func PrepareBeforeApply added in v1.1.1

PrepareBeforeApply will prepare for some necessary info before apply

Types

type AppManifests

type AppManifests struct {
	AppRevision     *v1beta1.ApplicationRevision
	WorkloadOptions []WorkloadOption
	// contains filtered or unexported fields
}

AppManifests contains configuration to assemble resources recorded in the ApplicationRevision. 'Assemble' means expand Application(Component and Trait) into K8s resource and get them ready to go, to be emitted into K8s

func NewAppManifests

func NewAppManifests(appRevision *v1beta1.ApplicationRevision, parser *appfile.Parser) *AppManifests

NewAppManifests create a AppManifests

func (*AppManifests) AssembledManifests

func (am *AppManifests) AssembledManifests() ([]*unstructured.Unstructured, error)

AssembledManifests do assemble and merge all assembled resources(except referenced scopes) into one array The result guarantee the order of resources as defined in application originally. If it contains more than one component, the resources are well-orderred and also grouped. For example, if app = comp1 (wl1 + trait1 + trait2) + comp2 (wl2 + trait3 +trait4), the result is [wl1, trait1, trait2, wl2, trait3, trait4]

func (*AppManifests) GroupAssembledManifests

GroupAssembledManifests do assemble and return all resources grouped by components

func (*AppManifests) ReferencedScopes

func (am *AppManifests) ReferencedScopes() (map[corev1.ObjectReference][]corev1.ObjectReference, error)

ReferencedScopes do assemble and return workload reference and referenced scopes

func (*AppManifests) WithComponentManifests added in v1.1.1

func (am *AppManifests) WithComponentManifests(componentManifests []*types.ComponentManifest) *AppManifests

WithComponentManifests set component manifests with the given one

func (*AppManifests) WithWorkloadOption

func (am *AppManifests) WithWorkloadOption(wo WorkloadOption) *AppManifests

WithWorkloadOption add a WorkloadOption to plug in custom logic applied to each workload

type WorkloadOption

type WorkloadOption interface {
	ApplyToWorkload(*unstructured.Unstructured, *v1beta1.ComponentDefinition, []*unstructured.Unstructured) error
}

WorkloadOption will be applied to each workloads AFTER it has been assembled by generic rules shown below: 1) use component name as workload name 2) use application namespace as workload namespace if unspecified 3) set application as workload's owner 4) pass all application's labels and annotations to workload's Component and ComponentDefinition are enough for caller to manipulate workloads. Caller can use below labels of workload to get more information: - oam.LabelAppName - oam.LabelAppRevision - oam.LabelAppRevisionHash - oam.LabelAppComponent - oam.LabelAppComponentRevision

func DiscoveryHelmBasedWorkload

func DiscoveryHelmBasedWorkload(ctx context.Context, c client.Reader) WorkloadOption

DiscoveryHelmBasedWorkload only works for Helm-based component. It computes a qualifiedFullName for the workload and try to get it from K8s cluster. If not found, block down-streaming process until Helm creates the workload successfully.

func PrepareWorkloadForRollout

func PrepareWorkloadForRollout(rolloutComp string) WorkloadOption

PrepareWorkloadForRollout prepare the workload before it is emit to the k8s. The current approach is to mark it as disabled so that it's spec won't take effect immediately. The rollout controller can take over the resources and enable it on its own since app controller here won't override their change

type WorkloadOptionFn

WorkloadOptionFn implement interface WorkloadOption

func (WorkloadOptionFn) ApplyToWorkload

func (fn WorkloadOptionFn) ApplyToWorkload(wl *unstructured.Unstructured,
	compDefinition *v1beta1.ComponentDefinition, packagedWorkloadResources []*unstructured.Unstructured) error

ApplyToWorkload will apply the manipulation defined in the function to assembled workload

Jump to

Keyboard shortcuts

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