template

package
v0.104.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StateNotFoundErr = errors.New("state not found")

Functions

func ParseOCIReference

func ParseOCIReference(ref string) [2]string

ParseOCIReference parses a oci reference string into its repository and version. e.g. host:5000/myrepo/myimage:1.0.0 -> ["host:5000/myrepo/myimage", "1.0.0"] host:5000/myrepo/myimage@sha256:123 -> ["host:5000/myrepo/myimage", "sha256:123"]

func ResolveComponents

func ResolveComponents(defaultCD *types.ComponentDescriptor, list *types.ComponentDescriptorList, ocmSchemaVersion string, args []interface{}) ([]map[string]interface{}, error)

ResolveComponents is a helper function that can be used in the specific templating implementations to ease the access to component descriptors. The method takes a default component descriptor, a list of components and a optional number of args.

The arguments are expected to be a set of key value pairs that describe the identity of the resource. e.g. []interface{}{"name", "my-component"}. Optionally the first argument can be a component descriptor provided as map[string]interface{}

func ResolveResources

func ResolveResources(defaultCD *types.ComponentDescriptor, args []interface{}) ([]types.Resource, error)

ResolveResources is a helper function that can be used in the specific templating implementations to ease the access to component descriptor defined resources. The method takes a default component descriptor and a optional number of args.

The arguments are expected to be a set of key value pairs that describe the identity of the resource. e.g. []interface{}{"name", "my-resource"}. Optionally the first argument can be a component descriptor provided as map[string]interface{}

Types

type BlueprintExecutionOptions

type BlueprintExecutionOptions struct {
	Installation      *lsv1alpha1.Installation
	Blueprint         *blueprints.Blueprint
	ComponentVersion  model.ComponentVersion
	ComponentVersions *model.ComponentVersionList
	Imports           map[string]interface{}
}

BlueprintExecutionOptions describes the base options for templating of all blueprint executions.

func NewBlueprintExecutionOptions

func NewBlueprintExecutionOptions(installation *lsv1alpha1.Installation, blueprint *blueprints.Blueprint,
	cd model.ComponentVersion, cdList *model.ComponentVersionList, imports map[string]interface{}) BlueprintExecutionOptions

NewBlueprintExecutionOptions create new basic blueprint execution options

func (*BlueprintExecutionOptions) Values

func (o *BlueprintExecutionOptions) Values() (map[string]interface{}, error)

type DeployExecutionOptions

type DeployExecutionOptions struct {
	BlueprintExecutionOptions
}

DeployExecutionOptions describes the options for templating the deploy executions.

func (*DeployExecutionOptions) Values

func (o *DeployExecutionOptions) Values() (map[string]interface{}, error)

type DeployExecutorOutput

type DeployExecutorOutput struct {
	DeployItems []DeployItemSpecification `json:"deployItems"`
}

DeployExecutorOutput describes the output of deploy executor.

type DeployItemSpecification

type DeployItemSpecification struct {
	// Name is the unique name of the execution.
	Name string `json:"name"`

	// DataType is the DeployItem type of the execution.
	Type core.DeployItemType `json:"type"`

	// Target is the target reference to the target import of the target the deploy item should deploy to.
	// +optional
	Target *TargetReference `json:"target,omitempty"`

	// Labels is the map of labels to be added to the deploy item.
	// +optional
	Labels map[string]string `json:"labels,omitempty"`

	// ProviderConfiguration contains the type specific configuration for the execution.
	Configuration *runtime.RawExtension `json:"config"`

	// DependsOn lists deploy items that need to be executed before this one
	DependsOn []string `json:"dependsOn,omitempty"`

	// Timeout specifies how long the deployer may take to apply the deploy item.
	// When the time is exceeded, the deploy item fails.
	// Value has to be parsable by time.ParseDuration (or 'none' to deactivate the timeout).
	// Defaults to ten minutes if not specified.
	// +optional
	Timeout *lsv1alpha1.Duration `json:"timeout,omitempty"`

	// UpdateOnChangeOnly specifies if redeployment is executed only if the specification of the deploy item has changed.
	// +optional
	UpdateOnChangeOnly bool `json:"updateOnChangeOnly,omitempty"`

	OnDelete *core.OnDeleteConfig
}

DeployItemSpecification defines a execution element that is translated into a deployitem template for the execution object.

type ExecutionTemplater

type ExecutionTemplater interface {
	// Type returns the type of the templater.
	Type() lsv1alpha1.TemplateType
	// TemplateImportExecutions templates an import executor and return a list of error messages.
	TemplateImportExecutions(tmplExec lsv1alpha1.TemplateExecutor,
		blueprint *blueprints.Blueprint,
		cd model.ComponentVersion,
		cdList *model.ComponentVersionList,
		values map[string]interface{}) (*ImportExecutorOutput, error)
	// TemplateSubinstallationExecutions templates a subinstallation executor and return a list of installations templates.
	TemplateSubinstallationExecutions(tmplExec lsv1alpha1.TemplateExecutor,
		blueprint *blueprints.Blueprint,
		cd model.ComponentVersion,
		cdList *model.ComponentVersionList,
		values map[string]interface{}) (*SubinstallationExecutorOutput, error)
	// TemplateDeployExecutions templates a deploy executor and return a list of deployitem templates.
	TemplateDeployExecutions(tmplExec lsv1alpha1.TemplateExecutor,
		blueprint *blueprints.Blueprint,
		cd model.ComponentVersion,
		cdList *model.ComponentVersionList,
		values map[string]interface{}) (*DeployExecutorOutput, error)
	// TemplateExportExecutions templates a export executor.
	// It return the exported data as key value map where the key is the name of the export.
	TemplateExportExecutions(tmplExec lsv1alpha1.TemplateExecutor,
		blueprint *blueprints.Blueprint,
		descriptor model.ComponentVersion,
		cdList *model.ComponentVersionList,
		values map[string]interface{}) (*ExportExecutorOutput, error)
}

ExecutionTemplater describes a implementation for a template execution

type ExportExecutionOptions

type ExportExecutionOptions struct {
	BlueprintExecutionOptions
	Exports map[string]interface{}
}

ExportExecutionOptions describes the options for templating the deploy executions.

func NewExportExecutionOptions

func NewExportExecutionOptions(base BlueprintExecutionOptions, exports map[string]interface{}) ExportExecutionOptions

func (*ExportExecutionOptions) Values

func (o *ExportExecutionOptions) Values() (map[string]interface{}, error)

type ExportExecutorOutput

type ExportExecutorOutput struct {
	Exports map[string]interface{} `json:"exports"`
}

ExportExecutorOutput describes the output of export executor.

type GenericStateHandler

type GenericStateHandler interface {
	Store(context.Context, string, []byte) error
	Get(context.Context, string) ([]byte, error)
}

type ImportExecutorOutput

type ImportExecutorOutput struct {
	Bindings map[string]interface{} `json:"bindings"`
	Errors   []string               `json:"errors"`
}

ImportExecutorOutput describes the output of import executor.

type KubernetesStateHandler

type KubernetesStateHandler struct {
	KubeClient client.Client
	Inst       *lsv1alpha1.Installation
}

KubernetesStateHandler implements the GenericStateHandler interface that stores the stateHdl in a kubernetes cluster.

func (KubernetesStateHandler) Get

func (s KubernetesStateHandler) Get(ctx context.Context, name string) ([]byte, error)

func (KubernetesStateHandler) Store

func (s KubernetesStateHandler) Store(ctx context.Context, name string, data []byte) error

type MemoryStateHandler

type MemoryStateHandler map[string][]byte

func NewMemoryStateHandler

func NewMemoryStateHandler() MemoryStateHandler

func (MemoryStateHandler) Get

func (m MemoryStateHandler) Get(_ context.Context, name string) ([]byte, error)

func (MemoryStateHandler) Store

func (m MemoryStateHandler) Store(_ context.Context, name string, data []byte) error

type SubinstallationExecutorOutput

type SubinstallationExecutorOutput struct {
	Subinstallations []*lsv1alpha1.InstallationTemplate `json:"subinstallations"`
}

SubinstallationExecutorOutput describes the output of deploy executor.

func (SubinstallationExecutorOutput) MarshalJSON

func (o SubinstallationExecutorOutput) MarshalJSON() ([]byte, error)

func (*SubinstallationExecutorOutput) UnmarshalJSON

func (o *SubinstallationExecutorOutput) UnmarshalJSON(data []byte) error

type TargetReference

type TargetReference struct {
	// +optional
	Name string `json:"name,omitempty"`

	// +optional
	Import string `json:"import,omitempty"`

	// +optional
	Index *int `json:"index,omitempty"`

	// +optional
	Key *string `json:"key,omitempty"`
}

type TemplateInputFormatter

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

The TemplateInputFormatter formats the input parameter of a template in a human-readable format.

func NewTemplateInputFormatter

func NewTemplateInputFormatter(prettyPrint bool, sensitiveKeys ...string) *TemplateInputFormatter

NewTemplateInputFormatter creates a new template input formatter. When prettyPrint is set to true, the json output will be formatted with easier readable indentation. The parameter sensitiveKeys can contain template input keys which may contain sensitive data. When such a key is encountered during formatting, the values of the respective key will be removed.

func (*TemplateInputFormatter) Format

func (f *TemplateInputFormatter) Format(input map[string]interface{}, prefix string) string

Format formats the template input into a string value. The given prefix is prepended to each line of the formatted output.

type Templater

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

Templater implements all available template executors.

func New

func New(templaters ...ExecutionTemplater) *Templater

New creates a new instance of a templater.

func (*Templater) TemplateDeployExecutions

func (o *Templater) TemplateDeployExecutions(opts DeployExecutionOptions) ([]DeployItemSpecification, error)

TemplateDeployExecutions templates all deploy executions and returns a aggregated list of all templated deploy item templates.

func (*Templater) TemplateExportExecutions

func (o *Templater) TemplateExportExecutions(opts ExportExecutionOptions) (map[string]interface{}, error)

TemplateExportExecutions templates all exports.

func (*Templater) TemplateImportExecutions

func (o *Templater) TemplateImportExecutions(opts BlueprintExecutionOptions) ([]string, map[string]interface{}, error)

func (*Templater) TemplateSubinstallationExecutions

func (o *Templater) TemplateSubinstallationExecutions(opts DeployExecutionOptions) ([]*lsv1alpha1.InstallationTemplate, error)

TemplateSubinstallationExecutions templates all subinstallation executions and returns a aggregated list of all templated installation templates.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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