jsonnet

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Evaluate

func Evaluate(path, data string, opts Opts) (string, error)

Evaluate renders the given jsonnet into a string If cache options are given, a hash from the data will be computed and

the resulting string will be cached for future retrieval

func EvaluateFile

func EvaluateFile(jsonnetFile string, opts Opts) (string, error)

EvaluateFile evaluates the Jsonnet code in the given file and returns the result in JSON form. It disregards opts.ImportPaths in favor of automatically resolving these according to the specified file.

func MakeVM added in v0.12.0

func MakeVM(opts Opts) *jsonnet.VM

MakeVM returns a Jsonnet VM with some extensions of Tanka, including: - extended importer - extCode and tlaCode applied - native functions registered

func TransitiveImports

func TransitiveImports(dir string) ([]string, error)

TransitiveImports returns all recursive imports of an environment

Types

type ExtendedImporter added in v0.6.0

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

ExtendedImporter wraps jsonnet.FileImporter to add additional functionality: - `import "file.yaml"` - `import "tk"`

func NewExtendedImporter added in v0.6.0

func NewExtendedImporter(jpath []string) *ExtendedImporter

NewExtendedImporter returns a new instance of ExtendedImporter with the correct jpaths set up

func (*ExtendedImporter) Import added in v0.6.0

func (i *ExtendedImporter) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import implements the functionality offered by the ExtendedImporter

type FileEvalCache added in v0.18.0

type FileEvalCache struct {
	Directory string
}

FileEvalCache is an evaluation cache that stores its data on the local filesystem

func NewFileEvalCache added in v0.18.0

func NewFileEvalCache(cachePath string) *FileEvalCache

func (*FileEvalCache) Get added in v0.18.0

func (c *FileEvalCache) Get(hash string) (string, error)

func (*FileEvalCache) Store added in v0.18.0

func (c *FileEvalCache) Store(hash, content string) error

type InjectedCode added in v0.12.0

type InjectedCode map[string]string

InjectedCode holds data that is "late-bound" into the VM

func (*InjectedCode) Set added in v0.12.0

func (i *InjectedCode) Set(key, value string)

Set allows to set values on an InjectedCode, even when it is nil

type Modifier added in v0.7.0

type Modifier func(vm *jsonnet.VM) error

Modifier allows to set optional parameters on the Jsonnet VM. See jsonnet.With* for this.

type Opts added in v0.12.0

type Opts struct {
	ExtCode     InjectedCode
	TLACode     InjectedCode
	ImportPaths []string
	EvalScript  string
	CachePath   string

	CachePathRegexes []*regexp.Regexp
}

Opts are additional properties for the Jsonnet VM

func (Opts) Clone added in v0.14.0

func (o Opts) Clone() Opts

Clone returns a deep copy of Opts

func (Opts) PathIsCached added in v0.18.0

func (opts Opts) PathIsCached(path string) bool

PathIsCached determines if a given path is matched by any of the configured cached path regexes If no path regexes are defined, all paths are matched

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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