jsonnet

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: Apache-2.0 Imports: 19 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertObjectToMap

func ConvertObjectToMap(obj *astext.Object) (map[string]interface{}, error)

ConvertObjectToMap converts an object to a map.

func DecodeValue

func DecodeValue(s string) (interface{}, error)

DecodeValue decodes a string to an interface value. nolint: gocyclo

func FieldID

func FieldID(field astext.ObjectField) (string, error)

FieldID returns the id for an object field.

func FindObject

func FindObject(object *astext.Object, path []string) (*astext.Object, error)

FindObject finds a path in an object.

func HasField

func HasField(object *astext.Object, name string) bool

HasField returns true if the object has a field.

func Import

func Import(filename string) (*astext.Object, error)

Import imports jsonnet from a path.

func ImportFromFs

func ImportFromFs(filename string, fs afero.Fs) (*astext.Object, error)

ImportFromFs imports jsonnet object from a path on an afero filesystem.

func ImportNodeFromFs

func ImportNodeFromFs(filename string, fs afero.Fs) (ast.Node, error)

ImportNodeFromFs imports jsonnet node from a path on an afero filesystem.

func Parse

func Parse(filename, src string) (*astext.Object, error)

Parse converts a jsonnet snippet to AST Object.

func ParseNode

func ParseNode(filename, src string) (ast.Node, error)

ParseNode converts a jsonnet snippet to AST node.

func Set

func Set(object *astext.Object, path []string, value ast.Node) error

Set sets an object key at path to a value.

Types

type AferoImporter added in v0.12.0

type AferoImporter struct {
	FileImporter
	Fs afero.Fs
}

AferoImporter implements Importer using an afero Fs interface.

func (*AferoImporter) Import added in v0.12.0

func (ai *AferoImporter) Import(dir, importedPath string) (contents jsonnet.Contents, foundHere string, err error)

Import imports a file.

type FileImporter added in v0.12.0

type FileImporter struct {
	jsonnet.FileImporter
}

FileImporter extends jsonnet.FileImporter to allow incrementally adding import paths.

func (*FileImporter) AddJPath added in v0.12.0

func (f *FileImporter) AddJPath(paths ...string)

AddJPath adds the provided paths to the importer.

type Importer added in v0.12.0

type Importer interface {
	jsonnet.Importer

	AddJPath(paths ...string)
}

Importer extends jsonnet.Importer to support setting import paths.

type VM

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

VM is a ksonnet wrapper for the jsonnet VM.

func NewVM

func NewVM(opts ...VMOpt) *VM

NewVM creates an instance of VM.

func (*VM) AddFunctions added in v0.12.0

func (vm *VM) AddFunctions(fns ...*jsonnet.NativeFunction)

AddFunctions adds native functions to the Jsonnet VM.

func (*VM) AddJPath

func (vm *VM) AddJPath(paths ...string)

AddJPath adds JPaths to the jsonnet VM.

func (*VM) EvaluateSnippet

func (vm *VM) EvaluateSnippet(name, snippet string) (string, error)

EvaluateSnippet evaluates a jsonnet snippet.

func (*VM) ExtCode

func (vm *VM) ExtCode(key, value string)

ExtCode adds ExtCode to the jsonnet VM.

func (*VM) ExtVar

func (vm *VM) ExtVar(key, value string)

ExtVar adds ExtVar to the jsonnet VM.

func (*VM) TLACode

func (vm *VM) TLACode(key, value string)

TLACode adds TLACode to the jsonnet VM.

func (*VM) TLAVar

func (vm *VM) TLAVar(key, value string)

TLAVar adds TLAVar to the jsonnet VM.

type VMOpt

type VMOpt func(*VM)

VMOpt is an option for configuring VM.

func AferoImporterOpt added in v0.12.0

func AferoImporterOpt(fs afero.Fs) VMOpt

AferoImporterOpt configures a VM with a jsonnet.Importer

func ImporterOpt added in v0.12.0

func ImporterOpt(importer Importer) VMOpt

ImporterOpt configures a VM with a jsonnet.Importer

Jump to

Keyboard shortcuts

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