Back to godoc.org

Package hclutils

v0.10.4
Latest Go to latest

The latest major version is .

Published: Feb 19, 2020 | License: MPL-2.0 | Module: github.com/greut/nomad

Index

func GetStdlibFuncs

func GetStdlibFuncs() map[string]function.Function

GetStdlibFuncs returns the set of stdlib functions.

func HclConfigToInterface

func HclConfigToInterface(t *testing.T, config string) interface{}

func JsonConfigToInterface

func JsonConfigToInterface(t *testing.T, config string) interface{}

func ParseHclInterface

func ParseHclInterface(val interface{}, spec hcldec.Spec, vars map[string]cty.Value) (cty.Value, hcl.Diagnostics, []error)

ParseHclInterface is used to convert an interface value representing a hcl2 body and return the interpolated value. Vars may be nil if there are no variables to interpolate.

type HCLParser

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

func NewConfigParser

func NewConfigParser(spec *hclspec.Spec) *HCLParser

NewConfigParser return a helper for parsing drivers TaskConfig Parser is an immutable object can be used in multiple tests

func (*HCLParser) ParseHCL

func (b *HCLParser) ParseHCL(t *testing.T, configStr string, out interface{})

ParseHCL parses the hcl config string and decode it into the `out` parameter. out parameter should be a golang reference to a driver specific TaskConfig reference. The function terminates and reports errors if any is found during conversion.

Sample invocation would be

``` var tc *TaskConfig hclutils.NewConfigParser(spec).ParseHCL(t, configString, &tc) ```

func (*HCLParser) ParseJson

func (b *HCLParser) ParseJson(t *testing.T, configStr string, out interface{})

ParseJson parses the json config string and decode it into the `out` parameter. out parameter should be a golang reference to a driver specific TaskConfig reference. The function terminates and reports errors if any is found during conversion.

Sample invocation would be

``` var tc *TaskConfig hclutils.NewConfigParser(spec).ParseJson(t, configString, &tc) ```

func (*HCLParser) WithVars

func (b *HCLParser) WithVars(vars map[string]cty.Value) *HCLParser

WithVars returns a new parser that uses passed vars when interpolated strings in config

type MapStrInt

type MapStrInt map[string]int

MapStrInt is a wrapper for map[string]int that handles deserialization from different hcl2 json representation that were supported in Nomad 0.8

func (*MapStrInt) CodecDecodeSelf

func (s *MapStrInt) CodecDecodeSelf(dec *codec.Decoder)

func (*MapStrInt) CodecEncodeSelf

func (s *MapStrInt) CodecEncodeSelf(enc *codec.Encoder)

type MapStrStr

type MapStrStr map[string]string

MapStrStr is a wrapper for map[string]string that handles deserialization from different hcl2 json representation that were supported in Nomad 0.8

func (*MapStrStr) CodecDecodeSelf

func (s *MapStrStr) CodecDecodeSelf(dec *codec.Decoder)

func (*MapStrStr) CodecEncodeSelf

func (s *MapStrStr) CodecEncodeSelf(enc *codec.Encoder)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier