Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "remove vendor directory, update makefile" #6356

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
28 changes: 28 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ For more details on Magic Modules please visit [the readme](/~https://github.com/G

Fields that are only available in beta versions of the Google Cloud Platform API will need to be added only to the `google-beta` provider and excluded from the `google` provider. When adding beta features or resources you will need to use templating to exclude them from generating into the ga version. Look for `*.erb` files in [resources](/~https://github.com/GoogleCloudPlatform/magic-modules/tree/master/third_party/terraform/resources) for examples.

## Vendoring Libraries

When adding support for just-released GCP features, you'll often need to vendor a new version of the Google API client.
The Google provider uses Go Modules; use the commands listed below and the new dependencies will be included in your PR.

```bash
GO111MODULE=on go get {{dependency}}
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
```

If you're developing against Magic Modules, vendoring changes needs to be done against each of the providers Magic Modules builds. At time of writing, that's this provider (`google`) and [`google-beta`](/~https://github.com/terraform-providers/terraform-provider-google-beta).

### Adding a new package

While `go get` / `go.mod` specify dependencies at the repo level, `go mod vendor` works at the package level. It will only vendor packages that are currently being used in the codebase. Google's API client libs use a separate package per GCP product, making adding new products a little awkward.

In order to create a separate vendoring PR including a new library:

1. Stage your changes in the provider repo
* If using Magic Modules, generate into the provider repo and temporarily commit your changes there in a feature branch
* If developing directly in the repo, commit all your staged changes to your feature branch
1. Run the normal vendoring commands above and commit the changes to a new commit
1. Create a vendoring branch (off `master`) to stage your vendoring PR from
1. Cherry-pick the vendoring commit from your feature branch into the vendoring branch
1. Make the vendoring PR
1. Revert the vendoring changes in your feature branch

## Tests

### Running Tests
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
run:
deadline: 2m30s
modules-download-mode: vendor

issues:
max-per-linter: 0
Expand Down
7 changes: 5 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
TEST?=$$(go list ./...)
TEST?=$$(go list ./... |grep -v 'vendor')
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=google

GO111MODULE=on
GOFLAGS=-mod=vendor

default: build

build: fmtcheck generate
go install

test: fmtcheck generate
go test $(TESTARGS) -timeout=30s -parallel=4 $(TEST)
go test -i $(TEST) || exit 1
echo $(TEST) | \
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc: fmtcheck generate
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test $(TEST) -v $(TESTARGS) -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"
Expand Down
Loading