jsonnet

package module
v0.0.0-...-3db50c1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: MIT Imports: 3 Imported by: 0

README

jsonnet_cgo

Simple golang cgo wrapper around JSonnet VM.

Everything in libjsonnet.h is covered except the multi-file evaluators.

See jsonnet_test.go for how to use it.

Quick example:

    vm := jsonnet.Make()
    vm.ExtVar("color", "purple")

    x, err := vm.EvaluateSnippet(`Test_Demo`, `"dark " + std.extVar("color")`)

    if err != nil {
            panic(err)
    }
    if x != "\"dark purple\"\n" {
            panic("fail: we got " + x)
    }

    vm.Destroy()

Documentation

Overview

jsonnet is a simple Go wrapper for the JSonnet VM.

See http://jsonnet.org/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Evaluate a file containing Jsonnet code, return a JSON string.

Types

type ImportCallback

type ImportCallback func(base, rel string) (result string, path string, err error)

type VM

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

func Make

func Make() *VM

Create a new Jsonnet virtual machine.

func (*VM) Destroy

func (vm *VM) Destroy()

Complement of Make().

func (*VM) EvaluateFile

func (vm *VM) EvaluateFile(filename string) (string, error)

Evaluate a file containing Jsonnet code, return a JSON string.

func (*VM) EvaluateSnippet

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

Evaluate a string containing Jsonnet code, return a JSON string.

func (*VM) ExtCode

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

Bind a Jsonnet external var to the given Jsonnet code.

func (*VM) ExtVar

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

Bind a Jsonnet external var to the given value.

func (*VM) FormatFile

func (vm *VM) FormatFile(filename string) (string, error)

Format a file containing Jsonnet code, return a JSON string.

func (*VM) FormatIndent

func (vm *VM) FormatIndent(n int)

Indentation level when reformatting (number of spaces)

func (*VM) FormatSnippet

func (vm *VM) FormatSnippet(filename, snippet string) (string, error)

Format a string containing Jsonnet code, return a JSON string.

func (*VM) GcGrowthTrigger

func (vm *VM) GcGrowthTrigger(v float64)

Run the garbage collector after this amount of growth in the number of objects.

func (*VM) GcMinObjects

func (vm *VM) GcMinObjects(v uint)

Set the number of objects required before a garbage collection cycle is allowed.

func (*VM) ImportCallback

func (vm *VM) ImportCallback(f ImportCallback)

Override the callback used to locate imports.

func (*VM) JpathAdd

func (vm *VM) JpathAdd(path string)

Add to the default import callback's library search path.

func (*VM) MaxStack

func (vm *VM) MaxStack(v uint)

Set the maximum stack depth.

func (*VM) MaxTrace

func (vm *VM) MaxTrace(v uint)

Set the number of lines of stack trace to display (0 for all of them).

func (*VM) StringOutput

func (vm *VM) StringOutput(v bool)

Expect a string as output and don't JSON encode it.

func (*VM) TlaCode

func (vm *VM) TlaCode(key, val string)

Bind a Jsonnet top-level argument to the given Jsonnet code.

func (*VM) TlaVar

func (vm *VM) TlaVar(key, val string)

Bind a Jsonnet top-level argument to the given value.

Directories

Path Synopsis
Command line tool to try evaluating JSonnet.
Command line tool to try evaluating JSonnet.

Jump to

Keyboard shortcuts

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