vm

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package vm allows flexible creation of a Jsonnet VM.

Index

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

func MakeCode added in v0.14.0

func MakeCode(s string) Code

MakeCode returns a code object from the supplied string.

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.

func New

func New(config Config) VM

New constructs a new VM based on the supplied config. The returned VM interface is safe for concurrent use.

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

func NewCodeVar(name, code string) Var

NewCodeVar returns a variable that has a code value

func NewVar added in v0.14.0

func NewVar(name, value string) Var

NewVar returns a variable that has a string 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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