Skip to content

Commit d21b089

Browse files
committed
Makefile/docs: Lock in 1.6 req, doc vendored deps
* Drop Go 1.5 compatibility env vars * Drop `make updatedeps` from `Makefile` and docs * Update README w/ vendored dep instructions
1 parent 2a97e53 commit d21b089

File tree

4 files changed

+67
-34
lines changed

4 files changed

+67
-34
lines changed

BUILDING.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ vagrant ssh
4141
# The current "terraform" directory is then sync'd into the gopath
4242
cd /opt/gopath/src/github.com/hashicorp/terraform/
4343

44-
# Fetch dependencies
45-
make updatedeps
46-
4744
# Verify unit tests pass
4845
make test
4946

5047
# Build the release
5148
# This generates binaries for each platform and places them in the pkg folder
52-
make release
49+
make bin
5350
```
5451

5552
After running these commands, you should have binaries for all supported

Makefile

+10-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TEST?=$$(GO15VENDOREXPERIMENT=1 go list ./... | grep -v /vendor/)
1+
TEST?=$$(go list ./... | grep -v /vendor/)
22
VETARGS?=-all
33

44
default: test vet
@@ -19,7 +19,7 @@ quickdev: generate
1919
# changes will require a rebuild of everything, in which case the dev
2020
# target should be used.
2121
core-dev: fmtcheck generate
22-
GO15VENDOREXPERIMENT=1 go install github.com/hashicorp/terraform
22+
go install github.com/hashicorp/terraform
2323

2424
# Shorthand for quickly testing the core of Terraform (i.e. "not providers")
2525
core-test: generate
@@ -28,12 +28,12 @@ core-test: generate
2828
# Shorthand for building and installing just one plugin for local testing.
2929
# Run as (for example): make plugin-dev PLUGIN=provider-aws
3030
plugin-dev: fmtcheck generate
31-
GO15VENDOREXPERIMENT=1 go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN)
31+
go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN)
3232
mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN)
3333

3434
# test runs the unit tests
3535
test: fmtcheck generate
36-
TF_ACC= GO15VENDOREXPERIMENT=1 go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
36+
TF_ACC= go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
3737

3838
# testacc runs acceptance tests
3939
testacc: fmtcheck generate
@@ -42,30 +42,18 @@ testacc: fmtcheck generate
4242
echo " make testacc TEST=./builtin/providers/aws"; \
4343
exit 1; \
4444
fi
45-
TF_ACC=1 GO15VENDOREXPERIMENT=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
45+
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
4646

4747
# testrace runs the race checker
4848
testrace: fmtcheck generate
49-
TF_ACC= GO15VENDOREXPERIMENT=1 go test -race $(TEST) $(TESTARGS)
50-
51-
# updatedeps installs all the dependencies that Terraform needs to run
52-
# and build.
53-
updatedeps:
54-
go get -u github.com/mitchellh/gox
55-
go get -u golang.org/x/tools/cmd/stringer
56-
go list ./... \
57-
| xargs go list -f '{{join .Deps "\n"}}' \
58-
| grep -v github.com/hashicorp/terraform \
59-
| grep -v '/internal/' \
60-
| sort -u \
61-
| xargs go get -f -u -v
49+
TF_ACC= go test -race $(TEST) $(TESTARGS)
6250

6351
cover:
6452
@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
6553
go get -u golang.org/x/tools/cmd/cover; \
6654
fi
67-
GO15VENDOREXPERIMENT=1 go test $(TEST) -coverprofile=coverage.out
68-
GO15VENDOREXPERIMENT=1 go tool cover -html=coverage.out
55+
go test $(TEST) -coverprofile=coverage.out
56+
go tool cover -html=coverage.out
6957
rm coverage.out
7058

7159
# vet runs the Go source code static analysis tool `vet` to find
@@ -75,7 +63,7 @@ vet:
7563
go get golang.org/x/tools/cmd/vet; \
7664
fi
7765
@echo "go tool vet $(VETARGS) ."
78-
@GO15VENDOREXPERIMENT=1 go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \
66+
@go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \
7967
echo ""; \
8068
echo "Vet found suspicious constructs. Please check the reported constructs"; \
8169
echo "and fix them if necessary before submitting the code for review."; \
@@ -88,7 +76,7 @@ generate:
8876
@which stringer ; if [ $$? -ne 0 ]; then \
8977
go get -u golang.org/x/tools/cmd/stringer; \
9078
fi
91-
GO15VENDOREXPERIMENT=1 go generate $$(GO15VENDOREXPERIMENT=1 go list ./... | grep -v /vendor/)
79+
go generate $$(go list ./... | grep -v /vendor/)
9280

9381
fmt:
9482
gofmt -w .

README.md

+56-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ If you wish to work on Terraform itself or any of its built-in providers, you'll
3333

3434
For local dev first make sure Go is properly installed, including setting up a [GOPATH](http://golang.org/doc/code.html#GOPATH). You will also need to add `$GOPATH/bin` to your `$PATH`. Next, install the following software packages, which are needed for some dependencies:
3535

36-
- [Git](http://git-scm.com/)
37-
- [Mercurial](http://mercurial.selenic.com/)
38-
39-
Next, clone this repository into `$GOPATH/src/github.com/hashicorp/terraform` and run `make`. This will compile dependencies and run the tests. If this exits with exit status 0, then everything is working!
36+
Next, using [Git](https://git-scm.com/), clone this repository into `$GOPATH/src/github.com/hashicorp/terraform`. All the necessary dependencies are either vendored or automatically installed, so you just need to type `make`. This will compile the code and then run the tests. If this exits with exit status 0, then everything is working!
4037

4138
```sh
4239
$ make
@@ -70,6 +67,61 @@ If you're working on the core of Terraform, and only wish to rebuild that withou
7067
$ make core-dev
7168
```
7269

70+
### Dependencies
71+
72+
Terraform stores its dependencies under `vendor/`, which [Go 1.6+ will automatically recognize and load](https://golang.org/cmd/go/#hdr-Vendor_Directories). We use [`godep`](https://github.com/tools/godep) to manage the vendored dependencies.
73+
74+
If you're developing Terraform, there are a few tasks you might need to perform.
75+
76+
#### Adding a dependency
77+
78+
If you're adding a dependency. You'll need to vendor it in the same Pull Request as the code that depends on it. You should do this in a separate commit from your code, as makes PR review easier and Git history simpler to read in the future.
79+
80+
Because godep captures new dependencies from the local `$GOPATH`, you first need to `godep restore` from the master branch to ensure that the only diff is your new dependency.
81+
82+
Assuming your work is on a branch called `my-feature-branch`, the steps look like this:
83+
84+
```bash
85+
# Get latest master branch's dependencies staged in local $GOPATH
86+
git checkout master
87+
git pull
88+
godep restore -v # flag is optional, enables verbose output
89+
90+
# Capture the new dependency referenced from my-feature-branch
91+
git checkout my-feature-branch
92+
git rebase master
93+
godep save ./...
94+
95+
# There should now be a diff in `vendor/` with added files for your dependency,
96+
# and a diff in Godeps/Godeps.json with metadata for your dependency.
97+
98+
# Make a commit with your new dependencies added
99+
git add -A
100+
git commit -m "vendor: Capture new dependency upstream-pkg"
101+
102+
# Push to your branch (may need -f if you rebased)
103+
git push origin my-feature-branch
104+
```
105+
106+
#### Updating a dependency
107+
108+
If you're updating an existing dependency, godep provides a specific command to snag the newer version from your `$GOPATH`.
109+
110+
```bash
111+
# Update the dependncy to the version currently in your $GOPATH
112+
godep update github.com/some/dependency/...
113+
114+
# There should now be a diff in `vendor/` with changed files for your dependency,
115+
# and a diff in Godeps/Godeps.json with metadata for the updated dependency.
116+
117+
# Make a commit with the updated dependency
118+
git add -A
119+
git commit -m "vendor: Update dependency upstream-pkg to 1.4.6"
120+
121+
# Push to your branch
122+
git push origin my-feature-branch
123+
```
124+
73125
### Acceptance Tests
74126

75127
Terraform also has a comprehensive [acceptance test](http://en.wikipedia.org/wiki/Acceptance_testing) suite covering most of the major features of the built-in providers.

scripts/build.sh

-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
1818
XC_ARCH=${XC_ARCH:-"386 amd64 arm"}
1919
XC_OS=${XC_OS:-linux darwin windows freebsd openbsd solaris}
2020

21-
# Use vendored dependencies
22-
export GO15VENDOREXPERIMENT=1
23-
2421
# Delete the old dir
2522
echo "==> Removing old directory..."
2623
rm -f bin/*
2724
rm -rf pkg/*
2825
mkdir -p bin/
2926

30-
3127
# If its dev mode, only build for ourself
3228
if [ "${TF_DEV}x" != "x" ]; then
3329
XC_OS=$(go env GOOS)

0 commit comments

Comments
 (0)