Update README to reflect govendor vs godep

This commit is contained in:
James Nugent 2016-06-02 23:10:58 -05:00
parent 8895b567f4
commit f91d870537
1 changed files with 19 additions and 52 deletions

View File

@ -69,13 +69,7 @@ $ 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.
Generally speaking, `godep` operations follow this pattern:
1. Get current state of dependencies into your `$GOPATH` with `godep restore`.
2. Make changes to the packages in `$GOPATH`.
3. Tell `godep` to capture those changes in the Terraform repo.
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 [`govendor`](https://github.com/kardianos/govendor) to manage the vendored dependencies.
If you're developing Terraform, there are a few tasks you might need to perform.
@ -83,63 +77,36 @@ If you're developing Terraform, there are a few tasks you might need to perform.
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.
To add a dependency:
Assuming your work is on a branch called `my-feature-branch`, the steps look like this:
1. Add the new package to your GOPATH:
```bash
# Get latest master branch's dependencies staged in local $GOPATH
git checkout master
git pull
godep restore -v
# 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
go get github.com/hashicorp/my-project
```
2. Add the new package to your vendor/ directory:
```bash
govendor add github.com/hashicorp/my-project/package
```
3. Review the changes in git and commit them.
#### Updating a dependency
If you're updating an existing dependency, godep provides a specific command to snag the newer version from your `$GOPATH`.
To update a dependency:
1. Fetch the dependency:
```bash
# Get latest master branch's dependencies staged in local $GOPATH
git checkout master
git pull
godep restore -v
# Make your way to the dependency in question and checkout the target ref
pushd $GOPATH/src/github.com/some/dependency
git checkout v-1.next
# Head back to Terraform on a feature branch and update the dependncy to the
# version currently in your $GOPATH
popd
git checkout my-feature-branch
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
govendor fetch github.com/hashicorp/my-project
```
2. Review the changes in git and commit them.
### Acceptance Tests
Terraform has a comprehensive [acceptance