scripted

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEmptyString = `ZVaXr3jCd80vqJRhBP9t83LrpWIdNKWJ`
View Source
const DefaultEnvPrefix = "TF_SCRIPTED_"
View Source
const DefaultLinePrefix = DefaultStatePrefix
View Source
const DefaultStatePrefix = `WViRV1TbGAGehAYFL8g3ZL8o1cg1bxaq`
View Source
const DefaultTriggerString = `ndn4VFxYG489bUmV6xKjKFE0RYQIJdts`
View Source
const TriggerStringTpl = `{{ .TriggerString }}`

Variables

View Source
var Debug = getEnvBool("DEBUG", false)
View Source
var DefaultInterpreter = []string{"bash", "-Eeuo", "pipefail", "-c", "{{ .command }}"}
View Source
var DefaultWindowsInterpreter = []string{"cmd", "/C", "{{ .command }}"}
View Source
var EmptyString = 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,
}
View Source
var LinePrefix = getEnvMust("LINE_PREFIX", DefaultLinePrefix)
View Source
var SprigTemplateFuncs = getSprigTemplateFuncs()
View Source
var StatePrefix = getEnvMust("STATE_PREFIX", DefaultStatePrefix)
View Source
var Stderr = os.Stderr

Store original os.Stderr and os.Stdout, because it gets overwritten by go-plugin/server:Serve()

View Source
var Stdout = os.Stdout
View Source
var TemplateFuncs = getTemplateFuncs()
View Source
var TriggerString = getEnvMust("TRIGGER_STRING", DefaultTriggerString)
View Source
var ValidLogLevelsStrings = []string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"}

Functions

func Provider

func Provider() terraform.ResourceProvider

func RandomSafeString

func RandomSafeString(length int) string

func RandomString

func RandomString(length int) string

func RandomStringWithCharset

func RandomStringWithCharset(length int, charset string) string

func ToString

func ToString(val interface{}) string

Types

type ChangeMap

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

type CommandTemplates

type CommandTemplates struct {
	Create                   string
	CustomizeDiffComputeKeys 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
	CreateAfterUpdate   bool
	DeleteBeforeUpdate  bool
	DeleteOnNotExists   bool
	DeleteOnReadFailure bool
	Separator           string
	WorkingDirectory    string
	TriggerString       string
}

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
}

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()

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 Operation

type Operation string
const (
	Create Operation = "create"
	Read   Operation = "read"
	Exists Operation = "exists"
	Update Operation = "update"
	Delete Operation = "delete"
)

type OutputConfig

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

type ProviderConfig

type ProviderConfig struct {
	Commands                   *CommandsConfig
	ComputeStateKeys           []string
	ComputeOutputKeys          []string
	Logging                    *Logging
	Templates                  *TemplatesConfig
	RunningMessageInterval     float64
	EmptyString                string
	LoggingBufferSize          int64
	OutputUseDefaultLinePrefix bool

	OutputFormat    string
	StateFormat     string
	StateLinePrefix string
	LinePrefix      string
	// contains filtered or unexported fields
}

func (*ProviderConfig) OutputLinePrefix

func (pc *ProviderConfig) OutputLinePrefix() string

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) Set

func (d *ResourceData) Set(key string, value interface{}) 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) 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{}
	GetOk(string) (interface{}, bool)
	Set(string, interface{}) error
	Id() string
	SetIdErr(string) error
	GetChangedKeysPrefix(string) []string
}

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 Operation, 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
	Operation     Operation
	EmptyString   string
	TriggerString string
	StatePrefix   string
	OutputPrefix  string
	Output        map[string]interface{}
	State         *ChangeMap
}

type TemplatesConfig

type TemplatesConfig struct {
	LeftDelim  string
	RightDelim string
}

Jump to

Keyboard shortcuts

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