Skip to content

Commit 0497582

Browse files
committed
Remove all traces of libucl
1 parent 47ddd19 commit 0497582

File tree

6 files changed

+34
-627
lines changed

6 files changed

+34
-627
lines changed

Makefile

+7-42
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,34 @@
1-
CGO_CFLAGS:=-I$(CURDIR)/vendor/libucl/include
2-
CGO_LDFLAGS:=-L$(CURDIR)/vendor/libucl
3-
LIBUCL_NAME=libucl.a
41
TEST?=./...
52

6-
# Windows-only
7-
ifeq ($(OS), Windows_NT)
8-
# The Libucl library is named libucl.dll
9-
LIBUCL_NAME=libucl.dll
10-
11-
# Add the current directory on the path so the DLL is available.
12-
export PATH := $(CURDIR):$(PATH)
13-
endif
14-
15-
export CGO_CFLAGS CGO_LDFLAGS PATH
16-
173
default: test
184

19-
bin: config/y.go libucl
5+
bin: config/y.go
206
@sh -c "$(CURDIR)/scripts/build.sh"
217

22-
dev: config/y.go libucl
8+
dev: config/y.go
239
@TF_DEV=1 sh -c "$(CURDIR)/scripts/build.sh"
2410

25-
libucl: vendor/libucl/$(LIBUCL_NAME)
26-
27-
test: config/y.go libucl
11+
test: config/y.go
2812
TF_ACC= go test $(TEST) $(TESTARGS) -timeout=10s
2913

30-
testacc: config/y.go libucl
14+
testacc: config/y.go
3115
@if [ "$(TEST)" = "./..." ]; then \
3216
echo "ERROR: Set TEST to a specific package"; \
3317
exit 1; \
3418
fi
3519
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 30m
3620

37-
testrace: config/y.go libucl
21+
testrace: config/y.go
3822
TF_ACC= go test -race $(TEST) $(TESTARGS)
3923

40-
updatedeps: config/y.go libucl
24+
updatedeps: config/y.go
4125
go get -u -v ./...
4226

4327
config/y.go: config/expr.y
4428
cd config/ && \
4529
go tool yacc -p "expr" expr.y
4630

47-
vendor/libucl/libucl.a: vendor/libucl
48-
cd vendor/libucl && \
49-
cmake cmake/ && \
50-
make
51-
52-
vendor/libucl/libucl.dll: vendor/libucl
53-
cd vendor/libucl && \
54-
$(MAKE) -f Makefile.w32 && \
55-
cp .obj/libucl.dll . && \
56-
cp libucl.dll $(CURDIR)
57-
58-
vendor/libucl:
59-
rm -rf vendor/libucl
60-
mkdir -p vendor/libucl
61-
git clone https://github.com/hashicorp/libucl.git vendor/libucl
62-
cd vendor/libucl && \
63-
git checkout fix-win32-compile
64-
6531
clean:
6632
rm config/y.go
67-
rm -rf vendor
6833

69-
.PHONY: clean default libucl test updatedeps
34+
.PHONY: clean default test updatedeps

command/flag_var.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package command
22

33
import (
44
"fmt"
5+
"io/ioutil"
56
"strings"
67

7-
"github.com/mitchellh/go-libucl"
8+
"github.com/hashicorp/hcl"
89
)
910

1011
// FlagVar is a flag.Value implementation for parsing user variables
@@ -55,25 +56,23 @@ func (v *FlagVarFile) Set(raw string) error {
5556
return nil
5657
}
5758

58-
const libuclParseFlags = libucl.ParserNoTime
59-
6059
func loadVarFile(path string) (map[string]string, error) {
61-
var obj *libucl.Object
62-
63-
parser := libucl.NewParser(libuclParseFlags)
64-
err := parser.AddFile(path)
65-
if err == nil {
66-
obj = parser.Object()
67-
defer obj.Close()
60+
// Read the HCL file and prepare for parsing
61+
d, err := ioutil.ReadFile(path)
62+
if err != nil {
63+
return nil, fmt.Errorf(
64+
"Error reading %s: %s", path, err)
6865
}
69-
defer parser.Close()
7066

67+
// Parse it
68+
obj, err := hcl.Parse(string(d))
7169
if err != nil {
72-
return nil, err
70+
return nil, fmt.Errorf(
71+
"Error parsing %s: %s", path, err)
7372
}
7473

7574
var result map[string]string
76-
if err := obj.Decode(&result); err != nil {
75+
if err := hcl.DecodeObject(&result, obj); err != nil {
7776
return nil, err
7877
}
7978

config.go

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package main
22

33
import (
4+
"fmt"
5+
"io/ioutil"
46
"os/exec"
57
"path/filepath"
68

9+
"github.com/hashicorp/hcl"
710
"github.com/hashicorp/terraform/plugin"
811
"github.com/hashicorp/terraform/rpc"
912
"github.com/hashicorp/terraform/terraform"
10-
"github.com/mitchellh/go-libucl"
1113
"github.com/mitchellh/osext"
1214
)
1315

@@ -27,10 +29,6 @@ var BuiltinConfig Config
2729
// ContextOpts are the global ContextOpts we use to initialize the CLI.
2830
var ContextOpts terraform.ContextOpts
2931

30-
// Put the parse flags we use for libucl in a constant so we can get
31-
// equally behaving parsing everywhere.
32-
const libuclParseFlags = libucl.ParserNoTime
33-
3432
func init() {
3533
BuiltinConfig.Providers = map[string]string{
3634
"aws": "terraform-provider-aws",
@@ -49,26 +47,23 @@ func init() {
4947

5048
// LoadConfig loads the CLI configuration from ".terraformrc" files.
5149
func LoadConfig(path string) (*Config, error) {
52-
var obj *libucl.Object
53-
54-
// Parse the file and get the root object.
55-
parser := libucl.NewParser(libuclParseFlags)
56-
err := parser.AddFile(path)
57-
if err == nil {
58-
obj = parser.Object()
59-
defer obj.Close()
50+
// Read the HCL file and prepare for parsing
51+
d, err := ioutil.ReadFile(path)
52+
if err != nil {
53+
return nil, fmt.Errorf(
54+
"Error reading %s: %s", path, err)
6055
}
61-
defer parser.Close()
6256

63-
// If there was an error parsing, return now.
57+
// Parse it
58+
obj, err := hcl.Parse(string(d))
6459
if err != nil {
65-
return nil, err
60+
return nil, fmt.Errorf(
61+
"Error parsing %s: %s", path, err)
6662
}
6763

6864
// Build up the result
6965
var result Config
70-
71-
if err := obj.Decode(&result); err != nil {
66+
if err := hcl.DecodeObject(&result, obj); err != nil {
7267
return nil, err
7368
}
7469

0 commit comments

Comments
 (0)