Skip to content

Commit

Permalink
Rename the ancillary packages from "zcl" to "hcl".
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apparentlymart committed Sep 11, 2017
1 parent 386f713 commit 0dc3a60
Show file tree
Hide file tree
Showing 39 changed files with 73 additions and 73 deletions.
8 changes: 4 additions & 4 deletions cmd/zclfmt/main.go → cmd/hclfmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ext/include/file_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions ext/include/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions ext/include/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,62 @@ 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")),
}),
}),
},
},
})

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")),
}),
}),
},
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions ext/transform/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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{
{
Expand All @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ext/userfunc/decode.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gozcl/decode.go → gohcl/decode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gozcl
package gohcl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion gozcl/decode_test.go → gohcl/decode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gozcl
package gohcl

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion gozcl/doc.go → gohcl/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gozcl/schema.go → gohcl/schema.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gozcl
package gohcl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion gozcl/schema_test.go → gohcl/schema_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gozcl
package gohcl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion gozcl/types.go → gohcl/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gozcl
package gohcl

import (
"reflect"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/decode.go → hcldec/decode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"github.com/hashicorp/hcl2/zcl"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/doc.go → hcldec/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion zcldec/gob.go → hcldec/gob.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"encoding/gob"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/public.go → hcldec/public.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"github.com/hashicorp/hcl2/zcl"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/public_test.go → hcldec/public_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/schema.go → hcldec/schema.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"github.com/hashicorp/hcl2/zcl"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/spec.go → hcldec/spec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/spec_test.go → hcldec/spec_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

// Verify that all of our spec types implement the necessary interfaces
var objectSpecAsSpec Spec = ObjectSpec(nil)
Expand Down
2 changes: 1 addition & 1 deletion zcldec/variables.go → hcldec/variables.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"github.com/hashicorp/hcl2/zcl"
Expand Down
2 changes: 1 addition & 1 deletion zcldec/variables_test.go → hcldec/variables_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcldec
package hcldec

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zcled/doc.go → hcled/doc.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion zcled/navigation.go → hcled/navigation.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcled
package hcled

import (
"github.com/hashicorp/hcl2/zcl"
Expand Down
2 changes: 1 addition & 1 deletion zclparse/parser.go → hclparse/parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zclparse
package hclparse

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zcltest/doc.go → hcltest/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion zcltest/mock.go → hcltest/mock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcltest
package hcltest

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zcltest/mock_test.go → hcltest/mock_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zcltest
package hcltest

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion zclwrite/ast.go → hclwrite/ast.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zclwrite
package hclwrite

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion zclwrite/ast_test.go → hclwrite/ast_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zclwrite
package hclwrite

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion zclwrite/doc.go → hclwrite/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion zclwrite/format.go → hclwrite/format.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zclwrite
package hclwrite

import (
"github.com/hashicorp/hcl2/zcl/zclsyntax"
Expand Down
2 changes: 1 addition & 1 deletion zclwrite/format_test.go → hclwrite/format_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zclwrite
package hclwrite

import (
"fmt"
Expand Down
Loading

0 comments on commit 0dc3a60

Please sign in to comment.