appfile

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 42 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// WriteConnectionSecretToRefKey is used to create a secret for cloud resource connection
	WriteConnectionSecretToRefKey = "writeConnectionSecretToRef"
	// RegionKey is the region of a Cloud Provider
	// It's used to override the region of a Cloud Provider
	// Refer to https://github.com/oam-dev/terraform-controller/blob/master/api/v1beta2/configuration_types.go#L66 for details
	RegionKey = "customRegion"
	// ProviderRefKey is the reference of a Provider
	ProviderRefKey = "providerRef"
	// ForceDeleteKey is used to force delete Configuration
	ForceDeleteKey = "forceDelete"
	// GitCredentialsSecretReferenceKey is the reference to a secret with git ssh private key & known hosts
	GitCredentialsSecretReferenceKey = "gitCredentialsSecretReference"
)
View Source
const (
	// UsageTag is usage comment annotation
	UsageTag = "+usage="
	// ShortTag is the short alias annotation
	ShortTag = "+short"
)

Variables

This section is empty.

Functions

func ConvertTemplateJSON2Object added in v1.0.3

func ConvertTemplateJSON2Object(capabilityName string, in *runtime.RawExtension, schematic *common.Schematic) (types.Capability, error)

ConvertTemplateJSON2Object convert spec.extension or spec.schematic to object

func GenerateContextDataFromAppFile added in v1.2.5

func GenerateContextDataFromAppFile(appfile *Appfile, wlName string) velaprocess.ContextData

GenerateContextDataFromAppFile generates process context data from app file

func IsNotFoundInAppFile added in v1.8.0

func IsNotFoundInAppFile(err error) bool

IsNotFoundInAppFile check if the target error is `not found in appfile`

func IsNotFoundInAppRevision added in v1.8.0

func IsNotFoundInAppRevision(err error) bool

IsNotFoundInAppRevision check if the error is `not found in app revision`

func NewBasicContext added in v1.0.5

func NewBasicContext(contextData velaprocess.ContextData, params map[string]interface{}) process.Context

NewBasicContext prepares a basic DSL process Context

func PrepareProcessContext added in v0.3.1

func PrepareProcessContext(comp *Component, ctxData velaprocess.ContextData) (process.Context, error)

PrepareProcessContext prepares a DSL process Context

Types

type Appfile added in v0.3.1

type Appfile struct {
	Name             string
	Namespace        string
	ParsedComponents []*Component
	ParsedPolicies   []*Component

	AppRevision     *v1beta1.ApplicationRevision
	AppRevisionName string
	AppRevisionHash string

	AppLabels      map[string]string
	AppAnnotations map[string]string

	RelatedTraitDefinitions        map[string]*v1beta1.TraitDefinition
	RelatedComponentDefinitions    map[string]*v1beta1.ComponentDefinition
	RelatedWorkflowStepDefinitions map[string]*v1beta1.WorkflowStepDefinition

	Policies      []v1beta1.AppPolicy
	Components    []common.ApplicationComponent
	Artifacts     []*types.ComponentManifest
	WorkflowSteps []workflowv1alpha1.WorkflowStep
	WorkflowMode  *workflowv1alpha1.WorkflowExecuteMode

	ExternalPolicies map[string]*v1alpha1.Policy
	ExternalWorkflow *workflowv1alpha1.Workflow
	ReferredObjects  []*unstructured.Unstructured

	Debug bool
	// contains filtered or unexported fields
}

Appfile describes application

func (*Appfile) GenerateComponentManifest added in v1.1.0

func (af *Appfile) GenerateComponentManifest(comp *Component, mutate func(*velaprocess.ContextData)) (*types.ComponentManifest, error)

GenerateComponentManifest generate only one ComponentManifest

func (*Appfile) GenerateComponentManifests added in v1.1.0

func (af *Appfile) GenerateComponentManifests() ([]*types.ComponentManifest, error)

GenerateComponentManifests converts an appFile to a slice of ComponentManifest

func (*Appfile) GeneratePolicyManifests added in v1.3.0

func (af *Appfile) GeneratePolicyManifests(_ context.Context) ([]*unstructured.Unstructured, error)

GeneratePolicyManifests generates policy manifests from an appFile internal policies like apply-once, topology, will not render manifests

func (*Appfile) LoadDynamicComponent added in v1.4.0

func (af *Appfile) LoadDynamicComponent(ctx context.Context, cli client.Client, comp *common.ApplicationComponent) (*common.ApplicationComponent, error)

LoadDynamicComponent for ref-objects typed components, this function will load referred objects from stored revisions

func (*Appfile) PolicyClient added in v1.3.0

func (af *Appfile) PolicyClient(cli client.Client) client.Client

PolicyClient cache retrieved policy if ApplicationRevision not exists in appfile else use the policy in ApplicationRevision

func (*Appfile) SetOAMContract added in v1.1.1

func (af *Appfile) SetOAMContract(comp *types.ComponentManifest) error

SetOAMContract will set OAM labels and annotations for resources as contract

func (*Appfile) WorkflowClient added in v1.3.0

func (af *Appfile) WorkflowClient(cli client.Client) client.Client

WorkflowClient cache retrieved workflow if ApplicationRevision not exists in appfile else use the workflow in ApplicationRevision

type Component added in v1.9.6

type Component struct {
	Name               string
	Type               string
	CapabilityCategory types.CapabilityCategory
	Params             map[string]interface{}
	Traits             []*Trait
	FullTemplate       *Template
	Ctx                process.Context
	Patch              *value.Value

	SkipApplyWorkload bool
	// contains filtered or unexported fields
}

Component is an internal struct for component in application User-defined policies are parsed as a Component without any Traits because their purpose is dispatching some resources Internal policies are NOT parsed as a Component

func (*Component) EvalContext added in v1.9.6

func (comp *Component) EvalContext(ctx process.Context) error

EvalContext eval workload template and set the result to context

func (*Component) EvalHealth added in v1.9.6

func (comp *Component) EvalHealth(templateContext map[string]interface{}) (bool, error)

EvalHealth eval workload health check

func (*Component) EvalStatus added in v1.9.6

func (comp *Component) EvalStatus(templateContext map[string]interface{}) (string, error)

EvalStatus eval workload status

func (*Component) GetTemplateContext added in v1.9.6

func (comp *Component) GetTemplateContext(ctx process.Context, client client.Client, accessor util.NamespaceAccessor) (map[string]interface{}, error)

GetTemplateContext get workload template context, it will be used to eval status and health

type Parser added in v0.3.1

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

Parser is an application parser

func NewApplicationParser added in v0.3.1

func NewApplicationParser(cli client.Client, pd *packages.PackageDiscover) *Parser

NewApplicationParser create appfile parser

func NewDryRunApplicationParser added in v1.0.3

func NewDryRunApplicationParser(cli client.Client, pd *packages.PackageDiscover, defs []*unstructured.Unstructured) *Parser

NewDryRunApplicationParser create an appfile parser for DryRun

func (*Parser) GenerateAppFile added in v0.3.1

func (p *Parser) GenerateAppFile(ctx context.Context, app *v1beta1.Application) (*Appfile, error)

GenerateAppFile generate appfile for the application to run, if the application is controlled by PublishVersion, the application revision will be used to create the appfile

func (*Parser) GenerateAppFileFromApp added in v1.3.0

func (p *Parser) GenerateAppFileFromApp(ctx context.Context, app *v1beta1.Application) (*Appfile, error)

GenerateAppFileFromApp converts an application to an Appfile

func (*Parser) GenerateAppFileFromRevision added in v1.1.1

func (p *Parser) GenerateAppFileFromRevision(appRev *v1beta1.ApplicationRevision) (*Appfile, error)

GenerateAppFileFromRevision converts an application revision to an Appfile

func (*Parser) ParseComponentFromRevision added in v1.9.6

func (p *Parser) ParseComponentFromRevision(comp common.ApplicationComponent, appRev *v1beta1.ApplicationRevision) (*Component, error)

ParseComponentFromRevision resolve an ApplicationComponent and generate a Component containing ALL information required by an Appfile from app revision.

func (*Parser) ParseComponentFromRevisionAndClient added in v1.9.6

func (p *Parser) ParseComponentFromRevisionAndClient(ctx context.Context, c common.ApplicationComponent, appRev *v1beta1.ApplicationRevision) (*Component, error)

ParseComponentFromRevisionAndClient resolve an ApplicationComponent and generate a Component containing ALL information required by an Appfile from app revision, and will fall back to load external definitions if not found

func (*Parser) ValidateCUESchematicAppfile added in v1.0.3

func (p *Parser) ValidateCUESchematicAppfile(a *Appfile) error

ValidateCUESchematicAppfile validates CUE schematic workloads in an Appfile

func (*Parser) ValidateComponentNames added in v1.1.0

func (p *Parser) ValidateComponentNames(app *v1beta1.Application) (int, error)

ValidateComponentNames validate all component names whether repeat in app

type Template added in v1.0.3

type Template struct {
	TemplateStr        string
	Health             string
	CustomStatus       string
	CapabilityCategory types.CapabilityCategory
	Reference          common.WorkloadTypeDescriptor
	Terraform          *common.Terraform

	ComponentDefinition *v1beta1.ComponentDefinition
	WorkloadDefinition  *v1beta1.WorkloadDefinition
	TraitDefinition     *v1beta1.TraitDefinition

	PolicyDefinition       *v1beta1.PolicyDefinition
	WorkflowStepDefinition *v1beta1.WorkflowStepDefinition
}

Template is a helper struct for processing capability including ComponentDefinition, TraitDefinition. It mainly collects schematic and status data of a capability definition.

func LoadTemplate added in v1.0.3

func LoadTemplate(ctx context.Context, cli client.Client, capName string, capType types.CapType) (*Template, error)

LoadTemplate gets the capability definition from cluster and resolve it. It returns a helper struct, Template, which will be used for further processing.

func LoadTemplateFromRevision added in v1.1.1

func LoadTemplateFromRevision(capName string, capType types.CapType, apprev *v1beta1.ApplicationRevision, mapper meta.RESTMapper) (*Template, error)

LoadTemplateFromRevision will load Definition template from app revision

type TemplateLoaderFn added in v1.0.3

type TemplateLoaderFn func(context.Context, client.Client, string, types.CapType) (*Template, error)

TemplateLoaderFn load template of a capability definition

func DryRunTemplateLoader added in v1.0.3

func DryRunTemplateLoader(defs []*unstructured.Unstructured) TemplateLoaderFn

DryRunTemplateLoader return a function that do the same work as LoadTemplate, but load template from provided ones before loading from cluster through LoadTemplate

func (TemplateLoaderFn) LoadTemplate added in v1.0.3

func (fn TemplateLoaderFn) LoadTemplate(ctx context.Context, c client.Client, capName string, capType types.CapType) (*Template, error)

LoadTemplate load template of a capability definition

type Trait added in v0.3.1

type Trait struct {
	// The Name is name of TraitDefinition, actually it's a type of the trait instance
	Name               string
	CapabilityCategory types.CapabilityCategory
	Params             map[string]interface{}

	Template           string
	HealthCheckPolicy  string
	CustomStatusFormat string

	// RequiredSecrets stores secret names which the trait needs from cloud resource component and its context
	RequiredSecrets []process.RequiredSecrets

	FullTemplate *Template
	// contains filtered or unexported fields
}

Trait is ComponentTrait

func (*Trait) EvalContext added in v0.3.1

func (trait *Trait) EvalContext(ctx process.Context) error

EvalContext eval trait template and set result to context

func (*Trait) EvalHealth added in v0.3.1

func (trait *Trait) EvalHealth(templateContext map[string]interface{}) (bool, error)

EvalHealth eval trait health check

func (*Trait) EvalStatus added in v0.3.3

func (trait *Trait) EvalStatus(templateContext map[string]interface{}) (string, error)

EvalStatus eval trait status

func (*Trait) GetTemplateContext added in v1.7.0

func (trait *Trait) GetTemplateContext(ctx process.Context, client client.Client, accessor util.NamespaceAccessor) (map[string]interface{}, error)

GetTemplateContext get trait template context, it will be used to eval status and health

Directories

Path Synopsis
helm
flux2apis
Package apis contains typed structs from fluxcd/helm-controller and fluxcd/source-controller.
Package apis contains typed structs from fluxcd/helm-controller and fluxcd/source-controller.

Jump to

Keyboard shortcuts

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