summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Atkins <mart@degeneration.co.uk>2017-09-11 17:29:56 -0700
committerMartin Atkins <mart@degeneration.co.uk>2017-09-11 17:29:56 -0700
commitbdf1e7c6e63d505dd4564aebb89f7dfd85728f81 (patch)
tree8c83151470d23858ae127c089932fedb66f33e62
parentb8b5e0be6dbd5129c12602f5e851f088b6d8ade8 (diff)
gohcl: rename struct tag prefix from "zcl:" to "hcl:"
-rw-r--r--ext/include/transformer_test.go6
-rw-r--r--gohcl/decode_test.go114
-rw-r--r--gohcl/doc.go2
-rw-r--r--gohcl/schema.go6
-rw-r--r--gohcl/schema_test.go42
5 files changed, 85 insertions, 85 deletions
diff --git a/ext/include/transformer_test.go b/ext/include/transformer_test.go
index 99a344b..fba73fe 100644
--- a/ext/include/transformer_test.go
+++ b/ext/include/transformer_test.go
@@ -6,8 +6,8 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/hcl2/gohcl"
- "github.com/hashicorp/hcl2/hcltest"
"github.com/hashicorp/hcl2/hcl"
+ "github.com/hashicorp/hcl2/hcltest"
"github.com/zclconf/go-cty/cty"
)
@@ -78,10 +78,10 @@ func TestTransformer(t *testing.T) {
merged := transformer.TransformBody(caller)
type foo struct {
- From string `zcl:"from,attr"`
+ From string `hcl:"from,attr"`
}
type result struct {
- Foos []foo `zcl:"foo,block"`
+ Foos []foo `hcl:"foo,block"`
}
var got result
diags := gohcl.DecodeBody(merged, nil, &got)
diff --git a/gohcl/decode_test.go b/gohcl/decode_test.go
index cf10733..a41c231 100644
--- a/gohcl/decode_test.go
+++ b/gohcl/decode_test.go
@@ -7,8 +7,8 @@ import (
"testing"
"github.com/davecgh/go-spew/spew"
- zclJSON "github.com/hashicorp/hcl2/hcl/json"
"github.com/hashicorp/hcl2/hcl"
+ zclJSON "github.com/hashicorp/hcl2/hcl/json"
"github.com/zclconf/go-cty/cty"
)
@@ -34,20 +34,20 @@ func TestDecodeBody(t *testing.T) {
{
map[string]interface{}{},
struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{},
deepEquals(struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{}),
1, // name is required
},
{
map[string]interface{}{},
struct {
- Name *string `zcl:"name"`
+ Name *string `hcl:"name"`
}{},
deepEquals(struct {
- Name *string `zcl:"name"`
+ Name *string `hcl:"name"`
}{}),
0,
},
@@ -56,10 +56,10 @@ func TestDecodeBody(t *testing.T) {
"name": "Ermintrude",
},
struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{},
deepEquals(struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{"Ermintrude"}),
0,
},
@@ -69,10 +69,10 @@ func TestDecodeBody(t *testing.T) {
"age": 23,
},
struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{},
deepEquals(struct {
- Name string `zcl:"name"`
+ Name string `hcl:"name"`
}{"Ermintrude"}),
1, // Extraneous "age" property
},
@@ -82,13 +82,13 @@ func TestDecodeBody(t *testing.T) {
"age": 50,
},
struct {
- Name string `zcl:"name"`
- Attrs hcl.Attributes `zcl:",remain"`
+ Name string `hcl:"name"`
+ Attrs hcl.Attributes `hcl:",remain"`
}{},
func(gotI interface{}) bool {
got := gotI.(struct {
- Name string `zcl:"name"`
- Attrs hcl.Attributes `zcl:",remain"`
+ Name string `hcl:"name"`
+ Attrs hcl.Attributes `hcl:",remain"`
})
return got.Name == "Ermintrude" && len(got.Attrs) == 1 && got.Attrs["age"] != nil
},
@@ -100,13 +100,13 @@ func TestDecodeBody(t *testing.T) {
"age": 50,
},
struct {
- Name string `zcl:"name"`
- Remain hcl.Body `zcl:",remain"`
+ Name string `hcl:"name"`
+ Remain hcl.Body `hcl:",remain"`
}{},
func(gotI interface{}) bool {
got := gotI.(struct {
- Name string `zcl:"name"`
- Remain hcl.Body `zcl:",remain"`
+ Name string `hcl:"name"`
+ Remain hcl.Body `hcl:",remain"`
})
attrs, _ := got.Remain.JustAttributes()
@@ -121,12 +121,12 @@ func TestDecodeBody(t *testing.T) {
"age": 51,
},
struct {
- Name string `zcl:"name"`
- Remain map[string]cty.Value `zcl:",remain"`
+ Name string `hcl:"name"`
+ Remain map[string]cty.Value `hcl:",remain"`
}{},
deepEquals(struct {
- Name string `zcl:"name"`
- Remain map[string]cty.Value `zcl:",remain"`
+ Name string `hcl:"name"`
+ Remain map[string]cty.Value `hcl:",remain"`
}{
Name: "Ermintrude",
Remain: map[string]cty.Value{
@@ -140,7 +140,7 @@ func TestDecodeBody(t *testing.T) {
"noodle": map[string]interface{}{},
},
struct {
- Noodle struct{} `zcl:"noodle,block"`
+ Noodle struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating no diagnostics is good enough for this one.
@@ -153,7 +153,7 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}},
},
struct {
- Noodle struct{} `zcl:"noodle,block"`
+ Noodle struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating no diagnostics is good enough for this one.
@@ -166,7 +166,7 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}, {}},
},
struct {
- Noodle struct{} `zcl:"noodle,block"`
+ Noodle struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating one diagnostic is good enough for this one.
@@ -177,7 +177,7 @@ func TestDecodeBody(t *testing.T) {
{
map[string]interface{}{},
struct {
- Noodle struct{} `zcl:"noodle,block"`
+ Noodle struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating one diagnostic is good enough for this one.
@@ -190,7 +190,7 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{},
},
struct {
- Noodle struct{} `zcl:"noodle,block"`
+ Noodle struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating one diagnostic is good enough for this one.
@@ -203,11 +203,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": map[string]interface{}{},
},
struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
return gotI.(struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}).Noodle != nil
},
0,
@@ -217,11 +217,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}},
},
struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
return gotI.(struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}).Noodle != nil
},
0,
@@ -231,11 +231,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{},
},
struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
return gotI.(struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}).Noodle == nil
},
0,
@@ -245,7 +245,7 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}, {}},
},
struct {
- Noodle *struct{} `zcl:"noodle,block"`
+ Noodle *struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating one diagnostic is good enough for this one.
@@ -258,11 +258,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{},
},
struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodle := gotI.(struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}).Noodle
return len(noodle) == 0
},
@@ -273,11 +273,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}},
},
struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodle := gotI.(struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}).Noodle
return len(noodle) == 1
},
@@ -288,11 +288,11 @@ func TestDecodeBody(t *testing.T) {
"noodle": []map[string]interface{}{{}, {}},
},
struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodle := gotI.(struct {
- Noodle []struct{} `zcl:"noodle,block"`
+ Noodle []struct{} `hcl:"noodle,block"`
}).Noodle
return len(noodle) == 2
},
@@ -304,8 +304,8 @@ func TestDecodeBody(t *testing.T) {
},
struct {
Noodle struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// Generating two diagnostics is good enough for this one.
@@ -324,14 +324,14 @@ func TestDecodeBody(t *testing.T) {
},
struct {
Noodle struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodle := gotI.(struct {
Noodle struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}).Noodle
return noodle.Name == "foo_foo"
},
@@ -346,8 +346,8 @@ func TestDecodeBody(t *testing.T) {
},
struct {
Noodle struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
// One diagnostic is enough for this one.
@@ -364,14 +364,14 @@ func TestDecodeBody(t *testing.T) {
},
struct {
Noodles []struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodles := gotI.(struct {
Noodles []struct {
- Name string `zcl:"name,label"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"noodle,block"`
}).Noodles
return len(noodles) == 2 && (noodles[0].Name == "foo_foo" || noodles[0].Name == "bar_baz") && (noodles[1].Name == "foo_foo" || noodles[1].Name == "bar_baz") && noodles[0].Name != noodles[1].Name
},
@@ -387,16 +387,16 @@ func TestDecodeBody(t *testing.T) {
},
struct {
Noodle struct {
- Name string `zcl:"name,label"`
- Type string `zcl:"type"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ Type string `hcl:"type"`
+ } `hcl:"noodle,block"`
}{},
func(gotI interface{}) bool {
noodle := gotI.(struct {
Noodle struct {
- Name string `zcl:"name,label"`
- Type string `zcl:"type"`
- } `zcl:"noodle,block"`
+ Name string `hcl:"name,label"`
+ Type string `hcl:"type"`
+ } `hcl:"noodle,block"`
}).Noodle
return noodle.Name == "foo_foo" && noodle.Type == "rice"
},
diff --git a/gohcl/doc.go b/gohcl/doc.go
index 6535416..8500214 100644
--- a/gohcl/doc.go
+++ b/gohcl/doc.go
@@ -7,7 +7,7 @@
// A struct field tag scheme is used, similar to other decoding and
// unmarshalling libraries. The tags are formatted as in the following example:
//
-// ThingType string `zcl:"thing_type,attr"`
+// ThingType string `hcl:"thing_type,attr"`
//
// Within each tag there are two comma-separated tokens. The first is the
// name of the corresponding construct in configuration, while the second
diff --git a/gohcl/schema.go b/gohcl/schema.go
index 3d5801f..c110773 100644
--- a/gohcl/schema.go
+++ b/gohcl/schema.go
@@ -66,7 +66,7 @@ func ImpliedBodySchema(val interface{}) (schema *hcl.BodySchema, partial bool) {
}
if fty.Kind() != reflect.Struct {
panic(fmt.Sprintf(
- "zcl 'block' tag kind cannot be applied to %s field %s: struct required", field.Type.String(), field.Name,
+ "hcl 'block' tag kind cannot be applied to %s field %s: struct required", field.Type.String(), field.Name,
))
}
ftags := getFieldTags(fty)
@@ -113,7 +113,7 @@ func getFieldTags(ty reflect.Type) *fieldTags {
ct := ty.NumField()
for i := 0; i < ct; i++ {
field := ty.Field(i)
- tag := field.Tag.Get("zcl")
+ tag := field.Tag.Get("hcl")
if tag == "" {
continue
}
@@ -145,7 +145,7 @@ func getFieldTags(ty reflect.Type) *fieldTags {
idx := i // copy, because this loop will continue assigning to i
ret.Remain = &idx
default:
- panic(fmt.Sprintf("invalid zcl field tag kind %q on %s %q", kind, field.Type.String(), field.Name))
+ panic(fmt.Sprintf("invalid hcl field tag kind %q on %s %q", kind, field.Type.String(), field.Name))
}
}
diff --git a/gohcl/schema_test.go b/gohcl/schema_test.go
index df75630..0c7b0ae 100644
--- a/gohcl/schema_test.go
+++ b/gohcl/schema_test.go
@@ -29,8 +29,8 @@ func TestImpliedBodySchema(t *testing.T) {
},
{
struct {
- Attr1 bool `zcl:"attr1"`
- Attr2 bool `zcl:"attr2"`
+ Attr1 bool `hcl:"attr1"`
+ Attr2 bool `hcl:"attr2"`
}{},
&hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
@@ -48,7 +48,7 @@ func TestImpliedBodySchema(t *testing.T) {
},
{
struct {
- Attr *bool `zcl:"attr,attr"`
+ Attr *bool `hcl:"attr,attr"`
}{},
&hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
@@ -62,7 +62,7 @@ func TestImpliedBodySchema(t *testing.T) {
},
{
struct {
- Thing struct{} `zcl:"thing,block"`
+ Thing struct{} `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
@@ -76,9 +76,9 @@ func TestImpliedBodySchema(t *testing.T) {
{
struct {
Thing struct {
- Type string `zcl:"type,label"`
- Name string `zcl:"name,label"`
- } `zcl:"thing,block"`
+ Type string `hcl:"type,label"`
+ Name string `hcl:"name,label"`
+ } `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
@@ -93,9 +93,9 @@ func TestImpliedBodySchema(t *testing.T) {
{
struct {
Thing []struct {
- Type string `zcl:"type,label"`
- Name string `zcl:"name,label"`
- } `zcl:"thing,block"`
+ Type string `hcl:"type,label"`
+ Name string `hcl:"name,label"`
+ } `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
@@ -110,9 +110,9 @@ func TestImpliedBodySchema(t *testing.T) {
{
struct {
Thing *struct {
- Type string `zcl:"type,label"`
- Name string `zcl:"name,label"`
- } `zcl:"thing,block"`
+ Type string `hcl:"type,label"`
+ Name string `hcl:"name,label"`
+ } `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
@@ -127,9 +127,9 @@ func TestImpliedBodySchema(t *testing.T) {
{
struct {
Thing struct {
- Name string `zcl:"name,label"`
- Something string `zcl:"something"`
- } `zcl:"thing,block"`
+ Name string `hcl:"name,label"`
+ Something string `hcl:"something"`
+ } `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Blocks: []hcl.BlockHeaderSchema{
@@ -143,10 +143,10 @@ func TestImpliedBodySchema(t *testing.T) {
},
{
struct {
- Doodad string `zcl:"doodad"`
+ Doodad string `hcl:"doodad"`
Thing struct {
- Name string `zcl:"name,label"`
- } `zcl:"thing,block"`
+ Name string `hcl:"name,label"`
+ } `hcl:"thing,block"`
}{},
&hcl.BodySchema{
Attributes: []hcl.AttributeSchema{
@@ -166,8 +166,8 @@ func TestImpliedBodySchema(t *testing.T) {
},
{
struct {
- Doodad string `zcl:"doodad"`
- Config string `zcl:",remain"`
+ Doodad string `hcl:"doodad"`
+ Config string `hcl:",remain"`
}{},
&hcl.BodySchema{
Attributes: []hcl.AttributeSchema{