scripted

package
v3.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandId                       string = "commands_id"
	CommandDependencies             string = "commands_dependencies"
	CommandNeedsUpdate              string = "commands_needs_update"
	CommandCustomizeDiffComputeKeys string = "commands_customizediff_computekeys"
	CommandCreate                   string = "commands_create"
	CommandDelete                   string = "commands_delete"
	CommandExists                   string = "commands_exists"
	CommandRead                     string = "commands_read"
	CommandUpdate                   string = "commands_update"
)
View Source
const DefaultEmptyString = `ZVaXr3jCd80vqJRhBP9t83LrpWIdNKWJ`

noinspection SpellCheckingInspection

View Source
const DefaultEnvPrefix = "TF_SCRIPTED_"
View Source
const DefaultLinePrefix = `QmGRizGk1fdPEBVVZSGkCRPJRgAe9p07B`

noinspection SpellCheckingInspection

View Source
const DefaultStatePrefix = `WViRV1TbGAGehAYFL8g3ZL8o1cg1bxaq`

noinspection SpellCheckingInspection

View Source
const DefaultTriggerString = `ndn4VFxYG489bUmV6xKjKFE0RYQIJdts`

noinspection SpellCheckingInspection

View Source
const JsonContextEnvKey = "TF_SCRIPTED_CONTEXT"
View Source
const MaxUint64 = ^uint64(0)
View Source
const TriggerStringTpl = `{{ .TriggerString }}`
View Source
const Version = version.Version

Variables

View Source
var Debug = getEnvBool("DEBUG", false)
View Source
var DefaultInterpreter = []string{"bash", "-Eeuo", "pipefail", "-c", "{{ .command }}"}

noinspection SpellCheckingInspection

View Source
var DefaultWindowsInterpreter = []string{"cmd", "/C", "{{ .command }}"}
View Source
var EnvEmptyString = getEnvMust("EMPTY_STRING", DefaultEmptyString)

String representing empty value, can be set to anything

View Source
var EnvPrefix = envDefault("TF_SCRIPTED_ENV_PREFIX", DefaultEnvPrefix)
View Source
var ExtraTemplateFuncs = template.FuncMap{
	"toYaml":             toYaml,
	"fromYaml":           fromYaml,
	"toJson":             toJson,
	"toPrettyJson":       toPrettyJson,
	"fromJson":           fromJson,
	"is":                 is,
	"isSet":              isSet,
	"isFilled":           isFilled,
	"terraformifyValues": terraformifyPrimitives,

	"include":  func(string, interface{}) string { return "not implemented" },
	"required": func(string, interface{}) interface{} { return "not implemented" },
}
View Source
var SprigTemplateFuncs = getSprigTemplateFuncs()
View Source
var Stderr = os.Stderr
View Source
var Stdout = os.Stdout

noinspection GoUnusedGlobalVariable

View Source
var TemplateFuncs = getTemplateFuncs()
View Source
var ValidLogLevelsStrings = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"}

Functions

func NewTemplate

func NewTemplate(name string) *template.Template

func ParentStderr

func ParentStderr() *os.File

func Provider

func Provider() terraform.ResourceProvider

func RandomSafeString

func RandomSafeString(length int) string

noinspection GoUnusedExportedFunction

func RandomString

func RandomString(length int) string

noinspection GoUnusedExportedFunction

func RandomStringWithCharset

func RandomStringWithCharset(length int, charset string) string

Types

type ChangeMap

type ChangeMap struct {
	Old map[string]interface{}
	New map[string]interface{}
	Cur map[string]interface{}
}

type Closable

type Closable interface {
	Close() error
}

type CommandTemplates

type CommandTemplates struct {
	Create        string
	Delete        string
	Dependencies  string
	Exists        string
	Id            string
	Interpreter   []string
	ModifyPrefix  string
	Prefix        string
	PrefixFromEnv string
	Read          string
	NeedsUpdate   string
	Update        string
}

type CommandsConfig

type CommandsConfig struct {
	Environment                 *EnvironmentConfig
	Templates                   *CommandTemplates
	Output                      *OutputConfig
	DeleteOnNotExists           bool
	DeleteOnReadFailure         bool
	Separator                   string
	WorkingDirectory            string
	TriggerString               string
	InterpreterIsProvider       bool
	InterpreterProviderCommands []string
	DependenciesNotMetError     bool
}

type EnvironmentChangeMap

type EnvironmentChangeMap struct {
	Old map[string]string
	New map[string]string
	Cur map[string]string
}

type EnvironmentConfig

type EnvironmentConfig struct {
	PrefixNew          string
	PrefixOld          string
	IncludeParent      bool
	InheritVariables   []string
	IncludeJsonContext bool
}

type JsonContext

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

type KVEntry

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

type LoggedOutput

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

func (*LoggedOutput) Close

func (lo *LoggedOutput) Close() error

func (*LoggedOutput) Start

func (lo *LoggedOutput) Start() *io.PipeWriter

type Logger

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

func (*Logger) Log

func (l *Logger) Log(level hclog.Level, msg string, args ...interface{})

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

type Logging

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

func (*Logging) Clone

func (ls *Logging) Clone() *Logging

func (*Logging) Log

func (ls *Logging) Log(level hclog.Level, msg string, args ...interface{})

func (*Logging) PopIf

func (ls *Logging) PopIf(expected *Logger) *Logger

func (*Logging) Push

func (ls *Logging) Push(args ...interface{}) *Logger

func (*Logging) PushDefer

func (ls *Logging) PushDefer(args ...interface{}) func()

type OutputConfig

type OutputConfig struct {
	LogLevel  hclog.Level
	LineWidth int
	LogPids   bool
	LogIids   bool
}

type ProviderConfig

type ProviderConfig struct {
	Commands          *CommandsConfig
	StateComputeKeys  []string
	OutputComputeKeys []string

	Templates                  *TemplatesConfig
	RunningMessageInterval     float64
	EmptyString                string
	LoggingBufferSize          int64
	OutputUseDefaultLinePrefix bool
	OutputLinePrefix           string
	OutputFormat               string
	StateFormat                string
	StateLinePrefix            string
	LinePrefix                 string
	Version                    string
	InstanceState              *terraform.InstanceState
	EnvPrefix                  string
	OpenParentStderr           bool
	// contains filtered or unexported fields
}

type ResourceConfig

type ResourceConfig struct {
	Context *ChangeMap
	// contains filtered or unexported fields
}

type ResourceData

type ResourceData struct {
	*schema.ResourceData
}

func (*ResourceData) Get

func (d *ResourceData) Get(key string) interface{}

func (*ResourceData) GetChange

func (d *ResourceData) GetChange(key string) (interface{}, interface{})

func (*ResourceData) GetChangedKeysPrefix

func (d *ResourceData) GetChangedKeysPrefix(prefix string) []string

func (*ResourceData) GetOk

func (d *ResourceData) GetOk(key string) (interface{}, bool)

func (*ResourceData) GetOld

func (d *ResourceData) GetOld(key string) interface{}

func (*ResourceData) GetRollbackKeys

func (d *ResourceData) GetRollbackKeys() []string

func (*ResourceData) HasChangedKeysPrefix

func (d *ResourceData) HasChangedKeysPrefix(prefix string) bool

func (*ResourceData) IsNew

func (d *ResourceData) IsNew() bool

func (*ResourceData) Set

func (d *ResourceData) Set(key string, value interface{}) (err error)

func (*ResourceData) SetIdErr

func (d *ResourceData) SetIdErr(value string) error

type ResourceDiff

type ResourceDiff struct {
	*schema.ResourceDiff
}

func (*ResourceDiff) GetChange

func (rd *ResourceDiff) GetChange(key string) (o interface{}, n interface{})

func (*ResourceDiff) GetChangedKeysPrefix

func (rd *ResourceDiff) GetChangedKeysPrefix(prefix string) []string

func (*ResourceDiff) GetOld

func (rd *ResourceDiff) GetOld(key string) interface{}

func (*ResourceDiff) GetRollbackKeys

func (rd *ResourceDiff) GetRollbackKeys() []string

func (*ResourceDiff) HasChange

func (rd *ResourceDiff) HasChange(key string) bool

func (*ResourceDiff) HasChangedKeysPrefix

func (rd *ResourceDiff) HasChangedKeysPrefix(prefix string) bool

func (*ResourceDiff) IsNew

func (rd *ResourceDiff) IsNew() bool

func (*ResourceDiff) Set

func (rd *ResourceDiff) Set(key string, value interface{}) error

func (*ResourceDiff) SetIdErr

func (rd *ResourceDiff) SetIdErr(string) error

type ResourceInterface

type ResourceInterface interface {
	GetChange(string) (interface{}, interface{})
	Get(string) interface{}
	GetOld(string) interface{}
	GetOk(string) (interface{}, bool)
	Set(string, interface{}) error
	Id() string
	IsNew() bool
	SetIdErr(string) error
	GetChangedKeysPrefix(string) []string
	GetRollbackKeys() []string
	HasChangedKeysPrefix(string) bool
	HasChange(string) bool
}

func WrapResourceData

func WrapResourceData(data *schema.ResourceData) ResourceInterface

func WrapResourceDiff

func WrapResourceDiff(diff *schema.ResourceDiff) ResourceInterface

type Scripted

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

func New

func New(d ResourceInterface, meta interface{}, operation TerraformOperation, old bool) (*Scripted, error)

func (*Scripted) Environment

func (s *Scripted) Environment() (*EnvironmentChangeMap, error)

type TemplateArg

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

type TemplateContext

type TemplateContext struct {
	*ChangeMap
	Provider      *ProviderConfig
	Operation     TerraformOperation
	EmptyString   string
	TriggerString string
	StatePrefix   string
	OutputPrefix  string
	LinePrefix    string
	Output        map[string]interface{}
	State         *ChangeMap
	TemplateName  string
	TemplateNames []string
	Command       string
}

type TemplatesConfig

type TemplatesConfig struct {
	LeftDelim  string
	RightDelim string
}

type TerraformOperation

type TerraformOperation string
const (
	OperationCreate        TerraformOperation = "create"
	OperationRead          TerraformOperation = "read"
	OperationExists        TerraformOperation = "exists"
	OperationUpdate        TerraformOperation = "update"
	OperationDelete        TerraformOperation = "delete"
	OperationCustomizeDiff TerraformOperation = "customizediff"
)

Jump to

Keyboard shortcuts

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