Skip to content

Commit

Permalink
Update project to use go modules (#49)
Browse files Browse the repository at this point in the history
* Replace govendor by go modules

* Fix tests renaming a method call

* Replace references to govendor

* Update README removing references to GOPATH
  • Loading branch information
areina authored Jun 9, 2020
1 parent 24de6b5 commit 46b4310
Show file tree
Hide file tree
Showing 7 changed files with 364 additions and 1,761 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /go/src/github.com/newrelic/nri-prometheus
COPY Makefile Makefile
RUN make tools
# Trick for reusing the cache in case vendor.json doesn't change.
COPY vendor vendor
COPY go.mod .
RUN make deps
COPY . .
RUN make compile-only
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ GORELEASER_VERSION := v0.118.0
GORELEASER_SHA256 := 4ff50937727f5dc6bb1c63a224dff05034b530862734593f10eca887b5f0125e
GORELEASER_BIN ?= $(GOPATH)/bin/goreleaser
GO_PKGS := $(shell go list ./... | grep -v "/vendor/")
GOTOOLS = github.com/kardianos/govendor \
github.com/stretchr/testify/assert \
GOTOOLS = github.com/stretchr/testify/assert

all: build

Expand Down Expand Up @@ -50,7 +49,7 @@ deps: tools deps-only

deps-only:
@echo "=== $(INTEGRATION) === [ deps ]: Installing package dependencies required by the project..."
@govendor sync
@go mod download

validate: deps
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running golangci-lint..."
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ However, at the moment the tests are totally isolated and you don't need a clust
1. **Go 1.13**. This project uses the [error
wrapping](https://golang.org/doc/go1.13#error_wrapping) support, which makes
it incompatible with previous Go versions.
2. The project needs to be cloned at `$GOPATH/src/github.com/newrelic/nri-prometheus`.
3. Ensure you added `$GOPATH/bin` to your `$PATH`, otherwise builds won't be possible.

If you want to learn more about the GOPATH, check the [official Go docs](https://golang.org/doc/code.html#GOPATH).

### Running the tests & linters

Expand Down
36 changes: 36 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module github.com/newrelic/nri-prometheus

go 1.13

require (
github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect
github.com/fsnotify/fsnotify v1.4.8-0.20190312181446-1485a34d5d57 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/gnostic v0.2.3-0.20181019180348-e2aafd60c944 // indirect
github.com/hashicorp/hcl v1.0.1-0.20190611123218-cf7d376da96d // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/kardianos/govendor v1.0.9 // indirect
github.com/newrelic/newrelic-telemetry-sdk-go v0.2.1-0.20200116224429-790ff853d12b
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/pelletier/go-toml v1.2.1-0.20181124002727-27c6b39a135b // indirect
github.com/pkg/errors v0.8.1-0.20180311214515-816c9085562c
github.com/prometheus/client_golang v0.9.3
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
github.com/prometheus/common v0.4.0
github.com/sirupsen/logrus v1.3.0
github.com/spf13/cast v1.3.1-0.20190531093228-c01685bb8421 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.4.1-0.20190729163700-33bf76add3b7
github.com/stretchr/objx v0.1.2-0.20180626195558-9e1dfc121bca // indirect
github.com/stretchr/testify v1.6.1
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
k8s.io/api v0.16.10
k8s.io/apimachinery v0.16.10
k8s.io/client-go v0.15.12
k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 // indirect
sigs.k8s.io/yaml v1.1.1-0.20181103002144-5fa4c7f5e38d // indirect
)
315 changes: 315 additions & 0 deletions go.sum

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions internal/pkg/endpoints/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,17 @@ func populateFakePodDataModify(clientset *fake.Clientset) error {
},
}

_, err := clientset.Core().Pods("test-ns").Create(p)
_, err := clientset.CoreV1().Pods("test-ns").Create(p)
if err != nil {
return err
}

_, err = clientset.Core().Pods("test-ns").Create(p2)
_, err = clientset.CoreV1().Pods("test-ns").Create(p2)
if err != nil {
return err
}

_, err = clientset.Core().Pods("test-ns").Create(p3)
_, err = clientset.CoreV1().Pods("test-ns").Create(p3)
if err != nil {
return err
}
Expand All @@ -415,17 +415,17 @@ func populateFakePodDataModify(clientset *fake.Clientset) error {
p2.ObjectMeta.Labels["prometheus.io/scrape"] = "true"
delete(p3.ObjectMeta.Labels, "prometheus.io/scrape")

_, err = clientset.Core().Pods("test-ns").Update(p)
_, err = clientset.CoreV1().Pods("test-ns").Update(p)
if err != nil {
return err
}

_, err = clientset.Core().Pods("test-ns").Update(p2)
_, err = clientset.CoreV1().Pods("test-ns").Update(p2)
if err != nil {
return err
}

_, err = clientset.Core().Pods("test-ns").Update(p3)
_, err = clientset.CoreV1().Pods("test-ns").Update(p3)
if err != nil {
return err
}
Expand Down Expand Up @@ -485,12 +485,12 @@ func populateFakePodData(clientset *fake.Clientset) error {
},
}

_, err := clientset.Core().Pods("test-ns").Create(p)
_, err := clientset.CoreV1().Pods("test-ns").Create(p)
if err != nil {
return err
}

_, err = clientset.Core().Pods("test-ns").Create(p2)
_, err = clientset.CoreV1().Pods("test-ns").Create(p2)
if err != nil {
return err
}
Expand Down Expand Up @@ -526,11 +526,11 @@ func populateFakeServiceData(clientset *fake.Clientset) error {
},
}

_, err := clientset.Core().Services("test-ns").Create(s)
_, err := clientset.CoreV1().Services("test-ns").Create(s)
if err != nil {
return err
}
_, err = clientset.Core().Services("test-ns").Create(s2)
_, err = clientset.CoreV1().Services("test-ns").Create(s2)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 46b4310

Please sign in to comment.