diff --git a/hcl/json/public.go b/hcl/json/public.go index 8d4b052..27d4c5c 100644 --- a/hcl/json/public.go +++ b/hcl/json/public.go @@ -88,28 +88,3 @@ func ParseFile(filename string) (*hcl.File, hcl.Diagnostics) { return Parse(src, filename) } - -// ParseWithHIL is like Parse except the returned file will use the HIL -// template syntax for expressions in strings, rather than the native zcl -// template syntax. -// -// This is intended for providing backward compatibility for applications that -// used to use HCL/HIL and thus had a JSON-based format with HIL -// interpolations. -func ParseWithHIL(src []byte, filename string) (*hcl.File, hcl.Diagnostics) { - file, diags := Parse(src, filename) - if file != nil && file.Body != nil { - file.Body.(*body).useHIL = true - } - return file, diags -} - -// ParseFileWithHIL is like ParseWithHIL but it reads data from a file before -// parsing it. -func ParseFileWithHIL(filename string) (*hcl.File, hcl.Diagnostics) { - file, diags := ParseFile(filename) - if file != nil && file.Body != nil { - file.Body.(*body).useHIL = true - } - return file, diags -} diff --git a/hcl/json/public_test.go b/hcl/json/public_test.go index 859873e..16ea0bb 100644 --- a/hcl/json/public_test.go +++ b/hcl/json/public_test.go @@ -95,30 +95,3 @@ func TestParseTemplateUnwrap(t *testing.T) { t.Errorf("wrong result %#v; want %#v", val, cty.True) } } - -func TestParseTemplateWithHIL(t *testing.T) { - src := `{"greeting": "hello ${\"world\"}"}` - file, diags := ParseWithHIL([]byte(src), "") - if len(diags) != 0 { - t.Errorf("got %d diagnostics on parse; want 0", len(diags)) - } - if file == nil { - t.Errorf("got nil File; want actual file") - } - if file.Body == nil { - t.Fatalf("got nil Body; want actual body") - } - attrs, diags := file.Body.JustAttributes() - if len(diags) != 0 { - t.Errorf("got %d diagnostics on decode; want 0", len(diags)) - } - - val, diags := attrs["greeting"].Expr.Value(&hcl.EvalContext{}) - if len(diags) != 0 { - t.Errorf("got %d diagnostics on eval; want 0", len(diags)) - } - - if !val.RawEquals(cty.StringVal("hello world")) { - t.Errorf("wrong result %#v; want %#v", val, cty.StringVal("hello world")) - } -} diff --git a/hcl/json/structure.go b/hcl/json/structure.go index d039811..2899382 100644 --- a/hcl/json/structure.go +++ b/hcl/json/structure.go @@ -17,12 +17,6 @@ type body struct { // be treated as non-existing. This is used when Body.PartialContent is // called, to produce the "remaining content" Body. hiddenAttrs map[string]struct{} - - // If set, string values are turned into expressions using HIL's template - // language, rather than the native zcl language. This is intended to - // allow applications moving from HCL to zcl to continue to parse the - // JSON variant of their config that HCL handled previously. - useHIL bool } // expression is the implementation of "Expression" used for files processed @@ -133,7 +127,6 @@ func (b *body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Bod unusedBody := &body{ obj: b.obj, hiddenAttrs: usedNames, - useHIL: b.useHIL, } return content, unusedBody, diags @@ -219,8 +212,7 @@ func (b *body) unpackBlock(v node, typeName string, typeRange *hcl.Range, labels Type: typeName, Labels: labels, Body: &body{ - obj: tv, - useHIL: b.useHIL, + obj: tv, }, DefRange: tv.OpenRange, @@ -245,8 +237,7 @@ func (b *body) unpackBlock(v node, typeName string, typeRange *hcl.Range, labels Type: typeName, Labels: labels, Body: &body{ - obj: ov, - useHIL: b.useHIL, + obj: ov, }, DefRange: tv.OpenRange,