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" "os"
"strings" "strings"
"github.com/hashicorp/hcl2/hclparse"
"github.com/hashicorp/hcl2/hclwrite"
"github.com/hashicorp/hcl2/zcl" "github.com/hashicorp/hcl2/zcl"
"github.com/hashicorp/hcl2/zclparse"
"github.com/hashicorp/hcl2/zclwrite"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )
@ -24,7 +24,7 @@ var (
showVersion = flag.Bool("version", false, "show the version number and immediately exit") 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 diagWr zcl.DiagnosticWriter // initialized in init
var checkErrs = false var checkErrs = false
var changed []string 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) { if !bytes.Equal(inSrc, outSrc) {
changed = append(changed, fn) changed = append(changed, fn)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,4 +46,4 @@
// is bugs in the calling program, such as invalid struct tags, which are // 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 // 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. // 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 ( import (
"fmt" "fmt"

View File

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

View File

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

View File

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

View File

@ -9,4 +9,4 @@
// package, which has a similar purpose but decodes directly into native // package, which has a similar purpose but decodes directly into native
// Go data types. zcldec instead targets the cty type system, and thus allows // Go data types. zcldec instead targets the cty type system, and thus allows
// a cty-driven application to remain within that type system. // 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 ( import (
"encoding/gob" "encoding/gob"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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