appfile

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 34 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TerraformBaseLocation is the base directory to store all Terraform JSON files
	TerraformBaseLocation = ".vela/terraform/"
	// TerraformLog is the logfile name for terraform
	TerraformLog = "terraform.log"
)
View Source
const (
	// AppfileBuiltinConfig defines the built-in config variable
	AppfileBuiltinConfig = "config"

	// OAMApplicationLabel is application's metadata label tagged on AC and Component
	OAMApplicationLabel = "application.oam.dev"
)

Variables

This section is empty.

Functions

func ApplyTerraform added in v0.3.1

func ApplyTerraform(app *v1alpha2.Application, k8sClient client.Client, ioStream util.IOStreams, namespace string, dm discoverymapper.DiscoveryMapper) ([]v1alpha2.ApplicationComponent, error)

ApplyTerraform deploys addon resources

func BuildRun added in v0.3.1

func BuildRun(ctx context.Context, app *api.Application, client client.Client, env *types.EnvMeta, io cmdutil.IOStreams) error

BuildRun will build application and deploy from Appfile

func CreateOrUpdateApplication added in v0.3.1

func CreateOrUpdateApplication(ctx context.Context, client client.Client, app *v1alpha2.Application) error

CreateOrUpdateApplication will create if not exist and update if exists.

func CreateOrUpdateObjects added in v0.3.1

func CreateOrUpdateObjects(ctx context.Context, client client.Client, objects []oam.Object) error

CreateOrUpdateObjects will create all scopes

func Delete added in v0.3.1

func Delete(envName, appName string) error

Delete will delete an app along with it's appfile.

func GetAppConfig added in v0.3.1

GetAppConfig will get AppConfig from K8s cluster.

func GetApplication added in v0.3.1

func GetApplication(ctx context.Context, c client.Client, app *api.Application, env *types.EnvMeta) (*v1alpha2.Application, error)

GetApplication will get Application from K8s cluster.

func GetComponents added in v0.3.1

func GetComponents(app *api.Application) []string

GetComponents will get oam components from Appfile.

func GetServiceConfig added in v0.3.1

func GetServiceConfig(app *api.Application, componentName string) (string, map[string]interface{})

GetServiceConfig will get service type and it's configuration

func GetTraits added in v0.3.1

func GetTraits(app *api.Application, componentName string) (map[string]map[string]interface{}, error)

GetTraits will list all traits and it's configurations attached to the specified component.

func GetTraitsByType added in v0.3.1

func GetTraitsByType(app *api.Application, componentName, traitType string) (map[string]interface{}, error)

GetTraitsByType will get trait configuration with specified component and trait type, we assume one type of trait can only attach to a component once.

func GetWorkload added in v0.3.1

func GetWorkload(app *api.Application, componentName string) (string, map[string]interface{})

GetWorkload will get workload type and it's configuration

func IsNotFound added in v0.3.1

func IsNotFound(appName string, err error) bool

IsNotFound is application not found error

func List added in v0.3.1

func List(envName string) ([]*api.Application, error)

List will list all apps

func LoadApplication added in v0.3.1

func LoadApplication(envName, appName string) (*api.Application, error)

LoadApplication will load application with env and name from default vela home dir.

func MatchAppByComp added in v0.3.1

func MatchAppByComp(envName, compName string) (*api.Application, error)

MatchAppByComp will get application with componentName without AppName.

func NewApplication added in v0.3.1

func NewApplication(f *api.AppFile, tm template.Manager) *api.Application

NewApplication will create application object

func NewEmptyApplication added in v0.3.1

func NewEmptyApplication() (*api.Application, error)

NewEmptyApplication new empty application, only set tm

func PrepareProcessContext added in v0.3.1

func PrepareProcessContext(k8sClient client.Client, wl *Workload, applicationName string, namespace string) (process.Context, error)

PrepareProcessContext prepares a DSL process Context

func RemoveComponent added in v0.3.1

func RemoveComponent(app *api.Application, componentName string) error

RemoveComponent will remove component from Appfile

func RemoveTrait added in v0.3.1

func RemoveTrait(app *api.Application, componentName, traitType string) error

RemoveTrait will remove a trait from Appfile

func Run added in v0.3.1

func Run(ctx context.Context, client client.Client, app *v1alpha2.Application, assistantObjects []oam.Object) error

Run will deploy OAM objects and other assistant K8s Objects including ConfigMap, OAM Scope Custom Resource.

func Save added in v0.3.1

func Save(app *api.Application, envName string) error

Save will save appfile into default dir.

func SetTrait added in v0.3.1

func SetTrait(app *api.Application, componentName, traitType string, traitData map[string]interface{}) error

SetTrait will set user trait for Appfile

func SetWorkload added in v0.3.1

func SetWorkload(app *api.Application, componentName, workloadType string, workloadData map[string]interface{}) error

SetWorkload will set user workload for Appfile

func Validate added in v0.3.1

func Validate(app *api.Application) error

Validate will validate whether an Appfile is valid.

Types

type Appfile added in v0.3.1

type Appfile struct {
	Name      string
	Workloads []*Workload
}

Appfile describes application

func (*Appfile) TemplateValidate added in v0.3.1

func (af *Appfile) TemplateValidate() error

TemplateValidate validate Template format

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, dm discoverymapper.DiscoveryMapper) *Parser

NewApplicationParser create appfile parser

func (*Parser) GenerateAppFile added in v0.3.1

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

GenerateAppFile converts an application to an Appfile

func (*Parser) GenerateApplicationConfiguration added in v0.3.1

func (p *Parser) GenerateApplicationConfiguration(app *Appfile, ns string) (*v1alpha2.ApplicationConfiguration,
	[]*v1alpha2.Component, error)

GenerateApplicationConfiguration converts an appFile to applicationConfig & Components

type Scope added in v0.3.1

type Scope struct {
	Name string
	GVK  schema.GroupVersionKind
}

Scope defines the scope of workload

type Storage added in v0.3.1

type Storage struct {
	api.Driver
}

Storage is common storage client,use it to get app and others resource

func GetStorage added in v0.3.1

func GetStorage() *Storage

GetStorage will create storage driver from the system environment of "STORAGE_DRIVER"

func (*Storage) Delete added in v0.3.1

func (s *Storage) Delete(envName, appName string) error

Delete application storage common implement

func (*Storage) Get added in v0.3.1

func (s *Storage) Get(envName, appName string) (*api.Application, error)

Get application storage common implement

func (*Storage) List added in v0.3.1

func (s *Storage) List(envName string) ([]*api.Application, error)

List applications storage common implement

func (*Storage) Save added in v0.3.1

func (s *Storage) Save(app *api.Application, envName string) error

Save application storage common implement

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
}

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(ctx process.Context, client client.Client, namespace string) (bool, error)

EvalHealth eval trait health check

func (*Trait) EvalStatus added in v0.3.3

func (trait *Trait) EvalStatus(ctx process.Context, cli client.Client, ns string) (string, error)

EvalStatus eval trait status

type Workload added in v0.3.1

type Workload struct {
	Name               string
	Type               string
	CapabilityCategory types.CapabilityCategory
	Params             map[string]interface{}
	Traits             []*Trait
	Scopes             []Scope

	Template           string
	HealthCheckPolicy  string
	CustomStatusFormat string
}

Workload is component

func (*Workload) EvalContext added in v0.3.1

func (wl *Workload) EvalContext(ctx process.Context) error

EvalContext eval workload template and set result to context

func (*Workload) EvalHealth added in v0.3.1

func (wl *Workload) EvalHealth(ctx process.Context, client client.Client, namespace string) (bool, error)

EvalHealth eval workload health check

func (*Workload) EvalStatus added in v0.3.3

func (wl *Workload) EvalStatus(ctx process.Context, cli client.Client, ns string) (string, error)

EvalStatus eval workload status

func (*Workload) GetUserConfigName added in v0.3.1

func (wl *Workload) GetUserConfigName() string

GetUserConfigName get user config from AppFile, it will contain config file in it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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