Skip to content

Commit

Permalink
Update README to reflect govendor vs godep
Browse files Browse the repository at this point in the history
  • Loading branch information
jen20 committed Jun 3, 2016
1 parent 8895b56 commit f91d870
Showing 1 changed file with 17 additions and 50 deletions.
67 changes: 17 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,77 +69,44 @@ $ 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.

#### 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.
To add a 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
1. Add the new package to your GOPATH:

# 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.
```bash
go get github.com/hashicorp/my-project
```

# Make a commit with your new dependencies added
git add -A
git commit -m "vendor: Capture new dependency upstream-pkg"
2. Add the new package to your vendor/ directory:

# Push to your branch (may need -f if you rebased)
git push origin my-feature-branch
```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
Expand Down

0 comments on commit f91d870

Please sign in to comment.