Stackdriver / stackdriver-prometheus-sidecar

A sidecar for the Prometheus server that can send metrics to Stackdriver.
https://cloud.google.com/monitoring/kubernetes-engine/prometheus
Apache License 2.0
121 stars 43 forks source link

Cannot build within GOPATH: build flag -mod=vendor only valid when using modules #156

Closed roman-yepishev closed 5 years ago

roman-yepishev commented 5 years ago

Runing the build from within a GOPATH fails with:

:stackdriver-prometheus-sidecar (master)$ make docker
>> fetching promu
curl -s -L https://github.com/prometheus/promu/releases/download/v0.5.0/promu-0.5.0.linux-amd64.tar.gz | tar -xvzf - -C /tmp/tmp.zU4GpffJ6u
promu-0.5.0.linux-amd64/
promu-0.5.0.linux-amd64/promu
promu-0.5.0.linux-amd64/NOTICE
promu-0.5.0.linux-amd64/LICENSE
mkdir -p /home/rye/go/bin
cp /tmp/tmp.zU4GpffJ6u/promu-0.5.0.linux-amd64/promu /home/rye/go/bin/promu
rm -r /tmp/tmp.zU4GpffJ6u
>> building linux amd64 binaries
 >   stackdriver-prometheus-sidecar
build flag -mod=vendor only valid when using modules
!! command failed: build -o /home/rye/go/src/github.com/Stackdriver/stackdriver-prometheus-sidecar/stackdriver-prometheus-sidecar -ldflags -X github.com/Stackdriver/stackdriver-prometheus-sidecar/vendor/github.com/prometheus/common/version.Version=HEAD -X github.com/Stackdriver/stackdriver-prometheus-sidecar/vendor/github.com/prometheus/common/version.Revision=872c1b90aa8b2172f7aee766eeba5a3e921849b3 -X github.com/Stackdriver/stackdriver-prometheus-sidecar/vendor/github.com/prometheus/common/version.Branch=master -X github.com/Stackdriver/stackdriver-prometheus-sidecar/vendor/github.com/prometheus/common/version.BuildUser=rye@localhost -X github.com/Stackdriver/stackdriver-prometheus-sidecar/vendor/github.com/prometheus/common/version.BuildDate=20190827-22:07:23  -extldflags '-static' -mod=vendor -a -tags netgo github.com/Stackdriver/stackdriver-prometheus-sidecar/cmd/stackdriver-prometheus-sidecar: exit status 1
make: *** [Makefile:109: build-linux-amd64] Error 1

This appears to happen because GO111MODULE, while set in Makefile and used for deps target, is not propagated for other build steps.