Skip to content

Commit 6469da9

Browse files
authored
Updated dependencies. (#143)
* Switched to go mod
1 parent d5e162f commit 6469da9

File tree

3,174 files changed

+770723
-544384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,174 files changed

+770723
-544384
lines changed

.promu.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
verbose: false
2+
go:
3+
version: 1.12.0
4+
cgo: false
15
repository:
26
path: github.com/Stackdriver/stackdriver-prometheus-sidecar
37
build:
48
binaries:
59
- name: stackdriver-prometheus-sidecar
610
path: ./cmd/stackdriver-prometheus-sidecar
7-
flags: -a -tags netgo
11+
flags: -mod=vendor -a -tags netgo
812
ldflags: |
913
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
1014
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}

.travis.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
language: go
2-
script: make goveralls
2+
3+
go:
4+
- 1.12.x
5+
6+
go_import_path: github.com/Stackdriver/stackdriver-prometheus-sidecar
7+
8+
# Skip dependency fetch. We store all dependencies under vendor/.
9+
install: true
10+
11+
# make goveralls runs all tests as well.
12+
script:
13+
- make goveralls
14+
# TODO(jkohen): `make goveralls` is causing a diff in go.mod. Prevent that and uncomment the line below.
15+
#- git diff --exit-code
16+
317
# Contains tokens for Coveralls. See https://docs.coveralls.io/go
418
env:
519
global:

Makefile

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,34 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14+
# Ensure GOBIN is not set during build so that promu is installed to the correct path
15+
unexport GOBIN
16+
1417
GO ?= go
1518
GOFMT ?= $(GO)fmt
1619
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
20+
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
21+
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
22+
23+
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
24+
GO111MODULE := on
25+
# Always use the local vendor/ directory to satisfy the dependencies.
26+
GOOPTS := $(GOOPTS) -mod=vendor
27+
1728
PROMU := $(FIRST_GOPATH)/bin/promu
1829
STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
1930
GOVERALLS := $(FIRST_GOPATH)/bin/goveralls
20-
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
31+
pkgs = ./...
32+
33+
ifeq (arm, $(GOHOSTARCH))
34+
GOHOSTARM ?= $(shell GOARM= $(GO) env GOARM)
35+
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v$(GOHOSTARM)
36+
else
37+
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
38+
endif
39+
40+
PROMU_VERSION ?= 0.5.0
41+
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
2142

2243
PREFIX ?= $(shell pwd)
2344
BIN_DIR ?= $(shell pwd)
@@ -40,41 +61,48 @@ check_license:
4061
@echo ">> checking license header"
4162
@./scripts/check_license.sh
4263

43-
# TODO(fabxc): example tests temporarily removed.
64+
deps:
65+
@echo ">> getting dependencies"
66+
ifdef GO111MODULE
67+
GO111MODULE=$(GO111MODULE) $(GO) mod download
68+
else
69+
$(GO) get $(GOOPTS) -t ./...
70+
endif
71+
4472
test-short:
4573
@echo ">> running short tests"
46-
@$(GO) test -short $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
74+
$(GO) test -short $(GOOPTS) $(pkgs)
4775

4876
test:
4977
@echo ">> running all tests"
50-
@$(GO) test $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
78+
$(GO) test $(GOOPTS) $(pkgs)
5179

5280
cover:
5381
@echo ">> running all tests with coverage"
54-
@$(GO) test -coverprofile=coverage.out $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
82+
$(GO) test -coverprofile=coverage.out $(GOOPTS) $(pkgs)
5583

5684
format:
5785
@echo ">> formatting code"
58-
@$(GO) fmt $(pkgs)
86+
$(GO) fmt $(pkgs)
5987

6088
vet:
6189
@echo ">> vetting code"
62-
@$(GO) vet $(pkgs)
90+
$(GO) vet $(GOOPTS) $(pkgs)
6391

6492
staticcheck: $(STATICCHECK)
6593
@echo ">> running staticcheck"
66-
@$(STATICCHECK) $(pkgs)
94+
$(STATICCHECK) $(pkgs)
6795

6896
goveralls: cover $(GOVERALLS)
6997
ifndef COVERALLS_TOKEN
7098
$(error COVERALLS_TOKEN is undefined, follow https://docs.coveralls.io/go to create one and go to https://coveralls.io to retrieve existing ones)
7199
endif
72100
@echo ">> running goveralls"
73-
@$(GOVERALLS) -coverprofile=coverage.out -service=travis-ci -repotoken "${COVERALLS_TOKEN}"
101+
$(GOVERALLS) -coverprofile=coverage.out -service=travis-ci -repotoken "${COVERALLS_TOKEN}"
74102

75103
build: promu
76104
@echo ">> building binaries"
77-
@$(PROMU) build --prefix $(PREFIX)
105+
$(PROMU) build --prefix $(PREFIX)
78106

79107
build-linux-amd64: promu
80108
@echo ">> building linux amd64 binaries"
@@ -86,29 +114,30 @@ tarball: promu
86114

87115
docker: build-linux-amd64
88116
@echo ">> building docker image"
89-
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
117+
docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
90118

91119
push: test docker
92120
@echo ">> pushing docker image"
93121
docker push "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)"
94122

95123
assets:
96124
@echo ">> writing assets"
97-
@$(GO) get -u github.com/jteeuwen/go-bindata/...
98-
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
99-
@$(GO) fmt ./web/ui
125+
$(GO) get -u github.com/jteeuwen/go-bindata/...
126+
go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
127+
$(GO) fmt ./web/ui
100128

101129
promu:
102130
@echo ">> fetching promu"
103-
@GOOS=$(shell uname -s | tr A-Z a-z) \
104-
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
105-
GO="$(GO)" \
106-
$(GO) get -u github.com/prometheus/promu
131+
$(eval PROMU_TMP := $(shell mktemp -d))
132+
curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
133+
mkdir -p $(FIRST_GOPATH)/bin
134+
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
135+
rm -r $(PROMU_TMP)
107136

108137
$(FIRST_GOPATH)/bin/staticcheck:
109-
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
138+
GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
110139

111140
$(FIRST_GOPATH)/bin/goveralls:
112-
@GOOS= GOARCH= $(GO) get -u github.com/mattn/goveralls
141+
GOOS= GOARCH= $(GO) get -u github.com/mattn/goveralls
113142

114-
.PHONY: all style check_license format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck goveralls $(FIRST_GOPATH)/bin/goveralls
143+
.PHONY: all style check_license deps format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck goveralls $(FIRST_GOPATH)/bin/goveralls

cmd/stackdriver-prometheus-sidecar/main.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"time"
3232

3333
md "cloud.google.com/go/compute/metadata"
34+
oc_prometheus "contrib.go.opencensus.io/exporter/prometheus"
3435
oc_stackdriver "contrib.go.opencensus.io/exporter/stackdriver"
3536
"github.com/Stackdriver/stackdriver-prometheus-sidecar/metadata"
3637
"github.com/Stackdriver/stackdriver-prometheus-sidecar/retrieval"
@@ -53,7 +54,6 @@ import (
5354
"github.com/prometheus/prometheus/pkg/textparse"
5455
"github.com/prometheus/prometheus/promql"
5556
"github.com/prometheus/prometheus/scrape"
56-
oc_prometheus "go.opencensus.io/exporter/prometheus"
5757
"go.opencensus.io/plugin/ocgrpc"
5858
"go.opencensus.io/plugin/ochttp"
5959
"go.opencensus.io/stats/view"
@@ -196,8 +196,7 @@ type mainConfig struct {
196196
UseRestrictedIPs bool
197197
manualResolver *manual.Resolver
198198
MonitoringBackends []string
199-
200-
LogLevel promlog.AllowedLevel
199+
PromlogConfig promlog.Config
201200
}
202201

203202
func main() {
@@ -269,7 +268,7 @@ func main() {
269268
a.Flag("filter", "PromQL-style matcher for a single label which must pass for a series to be forwarded to Stackdriver. If repeated, the series must pass all filters to be forwarded. Deprecated, please use --include instead.").
270269
StringsVar(&cfg.Filters)
271270

272-
promlogflag.AddFlags(a, &cfg.LogLevel)
271+
promlogflag.AddFlags(a, &cfg.PromlogConfig)
273272

274273
_, err := a.Parse(os.Args[1:])
275274
if err != nil {
@@ -278,7 +277,7 @@ func main() {
278277
os.Exit(2)
279278
}
280279

281-
logger := promlog.New(cfg.LogLevel)
280+
logger := promlog.New(&cfg.PromlogConfig)
282281
if cfg.ConfigFilename != "" {
283282
cfg.MetricRenames, cfg.StaticMetadata, cfg.Aggregations, err = parseConfigFile(cfg.ConfigFilename)
284283
if err != nil {
@@ -365,11 +364,13 @@ func main() {
365364
// to resolve GCP API calls to the resolver.
366365
cfg.manualResolver, _ = manual.GenerateAndRegisterManualResolver()
367366
// These IP addresses correspond to restricted.googleapis.com and are not expected to change.
368-
cfg.manualResolver.InitialAddrs([]resolver.Address{
369-
{Addr: "199.36.153.4:443"},
370-
{Addr: "199.36.153.5:443"},
371-
{Addr: "199.36.153.6:443"},
372-
{Addr: "199.36.153.7:443"},
367+
cfg.manualResolver.InitialState(resolver.State{
368+
Addresses: []resolver.Address{
369+
{Addr: "199.36.153.4:443"},
370+
{Addr: "199.36.153.5:443"},
371+
{Addr: "199.36.153.6:443"},
372+
{Addr: "199.36.153.7:443"},
373+
},
373374
})
374375
}
375376
targetsURL, err := cfg.PrometheusURL.Parse(targets.DefaultAPIEndpoint)

cmd/stackdriver-prometheus-sidecar/statusz-tmpl.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ <h1>Parsed configuration</h1>
6969
<tr><th>Kubernetes labels: cluster name</th><td>{{.KubernetesLabels.ClusterName}}</td></tr>
7070
<tr><th>Kubernetes labels: location</th><td>{{.KubernetesLabels.Location}}</td></tr>
7171
<tr><th>Listen address</th><td>{{.ListenAddress}}</td></tr>
72-
<tr><th>Log level</th><td>{{.LogLevel.String}}</td></tr>
72+
<tr><th>Log level</th><td>{{.PromlogConfig.Level}}</td></tr>
73+
<tr><th>Log format</th><td>{{.PromlogConfig.Format}}</td></tr>
7374
<tr><th>Metrics prefix</th><td>{{.MetricsPrefix}}</td></tr>
7475
<tr><th>Monitoring backends</th><td>{{.MonitoringBackends}}</td></tr>
7576
<tr><th>Project ID resource</th><td>{{.ProjectIDResource}}</td></tr>

cmd/stackdriver-prometheus-sidecar/statusz_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func TestStatuszHandler(t *testing.T) {
5858

5959
matcher, _ := labels.NewMatcher(labels.MatchEqual, "k", "v")
6060

61-
var logLevel promlog.AllowedLevel
62-
logLevel.Set("debug")
61+
logConfig := promlog.Config{Level: &promlog.AllowedLevel{}}
62+
logConfig.Level.Set("debug")
6363

6464
handler := &statuszHandler{
6565
logger: log.NewLogfmtLogger(os.Stdout),
@@ -81,7 +81,7 @@ func TestStatuszHandler(t *testing.T) {
8181
ClusterName: "my-cluster",
8282
},
8383
ListenAddress: "0.0.0.0:9091",
84-
LogLevel: logLevel,
84+
PromlogConfig: logConfig,
8585
MetricRenames: map[string]string{"from1": "to1", "from2": "to2"},
8686
MetricsPrefix: "external.googleapis.com/prometheus",
8787
MonitoringBackends: []string{"prometheus", "stackdriver"},
@@ -120,6 +120,7 @@ func TestStatuszHandler(t *testing.T) {
120120
regexp.MustCompile(`<tr><th>Kubernetes labels: location</th><td>us-central1-a</td></tr>`),
121121
regexp.MustCompile(`<tr><th>Listen address</th><td>0.0.0.0:9091</td></tr>`),
122122
regexp.MustCompile(`<tr><th>Log level</th><td>debug</td></tr>`),
123+
regexp.MustCompile(`<tr><th>Log format</th><td>&lt;nil&gt;</td></tr>`),
123124
regexp.MustCompile(`<tr><th>Metrics prefix</th><td>external.googleapis.com/prometheus</td></tr>`),
124125
regexp.MustCompile(`<tr><th>Monitoring backends</th><td>\[prometheus stackdriver\]</td></tr>`),
125126
regexp.MustCompile(`<tr><th>Project ID resource</th><td>my-project</td></tr>`),

go.mod

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module github.com/Stackdriver/stackdriver-prometheus-sidecar
2+
3+
require (
4+
cloud.google.com/go v0.43.0
5+
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
6+
contrib.go.opencensus.io/exporter/prometheus v0.1.0
7+
contrib.go.opencensus.io/exporter/stackdriver v0.12.4
8+
github.com/Azure/azure-sdk-for-go v32.1.0+incompatible // indirect
9+
github.com/Azure/go-autorest v12.4.1+incompatible // indirect
10+
github.com/Azure/go-autorest/autorest v0.5.0 // indirect
11+
github.com/Azure/go-autorest/autorest/to v0.2.0 // indirect
12+
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
13+
github.com/Azure/go-autorest/tracing v0.2.0 // indirect
14+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
15+
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 // indirect
16+
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect
17+
github.com/aws/aws-sdk-go v1.21.10 // indirect
18+
github.com/beorn7/perks v1.0.1 // indirect
19+
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
20+
github.com/ghodss/yaml v1.0.0
21+
github.com/go-kit/kit v0.9.0
22+
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 // indirect
23+
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
24+
github.com/golang/protobuf v1.3.2
25+
github.com/googleapis/gnostic v0.3.0 // indirect
26+
github.com/gophercloud/gophercloud v0.3.0 // indirect
27+
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
28+
github.com/grpc-ecosystem/grpc-gateway v1.9.5 // indirect
29+
github.com/hashicorp/go-immutable-radix v1.1.0 // indirect
30+
github.com/hashicorp/go-msgpack v0.5.5 // indirect
31+
github.com/hashicorp/go-rootcerts v1.0.1 // indirect
32+
github.com/hashicorp/golang-lru v0.5.3 // indirect
33+
github.com/hashicorp/memberlist v0.1.4 // indirect
34+
github.com/hashicorp/serf v0.8.3 // indirect
35+
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 // indirect
36+
github.com/json-iterator/go v1.1.7 // indirect
37+
github.com/miekg/dns v1.1.15 // indirect
38+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
39+
github.com/oklog/oklog v0.3.2
40+
github.com/onsi/ginkgo v1.8.0 // indirect
41+
github.com/onsi/gomega v1.5.0 // indirect
42+
github.com/opentracing/opentracing-go v1.1.0 // indirect
43+
github.com/pkg/errors v0.8.1
44+
github.com/prometheus/client_golang v1.0.0
45+
github.com/prometheus/common v0.4.1
46+
github.com/prometheus/procfs v0.0.3 // indirect
47+
github.com/prometheus/prometheus v0.0.0-20190710134608-e5b22494857d
48+
github.com/prometheus/tsdb v0.10.0
49+
github.com/samuel/go-zookeeper v0.0.0-20190801204459-3c104360edc8 // indirect
50+
github.com/spaolacci/murmur3 v1.1.0 // indirect
51+
go.opencensus.io v0.22.0
52+
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
53+
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 // indirect
54+
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa // indirect
55+
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
56+
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64
57+
google.golang.org/grpc v1.22.1
58+
gopkg.in/alecthomas/kingpin.v2 v2.2.6
59+
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
60+
k8s.io/klog v0.3.3 // indirect
61+
k8s.io/kube-openapi v0.0.0-20190722073852-5e22f3d471e6 // indirect
62+
k8s.io/utils v0.0.0-20190801114015-581e00157fb1 // indirect
63+
)

0 commit comments

Comments
 (0)