moved JSON handlers and extension code around a bit for proper order of

initialization
This commit is contained in:
Chris Baker
2021-03-22 14:12:42 +00:00
parent ca51bd91bd
commit 0cd707e3a9
12 changed files with 86 additions and 57 deletions

View File

@@ -6,13 +6,14 @@ import (
"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/hcl"
"github.com/hashicorp/hcl/hcl/ast"
"github.com/hashicorp/nomad/helper/pluginutils/hclspecutils"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/plugins/shared/hclspec"
"github.com/mitchellh/mapstructure"
"github.com/stretchr/testify/require"
"github.com/zclconf/go-cty/cty"
"github.com/hashicorp/nomad/helper/pluginutils/hclspecutils"
"github.com/hashicorp/nomad/nomad/json/handlers"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/plugins/shared/hclspec"
)
type HCLParser struct {
@@ -121,7 +122,7 @@ func JsonConfigToInterface(t *testing.T, config string) interface{} {
t.Helper()
// Decode from json
dec := codec.NewDecoderBytes([]byte(config), structs.JsonHandle)
dec := codec.NewDecoderBytes([]byte(config), handlers.JsonHandle)
var m map[string]interface{}
err := dec.Decode(&m)

View File

@@ -9,7 +9,9 @@ import (
hcl "github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hcldec"
hjson "github.com/hashicorp/hcl/v2/json"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/nomad/json/handlers"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/function"
"github.com/zclconf/go-cty/cty/function/stdlib"
@@ -26,7 +28,7 @@ func ParseHclInterface(val interface{}, spec hcldec.Spec, vars map[string]cty.Va
// Encode to json
var buf bytes.Buffer
enc := codec.NewEncoder(&buf, structs.JsonHandle)
enc := codec.NewEncoder(&buf, handlers.JsonHandle)
err := enc.Encode(val)
if err != nil {
// Convert to a hcl diagnostics message