Documentation
¶
Overview ¶
Package vm allows flexible creation of a Jsonnet VM.
Index ¶
- type Code
- type Config
- type VM
- type Var
- type VariableSet
- func (vs VariableSet) HasTopLevelVar(name string) bool
- func (vs VariableSet) HasVar(name string) bool
- func (vs VariableSet) TopLevelVars() []Var
- func (vs VariableSet) Vars() []Var
- func (vs VariableSet) WithTopLevelVars(add ...Var) VariableSet
- func (vs VariableSet) WithVars(add ...Var) VariableSet
- func (vs VariableSet) WithoutTopLevel() VariableSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Code ¶ added in v0.14.0
type Code struct {
// contains filtered or unexported fields
}
Code wraps string to distinguish it from string file names
type Config ¶
type Config struct { LibPaths []string // library paths DataSources []importers.DataSource // data sources }
Config is the configuration of the VM
type VM ¶
type VM interface { // EvalFile evaluates the supplied file initializing the VM with the supplied variables // and returns its output as a JSON string. EvalFile(file string, v VariableSet) (string, error) // EvalCode evaluates the supplied code initializing the VM with the supplied variables // and returns its output as a JSON string. EvalCode(diagnosticFile string, code Code, v VariableSet) (string, error) // LintCode uses the jsonnet linter to lint the code and returns any errors LintCode(diagnosticFile string, code Code) error }
VM provides a narrow interface to the capabilities of a jsonnet VM.
type Var ¶ added in v0.14.0
type Var struct { Name string // contains filtered or unexported fields }
Var is an opaque variable to be initialized for the jsonnet VM
func NewCodeVar ¶ added in v0.14.0
NewCodeVar returns a variable that has a code value
type VariableSet ¶ added in v0.14.0
type VariableSet struct {
// contains filtered or unexported fields
}
VariableSet is an immutable set of variables to be registered with a jsonnet VM
func VariablesFromConfig ¶ added in v0.14.0
func VariablesFromConfig(config externals.Externals) VariableSet
VariablesFromConfig returns a variable set containing the user-supplied variables.
func (VariableSet) HasTopLevelVar ¶ added in v0.14.0
func (vs VariableSet) HasTopLevelVar(name string) bool
HasTopLevelVar returns true if the specified TLA variable is defined.
func (VariableSet) HasVar ¶ added in v0.14.0
func (vs VariableSet) HasVar(name string) bool
HasVar returns true if the specified external variable is defined.
func (VariableSet) TopLevelVars ¶ added in v0.14.0
func (vs VariableSet) TopLevelVars() []Var
TopLevelVars returns the string top-level variables defined for this variable set.
func (VariableSet) Vars ¶ added in v0.14.0
func (vs VariableSet) Vars() []Var
Vars returns the names of all variables defined for this variable set.
func (VariableSet) WithTopLevelVars ¶ added in v0.14.0
func (vs VariableSet) WithTopLevelVars(add ...Var) VariableSet
WithTopLevelVars returns a variable set with additional top-level string variables in its environment.
func (VariableSet) WithVars ¶ added in v0.14.0
func (vs VariableSet) WithVars(add ...Var) VariableSet
WithVars returns a variable set with additional variables in its environment.
func (VariableSet) WithoutTopLevel ¶ added in v0.14.0
func (vs VariableSet) WithoutTopLevel() VariableSet
WithoutTopLevel returns a variable set that does not have any top level variables set.