mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
167f455277
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: #2063 Signed-off-by: Patrick East <east.patrick@gmail.com>
35 lines
736 B
Bash
35 lines
736 B
Bash
#!/usr/bin/env bash
|
|
|
|
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
|
|
done
|
|
}
|
|
|
|
function opa::go_files_in_package() {
|
|
dir=$(go list -f '{{ .Dir }}' $1)
|
|
for file in $(go list -f '{{ join .GoFiles "\n" }}' $1); do
|
|
echo $dir/$file
|
|
done
|
|
for file in $(go list -f '{{ join .TestGoFiles "\n" }}' $1); do
|
|
echo $dir/$file
|
|
done
|
|
}
|
|
|
|
function opa::all_go_files() {
|
|
FILES=""
|
|
for pkg in $(opa::go_packages); do
|
|
for file in $(opa::go_files_in_package $pkg); do
|
|
FILES+=" ${file}"
|
|
done
|
|
done
|
|
echo "${FILES}"
|
|
}
|