project

package
v0.4.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileName = "project.yaml"

ConfigFileName name of required project config file.

Variables

View Source
var BackendsFactories = map[string]BackendsFactory{}

BackendsFactories map of backend providers factories. Use BackendsFactories["prov_name"].New() to create backend of provider 'prov_name'

View Source
var ModuleFactoriesMap = map[string]ModuleFactory{}
View Source
var SecretDriversMap = map[string]SecretDriver{}
View Source
var TemplateDriversMap map[string]TemplateDriver = map[string]TemplateDriver{}

Functions

func BcryptString

func BcryptString(pwd []byte) (string, error)

func BuildDep

func BuildDep(m Module, dep *Dependency) error

func BuildModuleDeps

func BuildModuleDeps(m Module) error

BuildModuleDeps check all dependencies and add module pointer.

func ConvertToShellVar

func ConvertToShellVar(name string) string

func ConvertToShellVarName

func ConvertToShellVarName(name string) string

func ConvertToTfVarName

func ConvertToTfVarName(name string) string

func CreateMarker

func CreateMarker(markerPath, dataForHash string) string

CreateMarker generate hash string for template markers.

func ProjectsFilesExists

func ProjectsFilesExists() bool

func RegisterBackendFactory

func RegisterBackendFactory(f BackendsFactory, provider string) error

RegisterBackendFactory - register factory of some provider (like s3) in map.

func RegisterModuleFactory

func RegisterModuleFactory(f ModuleFactory, modType string) error

func RegisterSecretDriver

func RegisterSecretDriver(drv SecretDriver, key string) error

func RegisterTemplateDriver

func RegisterTemplateDriver(drv TemplateDriver)

RegisterTemplateDriver register module template driver.

func ScanMarkers

func ScanMarkers(data interface{}, procFunc MarkerScanner, module Module) error

ScanMarkers use marker scanner function to replace templated markers.

Types

type Backend

type Backend interface {
	Name() string
	Provider() string
	GetBackendHCL(string, string) (*hclwrite.File, error)
	GetBackendBytes(string, string) ([]byte, error)
	GetRemoteStateHCL(string, string) ([]byte, error)
	State() map[string]interface{}
}

Backend interface for backend provider.

type BackendsFactory

type BackendsFactory interface {
	New([]byte, string) (Backend, error)
}

BackendsFactory - interface for backend provider factory. New() creates backend.

type Dependency

type Dependency struct {
	Module     Module `json:"-"`
	ModuleName string
	InfraName  string
	Output     string
}

Dependency describe module dependency.

type InfraTemplate

type InfraTemplate struct {
	Name    string                   `yaml:"name"`
	Kind    string                   `yaml:"kind"`
	Modules []map[string]interface{} `yaml:"modules"`
}

func NewInfraTemplate

func NewInfraTemplate(data []byte) (*InfraTemplate, error)

type Infrastructure

type Infrastructure struct {
	ProjectPtr  *Project
	Backend     Backend
	Name        string
	BackendName string
	TemplateSrc string
	TemplateDir string
	Templates   []InfraTemplate
	Variables   map[string]interface{}
	ConfigData  map[string]interface{}
}

func (*Infrastructure) ReadTemplates

func (i *Infrastructure) ReadTemplates(src string) (err error)

ReadTemplates read all templates in src.

func (*Infrastructure) TemplateMust

func (i *Infrastructure) TemplateMust(data []byte) (res []byte, err error)

TemplateTry apply infrastructure variables to template data. If template has unresolved variables - function will return an error.

func (*Infrastructure) TemplateTry

func (i *Infrastructure) TemplateTry(data []byte) (res []byte, warn bool, err error)

TemplateTry apply infrastructure variables to template data. If template has unresolved variables - warn will be set to true.

type MarkerScanner

type MarkerScanner func(data reflect.Value, module Module) (reflect.Value, error)

MarkerScanner type witch describe function for scaning markers in templated and unmarshaled yaml data.

type Module

type Module interface {
	Name() string
	InfraPtr() *Infrastructure
	ProjectPtr() *Project
	InfraName() string
	ReplaceMarkers() error
	Dependencies() *[]*Dependency
	Build(string) error
	Apply() error
	Plan() error
	Destroy() error
	Key() string
	ExpectedOutputs() map[string]bool
	GetState() interface{}
	GetDiffData() interface{}
	LoadState(interface{}, string, *StateProject) error
	KindKey() string
}

Module interface for module drivers.

func NewModule

func NewModule(spec map[string]interface{}, infra *Infrastructure) (Module, error)

NewModule creates and return module with needed driver.

func NewModuleFromState

func NewModuleFromState(state map[string]interface{}, infra *Infrastructure) (Module, error)

NewModuleFromState creates module from saved state.

type ModuleDriver

type ModuleDriver interface {
	AddTemplateFunctions(projectPtr *Project) error
	GetScanners() []MarkerScanner
}

type ModuleFactory

type ModuleFactory interface {
	New(map[string]interface{}, *Infrastructure) (Module, error)
	NewFromState(map[string]interface{}, string, *StateProject) (Module, error)
}

type ModuleState

type ModuleState interface {
	GetType() string
}

type ObjectData

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

ObjectData simple representation of project object.

type Project

type Project struct {
	Modules          map[string]Module
	Infrastructures  map[string]*Infrastructure
	TmplFunctionsMap template.FuncMap
	Backends         map[string]Backend
	Markers          map[string]interface{}
	// contains filtered or unexported fields
}

Project describes main config with user-defined variables.

func LoadProjectBase

func LoadProjectBase() (*Project, error)

LoadProjectBase read project data in current directory, create base project, and load secrets. Infrastructures, backends and other objects are not loads.

func LoadProjectFull

func LoadProjectFull() (*Project, error)

LoadProjectFull read project data in current directory, create base project, load secrets and all project's objects.

func NewEmptyProject

func NewEmptyProject() *Project

NewEmptyProject creates new empty project. The configuration will not be loaded.

func (*Project) Apply

func (p *Project) Apply() error

Apply all modules.

func (*Project) Build

func (p *Project) Build() error

Build generate all terraform code for project.

func (*Project) CheckContainsMarkers

func (p *Project) CheckContainsMarkers(data string, kinds ...string) bool

CheckContainsMarkers - check if string contains any template markers.

func (*Project) Destroy

func (p *Project) Destroy() error

Destroy all modules.

func (*Project) Edit

func (p *Project) Edit(name string) error

func (*Project) LoadState

func (p *Project) LoadState() (*StateProject, error)

func (*Project) MkBuildDir

func (p *Project) MkBuildDir() error

func (*Project) Name

func (p *Project) Name() string

Name return project name.

func (*Project) Plan

func (p *Project) Plan() error

Plan and output result.

func (*Project) PrintInfo

func (p *Project) PrintInfo() error

PrintInfo print project info.

func (*Project) PrintSecretsList

func (p *Project) PrintSecretsList()

func (*Project) ProcessExport

func (p *Project) ProcessExport(ex interface{}) error

func (*Project) SaveState

func (p *Project) SaveState() error

func (*Project) TemplateMust

func (p *Project) TemplateMust(data []byte) (res []byte, err error)

TemplateMust do template

func (*Project) TemplateTry

func (p *Project) TemplateTry(data []byte) (res []byte, warn bool, err error)

TemplateTry do template

type Secret

type Secret struct {
	Filename  string
	DriverKey string
	Data      interface{}
}

type SecretDriver

type SecretDriver interface {
	// Read secret from raw yaml data. Return secret name, parsed secret data (for project templateing) and error.
	Read([]byte) (string, interface{}, error)
	// Return secret driver key (sops ...)
	Key() string
	// Edit secret.
	Edit(Secret) error
	// Create secret from files list generated by ui.generator/
	Create(map[string][]byte) error
}

type StateProject

type StateProject struct {
	Project
	LoaderProjectPtr *Project
	ChangedModules   map[string]Module
}

func (*StateProject) CheckModuleChanges

func (sp *StateProject) CheckModuleChanges(module Module) string

func (*StateProject) DeleteModule

func (sp *StateProject) DeleteModule(mod Module)

func (*StateProject) UpdateModule

func (sp *StateProject) UpdateModule(mod Module)

type TemplateDriver

type TemplateDriver interface {
	AddTemplateFunctions(*Project)
	Name() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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