Rename the ancillary packages from "zcl" to "hcl".

The main "zcl" package requires a bit more care because of how many
callers it has and because of its two subpackages, so we'll take care
of that one separately.
This commit is contained in:
Martin Atkins 2017-09-11 16:00:31 -07:00
parent 386f7134f1
commit 0dc3a6015c
39 changed files with 73 additions and 73 deletions

View File

@ -9,9 +9,9 @@ import (
"os"
"strings"
"github.com/hashicorp/hcl2/hclparse"
"github.com/hashicorp/hcl2/hclwrite"
"github.com/hashicorp/hcl2/zcl"
"github.com/hashicorp/hcl2/zclparse"
"github.com/hashicorp/hcl2/zclwrite"
"golang.org/x/crypto/ssh/terminal"
)
@ -24,7 +24,7 @@ var (
showVersion = flag.Bool("version", false, "show the version number and immediately exit")
)
var parser = zclparse.NewParser()
var parser = hclparse.NewParser()
var diagWr zcl.DiagnosticWriter // initialized in init
var checkErrs = false
var changed []string
@ -127,7 +127,7 @@ func processFile(fn string, in *os.File) error {
}
}
outSrc := zclwrite.Format(inSrc)
outSrc := hclwrite.Format(inSrc)
if !bytes.Equal(inSrc, outSrc) {
changed = append(changed, fn)

View File

@ -4,8 +4,8 @@ import (
"path/filepath"
"strings"
"github.com/hashicorp/hcl2/hclparse"
"github.com/hashicorp/hcl2/zcl"
"github.com/hashicorp/hcl2/zclparse"
)
// FileResolver creates and returns a Resolver that interprets include paths
@ -23,7 +23,7 @@ import (
// If the path given in configuration ends with ".json" then the referenced
// file is interpreted as JSON. Otherwise, it is interpreted as zcl native
// syntax.
func FileResolver(baseDir string, parser *zclparse.Parser) Resolver {
func FileResolver(baseDir string, parser *hclparse.Parser) Resolver {
return &fileResolver{
BaseDir: baseDir,
Parser: parser,
@ -32,7 +32,7 @@ func FileResolver(baseDir string, parser *zclparse.Parser) Resolver {
type fileResolver struct {
BaseDir string
Parser *zclparse.Parser
Parser *hclparse.Parser
}
func (r fileResolver) ResolveBodyPath(path string, refRange zcl.Range) (zcl.Body, zcl.Diagnostics) {

View File

@ -2,7 +2,7 @@ package include
import (
"github.com/hashicorp/hcl2/ext/transform"
"github.com/hashicorp/hcl2/gozcl"
"github.com/hashicorp/hcl2/gohcl"
"github.com/hashicorp/hcl2/zcl"
)
@ -69,7 +69,7 @@ func (t *transformer) TransformBody(in zcl.Body) zcl.Body {
pathExpr := incContent.Attributes["path"].Expr
var path string
incDiags = gozcl.DecodeExpression(pathExpr, t.Ctx, &path)
incDiags = gohcl.DecodeExpression(pathExpr, t.Ctx, &path)
diags = append(diags, incDiags...)
if incDiags.HasErrors() {
continue

View File

@ -5,36 +5,36 @@ import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/hcl2/gozcl"
"github.com/hashicorp/hcl2/gohcl"
"github.com/hashicorp/hcl2/hcltest"
"github.com/hashicorp/hcl2/zcl"
"github.com/hashicorp/hcl2/zcltest"
"github.com/zclconf/go-cty/cty"
)
func TestTransformer(t *testing.T) {
caller := zcltest.MockBody(&zcl.BodyContent{
caller := hcltest.MockBody(&zcl.BodyContent{
Blocks: zcl.Blocks{
{
Type: "include",
Body: zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"path": zcltest.MockExprVariable("var_path"),
Body: hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"path": hcltest.MockExprVariable("var_path"),
}),
}),
},
{
Type: "include",
Body: zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"path": zcltest.MockExprLiteral(cty.StringVal("include2")),
Body: hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"path": hcltest.MockExprLiteral(cty.StringVal("include2")),
}),
}),
},
{
Type: "foo",
Body: zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"from": zcltest.MockExprLiteral(cty.StringVal("caller")),
Body: hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"from": hcltest.MockExprLiteral(cty.StringVal("caller")),
}),
}),
},
@ -42,25 +42,25 @@ func TestTransformer(t *testing.T) {
})
resolver := MapResolver(map[string]zcl.Body{
"include1": zcltest.MockBody(&zcl.BodyContent{
"include1": hcltest.MockBody(&zcl.BodyContent{
Blocks: zcl.Blocks{
{
Type: "foo",
Body: zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"from": zcltest.MockExprLiteral(cty.StringVal("include1")),
Body: hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"from": hcltest.MockExprLiteral(cty.StringVal("include1")),
}),
}),
},
},
}),
"include2": zcltest.MockBody(&zcl.BodyContent{
"include2": hcltest.MockBody(&zcl.BodyContent{
Blocks: zcl.Blocks{
{
Type: "foo",
Body: zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"from": zcltest.MockExprLiteral(cty.StringVal("include2")),
Body: hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"from": hcltest.MockExprLiteral(cty.StringVal("include2")),
}),
}),
},
@ -84,7 +84,7 @@ func TestTransformer(t *testing.T) {
Foos []foo `zcl:"foo,block"`
}
var got result
diags := gozcl.DecodeBody(merged, nil, &got)
diags := gohcl.DecodeBody(merged, nil, &got)
if len(diags) != 0 {
t.Errorf("unexpected diags")
for _, diag := range diags {

View File

@ -5,8 +5,8 @@ import (
"reflect"
"github.com/hashicorp/hcl2/hcltest"
"github.com/hashicorp/hcl2/zcl"
"github.com/hashicorp/hcl2/zcltest"
"github.com/zclconf/go-cty/cty"
)
@ -27,9 +27,9 @@ func TestDeep(t *testing.T) {
return BodyWithDiagnostics(remain, diags)
})
src := zcltest.MockBody(&zcl.BodyContent{
Attributes: zcltest.MockAttrs(map[string]zcl.Expression{
"true": zcltest.MockExprLiteral(cty.True),
src := hcltest.MockBody(&zcl.BodyContent{
Attributes: hcltest.MockAttrs(map[string]zcl.Expression{
"true": hcltest.MockExprLiteral(cty.True),
}),
Blocks: []*zcl.Block{
{
@ -38,7 +38,7 @@ func TestDeep(t *testing.T) {
},
{
Type: "child",
Body: zcltest.MockBody(&zcl.BodyContent{
Body: hcltest.MockBody(&zcl.BodyContent{
Blocks: []*zcl.Block{
{
Type: "remove",
@ -70,8 +70,8 @@ func TestDeep(t *testing.T) {
}
}
wantAttrs := zcltest.MockAttrs(map[string]zcl.Expression{
"true": zcltest.MockExprLiteral(cty.True),
wantAttrs := hcltest.MockAttrs(map[string]zcl.Expression{
"true": hcltest.MockExprLiteral(cty.True),
})
if !reflect.DeepEqual(rootContent.Attributes, wantAttrs) {
t.Errorf("wrong root attributes\ngot: %#v\nwant: %#v", rootContent.Attributes, wantAttrs)

View File

@ -1,7 +1,7 @@
package userfunc
import (
"github.com/hashicorp/hcl2/gozcl"
"github.com/hashicorp/hcl2/gohcl"
"github.com/hashicorp/hcl2/zcl"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/function"
@ -72,13 +72,13 @@ func decodeUserFunctions(body zcl.Body, blockType string, contextFunc ContextFun
var params []string
var varParam string
paramsDiags := gozcl.DecodeExpression(paramsExpr, nil, &params)
paramsDiags := gohcl.DecodeExpression(paramsExpr, nil, &params)
diags = append(diags, paramsDiags...)
if paramsDiags.HasErrors() {
continue
}
if varParamExpr != nil {
paramsDiags := gozcl.DecodeExpression(varParamExpr, nil, &varParam)
paramsDiags := gohcl.DecodeExpression(varParamExpr, nil, &varParam)
diags = append(diags, paramsDiags...)
if paramsDiags.HasErrors() {
continue

View File

@ -1,4 +1,4 @@
package gozcl
package gohcl
import (
"fmt"

View File

@ -1,4 +1,4 @@
package gozcl
package gohcl
import (
"encoding/json"

View File

@ -46,4 +46,4 @@
// is bugs in the calling program, such as invalid struct tags, which are
// surfaced via panics since there can be no useful runtime handling of such
// errors and they should certainly not be returned to the user as diagnostics.
package gozcl
package gohcl

View File

@ -1,4 +1,4 @@
package gozcl
package gohcl
import (
"fmt"

View File

@ -1,4 +1,4 @@
package gozcl
package gohcl
import (
"fmt"

View File

@ -1,4 +1,4 @@
package gozcl
package gohcl
import (
"reflect"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"github.com/hashicorp/hcl2/zcl"

View File

@ -9,4 +9,4 @@
// package, which has a similar purpose but decodes directly into native
// Go data types. zcldec instead targets the cty type system, and thus allows
// a cty-driven application to remain within that type system.
package zcldec
package hcldec

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"encoding/gob"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"github.com/hashicorp/hcl2/zcl"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"fmt"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"github.com/hashicorp/hcl2/zcl"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"fmt"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
// Verify that all of our spec types implement the necessary interfaces
var objectSpecAsSpec Spec = ObjectSpec(nil)

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"github.com/hashicorp/hcl2/zcl"

View File

@ -1,4 +1,4 @@
package zcldec
package hcldec
import (
"fmt"

View File

@ -1,4 +1,4 @@
// Package zcled provides functionality intended to help an application
// that embeds zcl to deliver relevant information to a text editor or IDE
// for navigating around and analyzing configuration files.
package zcled
package hcled

View File

@ -1,4 +1,4 @@
package zcled
package hcled
import (
"github.com/hashicorp/hcl2/zcl"

View File

@ -1,4 +1,4 @@
package zclparse
package hclparse
import (
"fmt"

View File

@ -3,4 +3,4 @@
//
// This package is intended for use only in test code. It is optimized for
// convenience of use over all other concerns.
package zcltest
package hcltest

View File

@ -1,4 +1,4 @@
package zcltest
package hcltest
import (
"fmt"

View File

@ -1,4 +1,4 @@
package zcltest
package hcltest
import (
"testing"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"bytes"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"fmt"

View File

@ -4,4 +4,4 @@
// It operates at a different level of abstraction that the main zcl parser
// and AST, since details such as the placement of comments and newlines
// are preserved when unchanged.
package zclwrite
package hclwrite

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"github.com/hashicorp/hcl2/zcl/zclsyntax"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"fmt"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"github.com/hashicorp/hcl2/zcl/zclsyntax"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"sort"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"fmt"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"bytes"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"bytes"

View File

@ -1,4 +1,4 @@
package zclwrite
package hclwrite
import (
"bytes"