Documentation ¶
Index ¶
- Constants
- Variables
- func BcryptString(pwd []byte) (string, error)
- func BuildDep(m Module, dep *Dependency) error
- func BuildModuleDeps(m Module) error
- func ConvertToShellVar(name string) string
- func ConvertToShellVarName(name string) string
- func ConvertToTfVarName(name string) string
- func CreateMarker(markerPath, dataForHash string) string
- func ProjectsFilesExists() bool
- func RegisterBackendFactory(f BackendsFactory, provider string) error
- func RegisterModuleFactory(f ModuleFactory, modType string) error
- func RegisterSecretDriver(drv SecretDriver, key string) error
- func RegisterTemplateDriver(drv TemplateDriver)
- func ScanMarkers(data interface{}, procFunc MarkerScanner, module Module) error
- type Backend
- type BackendsFactory
- type Dependency
- type InfraTemplate
- type Infrastructure
- type MarkerScanner
- type Module
- type ModuleDriver
- type ModuleFactory
- type ModuleState
- type ObjectData
- type Project
- func (p *Project) Apply() error
- func (p *Project) Build() error
- func (p *Project) CheckContainsMarkers(data string, kinds ...string) bool
- func (p *Project) Destroy() error
- func (p *Project) Edit(name string) error
- func (p *Project) ExportEnvs(ex interface{}) error
- func (p *Project) LoadState() (*StateProject, error)
- func (p *Project) MkBuildDir() error
- func (p *Project) Name() string
- func (p *Project) Plan() error
- func (p *Project) PrintInfo() error
- func (p *Project) PrintSecretsList()
- func (p *Project) SaveState() error
- func (p *Project) TemplateMust(data []byte) (res []byte, err error)
- func (p *Project) TemplateTry(data []byte) (res []byte, warn bool, err error)
- type Secret
- type SecretDriver
- type StateProject
- type TemplateDriver
Constants ¶
const ConfigFileName = "project.yaml"
ConfigFileName name of required project config file.
Variables ¶
var BackendsFactories = map[string]BackendsFactory{}
BackendsFactories map of backend providers factories. Use BackendsFactories["prov_name"].New() to create backend of provider 'prov_name'
var ModuleFactoriesMap = map[string]ModuleFactory{}
var SecretDriversMap = map[string]SecretDriver{}
var TemplateDriversMap map[string]TemplateDriver = map[string]TemplateDriver{}
Functions ¶
func BcryptString ¶
func BuildDep ¶
func BuildDep(m Module, dep *Dependency) error
func BuildModuleDeps ¶
BuildModuleDeps check all dependencies and add module pointer.
func ConvertToShellVar ¶
func ConvertToShellVarName ¶
func ConvertToTfVarName ¶
func CreateMarker ¶
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 ¶
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 ¶
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 ¶
LoadProjectBase read project data in current directory, create base project, and load secrets. Infrastructures, backends and other objects are not loads.
func LoadProjectFull ¶
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) CheckContainsMarkers ¶
CheckContainsMarkers - check if string contains any template markers.
func (*Project) ExportEnvs ¶
func (*Project) LoadState ¶
func (p *Project) LoadState() (*StateProject, error)
func (*Project) MkBuildDir ¶
func (*Project) PrintSecretsList ¶
func (p *Project) PrintSecretsList()
func (*Project) TemplateMust ¶
TemplateMust do template
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 ¶
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)