common

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateFileRepresentation

type CreateFileRepresentation struct {
	FileName string      `yaml:"file"`
	FileMode fs.FileMode `yaml:"file_mode,omitempty"`
	Content  string      `yaml:"content"`
}

CreateFileRepresentation describes the unit's file that will be saved in the unit's working directory when building.

type Factory

type Factory struct {
}

Factory factory for s3 backends.

func (*Factory) New

func (f *Factory) New(spec map[string]interface{}, stack *project.Stack) (project.Unit, error)

New creates new units driver factory.

func (*Factory) NewFromState

func (f *Factory) NewFromState(spec map[string]interface{}, modKey string, p *project.StateProject) (project.Unit, error)

NewFromState creates new units from state data.

type FilesListT added in v0.5.2

type FilesListT []*CreateFileRepresentation

FilesListT describes all unit's files will be write to the unit's working directory when building.

func (*FilesListT) Add added in v0.5.2

func (l *FilesListT) Add(fileName string, content string, mode fs.FileMode) error

Add insert the new file with name fileName, returns error if file with this name already exists.

func (*FilesListT) Delete added in v0.5.2

func (l *FilesListT) Delete(fileName string)

Delete delete file with name fileName, do nothing if not found.

func (*FilesListT) Find added in v0.5.2

func (l *FilesListT) Find(fileName string) int

Find searchs file and returns a pointer to it or nil if not found.

func (*FilesListT) ReadDir added in v0.5.2

func (l *FilesListT) ReadDir(path, baseDir string) (err error)

ReadDir recursively reads files in path, saving relative pathes from baseDir.

func (*FilesListT) SPrint added in v0.5.2

func (l *FilesListT) SPrint() string

func (*FilesListT) WriteFiles added in v0.5.2

func (l *FilesListT) WriteFiles(path string) (err error)

WriteFiles write all files to path.

type HookSpec added in v0.5.2

type HookSpec struct {
	Command   string `json:"command"`
	OnDestroy bool   `yaml:"on_destroy,omitempty" json:"on_destroy,omitempty"`
	OnApply   bool   `yaml:"on_apply,omitempty" json:"on_apply,omitempty"`
	OnPlan    bool   `yaml:"on_plan,omitempty" json:"on_plan,omitempty"`
}

HookSpec describes pre/post hooks configuration in unit YAML.

type OperationConfig

type OperationConfig struct {
	Commands []interface{} `yaml:"commands" json:"commands"`
}

OperationConfig type that describe apply, plan and destroy operations.

type OutputParser added in v0.5.2

type OutputParser func(string, interface{}) error

OutputParser represents function for parsing unit output.

type OutputsConfigSpec

type OutputsConfigSpec struct {
	Command   string `yaml:"command,omitempty" json:"command,omitempty"`
	Type      string `yaml:"type" json:"type"`
	Regexp    string `yaml:"regexp,omitempty" json:"regexp,omitempty"`
	Separator string `yaml:"separator,omitempty" json:"separator,omitempty"`
}

OutputsConfigSpec describe how to retrive parse unit outputs.

type Unit

type Unit struct {
	StatePtr         *Unit                                `yaml:"-" json:"-"`
	StackPtr         *project.Stack                       `yaml:"-" json:"-"`
	ProjectPtr       *project.Project                     `yaml:"-" json:"-"`
	DependenciesList []*project.DependencyOutput          `yaml:"-" json:"dependencies,omitempty"`
	Outputs          map[string]*project.DependencyOutput `yaml:"-" json:"outputs,omitempty"`
	SpecRaw          map[string]interface{}               `yaml:"-" json:"-"`
	OutputRaw        []byte                               `yaml:"-" json:"-"`
	CacheDir         string                               `yaml:"-" json:"-"`
	MyName           string                               `yaml:"name" json:"name"`
	WorkDir          string                               `yaml:"work_dir,omitempty" json:"work_dir,omitempty"`
	Env              interface{}                          `yaml:"env,omitempty" json:"env,omitempty"`
	CreateFiles      *FilesListT                          `yaml:"create_files,omitempty" json:"create_files,omitempty"`
	InitConf         *OperationConfig                     `yaml:"init,omitempty" json:"init,omitempty"`
	ApplyConf        *OperationConfig                     `yaml:"apply,omitempty" json:"apply,omitempty"`
	PlanConf         *OperationConfig                     `yaml:"plan,omitempty" json:"plan,omitempty"`
	DestroyConf      *OperationConfig                     `yaml:"destroy,omitempty" json:"destroy,omitempty"`
	GetOutputsConf   *OutputsConfigSpec                   `yaml:"outputs,omitempty" json:"outputs_config,omitempty"`
	OutputParsers    map[string]OutputParser              `yaml:"-" json:"-"`
	Applied          bool                                 `yaml:"-" json:"-"`
	PreHook          *HookSpec                            `yaml:"-" json:"pre_hook,omitempty"`
	PostHook         *HookSpec                            `yaml:"-" json:"post_hook,omitempty"`
	UnitKind         string                               `yaml:"-" json:"type"`
	BackendPtr       *project.Backend                     `yaml:"-" json:"-"`
	BackendName      string                               `yaml:"-" json:"backend_name"`
}

Unit describe cluster.dev shell unit.

func NewEmptyUnit added in v0.5.2

func NewEmptyUnit() Unit

NewEmptyUnit creates new unit.

func NewUnit added in v0.5.2

func NewUnit(spec map[string]interface{}, stack *project.Stack) (*Unit, error)

NewUnit creates new unit and load config.

func (*Unit) Apply

func (u *Unit) Apply() error

Apply runs unit apply procedure.

func (*Unit) ApplyOutput

func (u *Unit) ApplyOutput() []byte

ApplyOutput return output of unit applying.

func (*Unit) Backend

func (u *Unit) Backend() project.Backend

Backend return unit backend.

func (*Unit) Build

func (m *Unit) Build() error

func (*Unit) CodeDir

func (u *Unit) CodeDir() string

CodeDir return path to unit code directory.

func (*Unit) Dependencies

func (u *Unit) Dependencies() *[]*project.DependencyOutput

Dependencies return slice of unit dependencies.

func (*Unit) Destroy

func (u *Unit) Destroy() error

Destroy unit.

func (*Unit) ExpectedOutputs

func (u *Unit) ExpectedOutputs() map[string]*project.DependencyOutput

ExpectedOutputs returns expected outputs of the unit.

func (*Unit) FindDependency added in v0.5.2

func (u *Unit) FindDependency(stackName, unitName string) *project.DependencyOutput

func (*Unit) GetDiffData

func (u *Unit) GetDiffData() interface{}

GetDiffData return unit representation as a data set for diff and reapply.

func (*Unit) GetState

func (u *Unit) GetState() interface{}

func (*Unit) GetStateDiffData added in v0.5.2

func (u *Unit) GetStateDiffData() interface{}

GetStateDiffData return unit representation as a data set for diff only update state.

func (*Unit) GetUnitDiff added in v0.5.2

func (u *Unit) GetUnitDiff() UnitDiffSpec

func (*Unit) Init

func (u *Unit) Init() error

Init runs init procedure for unit.

func (*Unit) JSONOutputParser

func (m *Unit) JSONOutputParser(in string, out interface{}) error

JSONOutputParser parse in (expected JSON string) and stores it in the value pointed to by out.

func (*Unit) Key

func (u *Unit) Key() string

Key return uniq unit index (stackName.unitName).

func (*Unit) KindKey

func (u *Unit) KindKey() string

KindKey returns unit kind.

func (*Unit) LoadState

func (u *Unit) LoadState(spec interface{}, modKey string, p *project.StateProject) error

func (*Unit) Name

func (u *Unit) Name() string

Name return unit name.

func (*Unit) Plan

func (u *Unit) Plan() error

Plan unit.

func (*Unit) Project added in v0.5.2

func (u *Unit) Project() *project.Project

Project return ptr to unit project.

func (*Unit) ReadConfig

func (u *Unit) ReadConfig(spec map[string]interface{}, stack *project.Stack) error

ReadConfig reads unit spec (unmarshaled YAML) and init the unit.

func (*Unit) RegexOutputParser

func (m *Unit) RegexOutputParser(in string, out interface{}) error

RegexOutputParser parse each line od in string with key/value regexp and stores result as a map in the value pointed to by out.

func (*Unit) ReplaceMarkers

func (u *Unit) ReplaceMarkers() error

ReplaceMarkers replace all templated markers with values.

func (*Unit) ReplaceOutputsForDiff added in v0.5.2

func (u *Unit) ReplaceOutputsForDiff(in, out interface{}) error

ReplaceOutputsForDiff replace remote state markers in struct to <remote state stack.mod.output> to show in diff.

func (*Unit) RequiredUnits added in v0.5.2

func (u *Unit) RequiredUnits() map[string]project.Unit

RequiredUnits list of dependencies in map representation.

func (*Unit) SeparatorOutputParser

func (m *Unit) SeparatorOutputParser(in string, out interface{}) error

SeparatorOutputParser split each line of in string with using separator and stores result as a map in the value pointed to by out.

func (*Unit) Stack added in v0.5.2

func (u *Unit) Stack() *project.Stack

Stack return ptr to unit stack.

func (*Unit) StackName

func (u *Unit) StackName() string

StackName return unit stack name.

func (*Unit) UpdateProjectRuntimeData

func (u *Unit) UpdateProjectRuntimeData(p *project.Project) error

UpdateProjectRuntimeData update project runtime dataset, adds unit outputs. TODO: get unit outputs and write to project runtime dataset. Now this function is only for printer's unit interface.

func (*Unit) WasApplied

func (u *Unit) WasApplied() bool

WasApplied return true if unit's method Apply was runned.

type UnitDiffSpec added in v0.5.2

type UnitDiffSpec struct {
	Outputs       map[string]string      `json:"outputs,omitempty"`
	CreateFiles   *FilesListT            `json:"create_files,omitempty"`
	ApplyConf     *OperationConfig       `json:"apply,omitempty"`
	Env           map[string]interface{} `json:"env,omitempty"`
	OutputsConfig *OutputsConfigSpec     `json:"outputs_config,omitempty"`
	PreHook       *HookSpec              `json:"pre_hook,omitempty"`
	PostHook      *HookSpec              `json:"post_hook,omitempty"`
}

UnitDiffSpec describe the pieces of StateSpec data, that will be comered in "plan" diff and should affect the unit redeployment.

Jump to

Keyboard shortcuts

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