hclutils

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MPL-2.0 Imports: 19 Imported by: 116

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

Types

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)

Jump to

Keyboard shortcuts

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