assemble

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCheckManageWorkloadTrait

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

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

func (am *AppManifests) GroupAssembledManifests() (
	map[string]*unstructured.Unstructured,
	map[string][]*unstructured.Unstructured,
	error)

GroupAssembledManifests do assemble and return all resources grouped by components

func (*AppManifests) WithComponentManifests

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.

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