jobspec2

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MPL-2.0 Imports: 36 Imported by: 10

Documentation

Index

Constants

View Source
const VarEnvPrefix = "NOMAD_VAR_"

Prefix your environment variables with VarEnvPrefix so that Packer can see them.

Variables

This section is empty.

Functions

func Functions

func Functions(basedir string, allowFS bool) map[string]function.Function

Functions returns the set of functions that should be used to when evaluating expressions in the receiving scope.

basedir is used with file functions and allows a user to reference a file using local path. Usually basedir is the directory in which the config file is located

func Parse

func Parse(path string, r io.Reader) (*api.Job, error)

func ParseWithConfig

func ParseWithConfig(args *ParseConfig) (*api.Job, error)

Types

type LocalBlock

type LocalBlock struct {
	Name string
	Expr hcl.Expression
}

Local represents a single entry from a "locals" block in a file. The "locals" block itself is not represented, because it serves only to provide context for us to interpret its contents.

type ParseConfig

type ParseConfig struct {
	Path    string
	BaseDir string

	// Body is the HCL body
	Body []byte

	// AllowFS enables HCL functions that require file system accecss
	AllowFS bool

	// ArgVars is the CLI -var arguments
	ArgVars []string

	// VarFiles is the paths of variable data files
	VarFiles []string

	// Envs represent process environment variable
	Envs []string

	Strict bool
	// contains filtered or unexported fields
}

type Variable

type Variable struct {
	// Values contains possible values for the variable; The last value set
	// from these will be the one used. If none is set; an error will be
	// returned by Value().
	Values []VariableAssignment

	// Validations contains all variables validation rules to be applied to the
	// used value. Only the used value - the last value from Values - is
	// validated.
	Validations []*VariableValidation

	// Cty Type of the variable. If the default value or a collected value is
	// not of this type nor can be converted to this type an error diagnostic
	// will show up. This allows us to assume that values are valid later in
	// code.
	//
	// When a default value - and no type - is passed in the variable
	// declaration, the type of the default variable will be used. This will
	// allow to ensure that users set this variable correctly.
	Type cty.Type
	// Common name of the variable
	Name string
	// Description of the variable
	Description string

	Range hcl.Range
}

func (*Variable) GoString

func (v *Variable) GoString() string

func (*Variable) Value

func (v *Variable) Value() (cty.Value, hcl.Diagnostics)

Value returns the last found value from the list of variable settings.

type VariableAssignment

type VariableAssignment struct {
	// From tells were it was taken from, command/varfile/env/default
	From  string
	Value cty.Value
	Expr  hcl.Expression
}

VariableAssignment represents a way a variable was set: the expression setting it and the value of that expression. It helps pinpoint were something was set in diagnostics.

type VariableValidation

type VariableValidation struct {
	// Condition is an expression that refers to the variable being tested and
	// contains no other references. The expression must return true to
	// indicate that the value is valid or false to indicate that it is
	// invalid. If the expression produces an error, that's considered a bug in
	// the block defining the validation rule, not an error in the caller.
	Condition hcl.Expression

	// ErrorMessage is one or more full sentences, which _should_ be in English
	// for consistency with the rest of the error message output but can in
	// practice be in any language as long as it ends with a period. The
	// message should describe what is required for the condition to return
	// true in a way that would make sense to a caller of the module.
	ErrorMessage string

	DeclRange hcl.Range
}

VariableValidation represents a configuration-defined validation rule for a particular input variable, given as a "validation" block inside a "variable" block.

type Variables

type Variables map[string]*Variable

func (Variables) Keys

func (variables Variables) Keys() []string

func (Variables) Values

func (variables Variables) Values() (map[string]cty.Value, hcl.Diagnostics)

Directories

Path Synopsis
Package addrs contains types that represent "addresses", which are references to specific objects within a Packer configuration.
Package addrs contains types that represent "addresses", which are references to specific objects within a Packer configuration.

Jump to

Keyboard shortcuts

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