Skip to content

Commit

Permalink
build: Force module mode and using only the vendor directory
Browse files Browse the repository at this point in the history
There are a handful of scripts that were making `go run` calls without
the required environment vars setup force go to use modules and only
use the vendor directory.

For golang 1.11/12 if OPA was in a path outside of the GOPATH it would
switch into module mode automatically (by default) and then try to
fetch packages and stuff remotely rather than use the vendor dir.

For golang 1.13+ any directory for OPA would (by default) result in
trying to use the remote modules rather than vendor dir.

Fixes: open-policy-agent#2063
Signed-off-by: Patrick East <[email protected]>
  • Loading branch information
patrick-east committed Feb 7, 2020
1 parent d4c708c commit 78eef06
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/gen-opa-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

GOOS="" GOARCH="" go run $@
GOFLAGS=-mod=vendor GO111MODULE=on GOOS="" GOARCH="" go run $@
2 changes: 1 addition & 1 deletion build/run-goimports.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

GOOS="" GOARCH="" go run ./vendor/golang.org/x/tools/cmd/goimports -local github.com/open-policy-agent/opa $@
GOFLAGS=-mod=vendor GO111MODULE=on GOOS="" GOARCH="" go run ./vendor/golang.org/x/tools/cmd/goimports -local github.com/open-policy-agent/opa $@
2 changes: 1 addition & 1 deletion build/run-pigeon.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

GOOS="" GOARCH="" go run ./vendor/github.com/mna/pigeon $@
GOFLAGS=-mod=vendor GO111MODULE=on GOOS="" GOARCH="" go run ./vendor/github.com/mna/pigeon $@
3 changes: 3 additions & 0 deletions build/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -o errexit
set -o pipefail
set -o nounset

export GO111MODULE=on
export GOFLAGS=-mod=vendor

function opa::go_packages() {
for pkg in $(go list ./.../ 2>/dev/null | grep -v vendor); do
echo $pkg
Expand Down

0 comments on commit 78eef06

Please sign in to comment.