@ -33,10 +33,7 @@ If you wish to work on Terraform itself or any of its built-in providers, you'll
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:
- [Git](http://git-scm.com/)
- [Mercurial](http://mercurial.selenic.com/)
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!
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!
```sh
$ make
@ -70,6 +67,61 @@ If you're working on the core of Terraform, and only wish to rebuild that withou
$ make core-dev
```
### Dependencies
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.
If you're developing Terraform, there are a few tasks you might need to perform.
#### Adding a dependency
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.
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.
Assuming your work is on a branch called `my-feature-branch`, the steps look like this:
```bash
# Get latest master branch's dependencies staged in local $GOPATH
git checkout master
git pull
godep restore -v # flag is optional, enables verbose output
# Capture the new dependency referenced from my-feature-branch
git checkout my-feature-branch
git rebase master
godep save ./...
# There should now be a diff in `vendor/` with added files for your dependency,
# and a diff in Godeps/Godeps.json with metadata for your dependency.
# Make a commit with your new dependencies added
git add -A
git commit -m "vendor: Capture new dependency upstream-pkg"
# Push to your branch (may need -f if you rebased)
git push origin my-feature-branch
```
#### Updating a dependency
If you're updating an existing dependency, godep provides a specific command to snag the newer version from your `$GOPATH`.
```bash
# Update the dependncy to the version currently in your $GOPATH
godep update github.com/some/dependency/...
# There should now be a diff in `vendor/` with changed files for your dependency,
# and a diff in Godeps/Godeps.json with metadata for the updated dependency.
# Make a commit with the updated dependency
git add -A
git commit -m "vendor: Update dependency upstream-pkg to 1.4.6"
# Push to your branch
git push origin my-feature-branch
```
### Acceptance Tests
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.