You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+56-4
Original file line number
Diff line number
Diff line change
@@ -33,10 +33,7 @@ If you wish to work on Terraform itself or any of its built-in providers, you'll
33
33
34
34
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:
35
35
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!
40
37
41
38
```sh
42
39
$ make
@@ -70,6 +67,61 @@ If you're working on the core of Terraform, and only wish to rebuild that withou
70
67
$ make core-dev
71
68
```
72
69
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
+
73
125
### Acceptance Tests
74
126
75
127
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.
0 commit comments