build: Run "go generate" in modules mode

It seems that all of the tools we run here are now sufficiently
modules-aware to run without problems in modules mode, and indeed running
_not_ in modules mode was causing problems with locating packages in
mockgen.
This commit is contained in:
Martin Atkins 2019-02-06 10:51:39 -08:00
parent 5946fd898e
commit a9274beaca
3 changed files with 14 additions and 6 deletions

View File

@ -73,11 +73,12 @@ cover:
# source files, except the protobuf stubs which are built instead with # source files, except the protobuf stubs which are built instead with
# "make protobuf". # "make protobuf".
generate: tools generate: tools
# We turn off modules for "go generate" because our downstream generate GOFLAGS=-mod=vendor go generate ./...
# commands are not all ready to deal with Go modules yet. # go fmt doesn't support -mod=vendor but it still wants to populate the
# See https://github.com/golang/go/issues/24661 # module cache with everything in go.mod even though formatting requires
# This also avoids downloading all of the deps that are in the vendor dir anyway. # no dependencies, and so we're disabling modules mode for this right
GO111MODULE=off go generate ./... # now until the "go fmt" behavior is rationalized to either support the
# -mod= argument or _not_ try to install things.
GO111MODULE=off go fmt command/internal_plugin_list.go > /dev/null GO111MODULE=off go fmt command/internal_plugin_list.go > /dev/null
# We separate the protobuf generation because most development tasks on # We separate the protobuf generation because most development tasks on

View File

@ -1,3 +1,3 @@
//go:generate mockgen -destination mock.go github.com/hashicorp/terraform/internal/tfplugin5 ProviderClient,ProvisionerClient,Provisioner_ProvisionResourceClient,Provisioner_ProvisionResourceServer //go:generate bash ./generate.sh
package mock_tfplugin5 package mock_tfplugin5

View File

@ -0,0 +1,7 @@
#!/bin/bash
# mockgen is particularly sensitive about what mode we run it in
export GOFLAGS=""
export GO111MODULE=on
mockgen -destination mock.go github.com/hashicorp/terraform/internal/tfplugin5 ProviderClient,ProvisionerClient,Provisioner_ProvisionResourceClient,Provisioner_ProvisionResourceServer