From 32028f6e0c818790eec85637796944ba3d227491 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Mon, 4 May 2020 21:17:34 +0700 Subject: [PATCH 01/17] chore(*) update Go up to 1.14.2 --- .circleci/config.yml | 6 +++--- Makefile | 4 ++-- api/go.mod | 2 +- go.mod | 2 +- pkg/plugins/resources/k8s/native/Dockerfile | 2 +- pkg/plugins/resources/k8s/native/go.mod | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 43b04e70f23d..a076ca5551cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,11 +3,11 @@ version: 2.1 # Adds support for executors, parameterized jobs, etc reusable: constants: - - &go_version "1.12.12" + - &go_version "1.14.2" docker_images: - - &golang_image "golang:1.12.12" - - &circleci_golang_image "circleci/golang:1.12" + - &golang_image "golang:1.14.2" + - &circleci_golang_image "circleci/golang:1.14.2" vm_images: - &ubuntu_vm_image "ubuntu-1604:201903-01" diff --git a/Makefile b/Makefile index ac7af8d86576..202776d146c2 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ build_info_ld_flags := $(foreach entry,$(build_info_fields), -X github.com/Kong/ LD_FLAGS := -ldflags="-s -w $(build_info_ld_flags)" GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) -GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(LD_FLAGS) +GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v -mod=mod $(LD_FLAGS) GO_RUN := CGO_ENABLED=0 go run $(LD_FLAGS) GO_TEST := go test $(LD_FLAGS) @@ -125,7 +125,7 @@ CI_KIND_VERSION ?= v0.7.0 CI_MINIKUBE_VERSION ?= v1.4.0 CI_KUBERNETES_VERSION ?= v1.15.3 CI_KUBECTL_VERSION ?= v1.14.0 -CI_TOOLS_IMAGE ?= circleci/golang:1.12.12 +CI_TOOLS_IMAGE ?= circleci/golang:1.14.2 CI_TOOLS_DIR ?= $(HOME)/bin GOPATH_DIR := $(shell go env GOPATH | awk -F: '{print $$1}') diff --git a/api/go.mod b/api/go.mod index 31729670bbdb..a9f40d3444fe 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/api -go 1.12 +go 1.14 require ( github.com/cncf/udpa v0.0.0-20200313221541-5f7e5dd04533 // indirect diff --git a/go.mod b/go.mod index 6cd861f62492..efad61a918fc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma -go 1.12 +go 1.14 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 diff --git a/pkg/plugins/resources/k8s/native/Dockerfile b/pkg/plugins/resources/k8s/native/Dockerfile index 9e390c09a3a1..15d56f8a680c 100644 --- a/pkg/plugins/resources/k8s/native/Dockerfile +++ b/pkg/plugins/resources/k8s/native/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.12.12 as builder +FROM golang:1.14.2 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/pkg/plugins/resources/k8s/native/go.mod b/pkg/plugins/resources/k8s/native/go.mod index 4e5e00a379c4..d486875c396d 100644 --- a/pkg/plugins/resources/k8s/native/go.mod +++ b/pkg/plugins/resources/k8s/native/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/pkg/plugins/resources/k8s/native -go 1.12 +go 1.14 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 From 7bcd8b0282ef9562dd500144bd4e95e810d83c65 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Mon, 4 May 2020 22:19:13 +0700 Subject: [PATCH 02/17] chore(*) add '-mod=mod' --- Makefile | 6 +++--- pkg/plugins/resources/k8s/native/Makefile | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 202776d146c2..03f8fefb564c 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ else endif PROTOC_VERSION := 3.6.1 -PROTOC_PGV_VERSION := v0.3.0-java +PROTOC_PGV_VERSION := v0.3.0-java.0.20200311152155-ab56c3dd1cf9 GOLANG_PROTOBUF_VERSION := v1.3.2 GOLANGCI_LINT_VERSION := v1.21.0 @@ -273,7 +273,7 @@ generate/gui: ## Generate go files with GUI static files to embed it into binary fmt: fmt/go fmt/proto ## Dev: Run various format tools fmt/go: ## Dev: Run go fmt - go fmt ./... + go fmt -mod=mod ./... @# apparently, it's not possible to simply use `go fmt ./pkg/plugins/resources/k8s/native/...` make fmt -C pkg/plugins/resources/k8s/native @@ -281,7 +281,7 @@ fmt/proto: ## Dev: Run clang-format on .proto files which $(CLANG_FORMAT_PATH) && find . -name '*.proto' | xargs -L 1 $(CLANG_FORMAT_PATH) -i || true vet: ## Dev: Run go vet - go vet ./... + go vet -mod=mod ./... @# for consistency with `fmt` make vet -C pkg/plugins/resources/k8s/native diff --git a/pkg/plugins/resources/k8s/native/Makefile b/pkg/plugins/resources/k8s/native/Makefile index 135873b54f30..fd8d0b5b9498 100644 --- a/pkg/plugins/resources/k8s/native/Makefile +++ b/pkg/plugins/resources/k8s/native/Makefile @@ -60,11 +60,11 @@ manifests: controller-gen # Run go fmt against code fmt: - go fmt ./... + go fmt -mod=mod ./... # Run go vet against code vet: - go vet ./... + go vet -mod=mod ./... # Generate code generate: controller-gen From 2494c575a20aa2b4b930af6106c7e4212add1112 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Mon, 4 May 2020 22:25:16 +0700 Subject: [PATCH 03/17] chore(*) revert proto version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 03f8fefb564c..7533bccdb5ab 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ else endif PROTOC_VERSION := 3.6.1 -PROTOC_PGV_VERSION := v0.3.0-java.0.20200311152155-ab56c3dd1cf9 +PROTOC_PGV_VERSION := v0.3.0-java GOLANG_PROTOBUF_VERSION := v1.3.2 GOLANGCI_LINT_VERSION := v1.21.0 From b49d8e652325aee287e6cee1a5b8fd1b42db8abc Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 02:18:56 +0700 Subject: [PATCH 04/17] ci check --- Makefile.dev.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.dev.mk b/Makefile.dev.mk index 67a798e74cf4..d235b4dc58ae 100644 --- a/Makefile.dev.mk +++ b/Makefile.dev.mk @@ -45,7 +45,9 @@ dev/install/protobuf-wellknown-types:: ## Bootstrap: Install Protobuf well-known && echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go generator) + ls ${HOME}/go/bin go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) + ls ${HOME}/go/bin dev/install/protoc-gen-validate: ## Bootstrap: Install Protoc Gen Validate Plugin (protobuf validation code generator) go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) From 197863888678e599c30125a2395034ed379b4f39 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 02:24:02 +0700 Subject: [PATCH 05/17] ci check --- Makefile.dev.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.dev.mk b/Makefile.dev.mk index d235b4dc58ae..4d2d1fbe9351 100644 --- a/Makefile.dev.mk +++ b/Makefile.dev.mk @@ -45,9 +45,9 @@ dev/install/protobuf-wellknown-types:: ## Bootstrap: Install Protobuf well-known && echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go generator) - ls ${HOME}/go/bin + ls ${GOPATH_BIN_DIR} go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) - ls ${HOME}/go/bin + ls ${GOPATH_BIN_DIR} dev/install/protoc-gen-validate: ## Bootstrap: Install Protoc Gen Validate Plugin (protobuf validation code generator) go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) From fc477bedeeda963ddd74cc522e87015958ff6eaf Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 02:31:06 +0700 Subject: [PATCH 06/17] disable update --- Makefile.dev.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile.dev.mk b/Makefile.dev.mk index 4d2d1fbe9351..b94e5302fd13 100644 --- a/Makefile.dev.mk +++ b/Makefile.dev.mk @@ -45,12 +45,10 @@ dev/install/protobuf-wellknown-types:: ## Bootstrap: Install Protobuf well-known && echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go generator) - ls ${GOPATH_BIN_DIR} go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) - ls ${GOPATH_BIN_DIR} dev/install/protoc-gen-validate: ## Bootstrap: Install Protoc Gen Validate Plugin (protobuf validation code generator) - go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) + go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) dev/install/ginkgo: ## Bootstrap: Install Ginkgo (BDD testing framework) # see https://github.com/onsi/ginkgo#set-me-up From 66dbc698c7e8484285e662dbe145dc87e5ab32f5 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 04:54:30 +0700 Subject: [PATCH 07/17] chore(*): adjust Makefiles for the new Go version --- Makefile | 26 ++++++++++++++++------- api/Makefile | 5 ++++- pkg/plugins/resources/k8s/native/Makefile | 6 +++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 7533bccdb5ab..367b73a33b2a 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ print/kubebuilder/test_assets \ run/kuma-dp -PKG_LIST := ./... ./api/... ./pkg/plugins/resources/k8s/native/... +PKG_LIST := ./... #./api/... ./pkg/plugins/resources/k8s/native/... BUILD_INFO_GIT_TAG ?= $(shell git describe --tags 2>/dev/null || echo unknown) BUILD_INFO_GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown) @@ -40,7 +40,7 @@ BUILD_DIR ?= build BUILD_ARTIFACTS_DIR ?= $(BUILD_DIR)/artifacts-${GOOS}-${GOARCH} BUILD_DOCKER_IMAGES_DIR ?= $(BUILD_DIR)/docker-images -GO_TEST_OPTS ?= +GO_TEST_OPTS ?= -mod=mod BUILD_COVERAGE_DIR ?= $(BUILD_DIR)/coverage @@ -295,19 +295,29 @@ check: generate fmt vet docs golangci-lint imports ## Dev: Run code checks (go f make generate manifests -C pkg/plugins/resources/k8s/native git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators and code checks) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty -test: ## Dev: Run tests +test: test/api test/k8s test/kuma ## Dev: Run tests for all modules + +test/kuma: # Dev: Run tests for the module github.com/Kong/kuma mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")" $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST) - go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" + GO111MODULE=off go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" + +test/api: # Dev: Run tests for the module github.com/Kong/kuma/api + GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../$(BUILD_COVERAGE_DIR)/coverage-api.out' \ + make test -C ./api + +test/k8s: # Dev: Run tests for the module github.com/Kong/kuma/pkg/plugins/resources/k8s/native + GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../../../../../$(BUILD_COVERAGE_DIR)/coverage-k8s.out' \ + make test -C ./pkg/plugins/resources/k8s/native test/kuma-cp: PKG_LIST=./app/kuma-cp/... ./pkg/config/app/kuma-cp/... -test/kuma-cp: test ## Dev: Run `kuma-cp` tests only +test/kuma-cp: test/kuma ## Dev: Run `kuma-cp` tests only test/kuma-dp: PKG_LIST=./app/kuma-dp/... ./pkg/config/app/kuma-dp/... -test/kuma-dp: test ## Dev: Run `kuma-dp` tests only +test/kuma-dp: test/kuma ## Dev: Run `kuma-dp` tests only test/kumactl: PKG_LIST=./app/kumactl/... ./pkg/config/app/kumactl/... -test/kumactl: test ## Dev: Run `kumactl` tests only +test/kumactl: test/kuma ## Dev: Run `kumactl` tests only integration: ## Dev: Run integration tests mkdir -p "$(shell dirname "$(COVERAGE_INTEGRATION_PROFILE)")" @@ -529,4 +539,4 @@ run/kuma-dp: ## Dev: Run `kuma-dp` locally $(GO_RUN) ./app/kuma-dp/main.go run --log-level=debug include Makefile.dev.mk -include Makefile.e2e.mk +include Makefile.e2e.mk \ No newline at end of file diff --git a/api/Makefile b/api/Makefile index 0776da6f19ae..b9bb24156367 100644 --- a/api/Makefile +++ b/api/Makefile @@ -135,8 +135,11 @@ protoc/system/v1alpha1: build: ## Build generated files go build ./... +GO_TEST ?= go test +GO_TEST_OPTS ?= + test: ## Run tests - go test ./... + $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" ./... check: generate build test ## Verify that auto-generated code is up-to-date git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty diff --git a/pkg/plugins/resources/k8s/native/Makefile b/pkg/plugins/resources/k8s/native/Makefile index fd8d0b5b9498..1421716fcc92 100644 --- a/pkg/plugins/resources/k8s/native/Makefile +++ b/pkg/plugins/resources/k8s/native/Makefile @@ -24,9 +24,13 @@ export TEST_ASSET_KUBECTL=$(KUBECTL_PATH) all: manager +GO_TEST ?= go test +GO_TEST_OPTS ?= +COVERAGE_PROFILE ?= cover.out + # Run tests test: generate fmt vet manifests - go test ./api/... ./controllers/... -coverprofile cover.out + $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" ./api/... ./controllers/... # Build manager binary manager: generate fmt vet From d59f6c1958f79c10471d964e5f221899b892ac27 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 05:12:05 +0700 Subject: [PATCH 08/17] chore(*): add separate coverage targets --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 367b73a33b2a..338d7e7cb7b4 100644 --- a/Makefile +++ b/Makefile @@ -295,13 +295,17 @@ check: generate fmt vet docs golangci-lint imports ## Dev: Run code checks (go f make generate manifests -C pkg/plugins/resources/k8s/native git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators and code checks) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty -test: test/api test/k8s test/kuma ## Dev: Run tests for all modules +test: ${COVERAGE_PROFILE} test/api test/k8s test/kuma coverage ## Dev: Run tests for all modules -test/kuma: # Dev: Run tests for the module github.com/Kong/kuma +${COVERAGE_PROFILE}: mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")" - $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST) + +coverage: ${COVERAGE_PROFILE} GO111MODULE=off go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" +test/kuma: # Dev: Run tests for the module github.com/Kong/kuma + $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST) + test/api: # Dev: Run tests for the module github.com/Kong/kuma/api GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../$(BUILD_COVERAGE_DIR)/coverage-api.out' \ make test -C ./api @@ -319,8 +323,10 @@ test/kuma-dp: test/kuma ## Dev: Run `kuma-dp` tests only test/kumactl: PKG_LIST=./app/kumactl/... ./pkg/config/app/kumactl/... test/kumactl: test/kuma ## Dev: Run `kumactl` tests only -integration: ## Dev: Run integration tests +${COVERAGE_INTEGRATION_PROFILE}: mkdir -p "$(shell dirname "$(COVERAGE_INTEGRATION_PROFILE)")" + +integration: ${COVERAGE_INTEGRATION_PROFILE} ## Dev: Run integration tests tools/test/run-integration-tests.sh '$(GO_TEST) -race -covermode=atomic -tags=integration -count=1 -coverpkg=./... -coverprofile=$(COVERAGE_INTEGRATION_PROFILE) $(PKG_LIST)' go tool cover -html="$(COVERAGE_INTEGRATION_PROFILE)" -o "$(COVERAGE_INTEGRATION_REPORT_HTML)" From 7541c9e180458dada9736856e591212f70063d6e Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 05:16:31 +0700 Subject: [PATCH 09/17] chore(*): move '-mod=mod' to GO_TEST --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 338d7e7cb7b4..8afe714c6c9d 100644 --- a/Makefile +++ b/Makefile @@ -34,13 +34,13 @@ GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v -mod=mod $(LD_FLAGS) GO_RUN := CGO_ENABLED=0 go run $(LD_FLAGS) -GO_TEST := go test $(LD_FLAGS) +GO_TEST := go test -mod=mod $(LD_FLAGS) BUILD_DIR ?= build BUILD_ARTIFACTS_DIR ?= $(BUILD_DIR)/artifacts-${GOOS}-${GOARCH} BUILD_DOCKER_IMAGES_DIR ?= $(BUILD_DIR)/docker-images -GO_TEST_OPTS ?= -mod=mod +GO_TEST_OPTS ?= BUILD_COVERAGE_DIR ?= $(BUILD_DIR)/coverage From ed77c1ed8da0816620f7309031ec8b71430c08bf Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 05:51:54 +0700 Subject: [PATCH 10/17] chore(*): circleci working_directory = /go/src/github.com/Kong/kuma --- .circleci/config.yml | 3 +++ api/mesh/v1alpha1/proxy_template.pb.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a076ca5551cc..92758d8fc188 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,6 +53,7 @@ executors: environment: GO_VERSION: *go_version GO111MODULE: "on" + working_directory: /go/src/github.com/Kong/kuma jobs: dev_golang: @@ -61,6 +62,7 @@ jobs: environment: GO_VERSION: *go_version GO111MODULE: "on" + working_directory: /go/src/github.com/Kong/kuma steps: - checkout - run: @@ -87,6 +89,7 @@ jobs: # if GOPATH is not set, `golang-ci` fails with an obscure message # "ERRO Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler" GOPATH: /root/.go-kuma-go + working_directory: /go/src/github.com/Kong/kuma steps: - checkout - run: diff --git a/api/mesh/v1alpha1/proxy_template.pb.go b/api/mesh/v1alpha1/proxy_template.pb.go index b83ddd811ff2..fbdee36eef1c 100644 --- a/api/mesh/v1alpha1/proxy_template.pb.go +++ b/api/mesh/v1alpha1/proxy_template.pb.go @@ -373,7 +373,9 @@ func init() { proto.RegisterType((*ProxyTemplateRawResource)(nil), "kuma.mesh.v1alpha1.ProxyTemplateRawResource") } -func init() { proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) } +func init() { + proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) +} var fileDescriptor_129e53d675ac14f4 = []byte{ // 392 bytes of a gzipped FileDescriptorProto From adcd384dfe45fe7c4c2676c239b61209ad6b6709 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 07:05:02 +0700 Subject: [PATCH 11/17] chore(*): downgrade to 1.13.10 because of 'go tool cover' --- .circleci/config.yml | 9 +++------ Makefile | 14 +++++++------- pkg/plugins/resources/k8s/native/Dockerfile | 2 +- pkg/plugins/resources/k8s/native/Makefile | 4 ++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92758d8fc188..bb1e4adfa063 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,11 +3,11 @@ version: 2.1 # Adds support for executors, parameterized jobs, etc reusable: constants: - - &go_version "1.14.2" + - &go_version "1.13.10" docker_images: - - &golang_image "golang:1.14.2" - - &circleci_golang_image "circleci/golang:1.14.2" + - &golang_image "golang:1.13.10" + - &circleci_golang_image "circleci/golang:1.13.10" vm_images: - &ubuntu_vm_image "ubuntu-1604:201903-01" @@ -53,7 +53,6 @@ executors: environment: GO_VERSION: *go_version GO111MODULE: "on" - working_directory: /go/src/github.com/Kong/kuma jobs: dev_golang: @@ -62,7 +61,6 @@ jobs: environment: GO_VERSION: *go_version GO111MODULE: "on" - working_directory: /go/src/github.com/Kong/kuma steps: - checkout - run: @@ -89,7 +87,6 @@ jobs: # if GOPATH is not set, `golang-ci` fails with an obscure message # "ERRO Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler" GOPATH: /root/.go-kuma-go - working_directory: /go/src/github.com/Kong/kuma steps: - checkout - run: diff --git a/Makefile b/Makefile index 8afe714c6c9d..96c52b540073 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ print/kubebuilder/test_assets \ run/kuma-dp -PKG_LIST := ./... #./api/... ./pkg/plugins/resources/k8s/native/... +PKG_LIST := ./... BUILD_INFO_GIT_TAG ?= $(shell git describe --tags 2>/dev/null || echo unknown) BUILD_INFO_GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown) @@ -32,9 +32,9 @@ build_info_ld_flags := $(foreach entry,$(build_info_fields), -X github.com/Kong/ LD_FLAGS := -ldflags="-s -w $(build_info_ld_flags)" GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) -GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v -mod=mod $(LD_FLAGS) +GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(LD_FLAGS) GO_RUN := CGO_ENABLED=0 go run $(LD_FLAGS) -GO_TEST := go test -mod=mod $(LD_FLAGS) +GO_TEST := go test $(LD_FLAGS) BUILD_DIR ?= build BUILD_ARTIFACTS_DIR ?= $(BUILD_DIR)/artifacts-${GOOS}-${GOARCH} @@ -125,7 +125,7 @@ CI_KIND_VERSION ?= v0.7.0 CI_MINIKUBE_VERSION ?= v1.4.0 CI_KUBERNETES_VERSION ?= v1.15.3 CI_KUBECTL_VERSION ?= v1.14.0 -CI_TOOLS_IMAGE ?= circleci/golang:1.14.2 +CI_TOOLS_IMAGE ?= circleci/golang:1.13.10 CI_TOOLS_DIR ?= $(HOME)/bin GOPATH_DIR := $(shell go env GOPATH | awk -F: '{print $$1}') @@ -273,7 +273,7 @@ generate/gui: ## Generate go files with GUI static files to embed it into binary fmt: fmt/go fmt/proto ## Dev: Run various format tools fmt/go: ## Dev: Run go fmt - go fmt -mod=mod ./... + go fmt ./... @# apparently, it's not possible to simply use `go fmt ./pkg/plugins/resources/k8s/native/...` make fmt -C pkg/plugins/resources/k8s/native @@ -281,7 +281,7 @@ fmt/proto: ## Dev: Run clang-format on .proto files which $(CLANG_FORMAT_PATH) && find . -name '*.proto' | xargs -L 1 $(CLANG_FORMAT_PATH) -i || true vet: ## Dev: Run go vet - go vet -mod=mod ./... + go vet ./... @# for consistency with `fmt` make vet -C pkg/plugins/resources/k8s/native @@ -301,7 +301,7 @@ ${COVERAGE_PROFILE}: mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")" coverage: ${COVERAGE_PROFILE} - GO111MODULE=off go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" + go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" test/kuma: # Dev: Run tests for the module github.com/Kong/kuma $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST) diff --git a/pkg/plugins/resources/k8s/native/Dockerfile b/pkg/plugins/resources/k8s/native/Dockerfile index 15d56f8a680c..127ad0e7448f 100644 --- a/pkg/plugins/resources/k8s/native/Dockerfile +++ b/pkg/plugins/resources/k8s/native/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.14.2 as builder +FROM golang:1.13.10 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/pkg/plugins/resources/k8s/native/Makefile b/pkg/plugins/resources/k8s/native/Makefile index 1421716fcc92..a9aea0b0f89e 100644 --- a/pkg/plugins/resources/k8s/native/Makefile +++ b/pkg/plugins/resources/k8s/native/Makefile @@ -64,11 +64,11 @@ manifests: controller-gen # Run go fmt against code fmt: - go fmt -mod=mod ./... + go fmt ./... # Run go vet against code vet: - go vet -mod=mod ./... + go vet ./... # Generate code generate: controller-gen From 1e62d0804b2219222a3f88807ac77cad5d8bf40f Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 07:49:42 +0700 Subject: [PATCH 12/17] chore(*): eliminate updating protoc-gen-validate --- api/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Makefile b/api/Makefile index b9bb24156367..ce316277507a 100644 --- a/api/Makefile +++ b/api/Makefile @@ -110,7 +110,7 @@ install/protoc-gen-go: go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) install/protoc-gen-validate: - go get -u github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) + go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) install/data-plane-api: go get -u github.com/envoyproxy/data-plane-api@$(DATAPLANE_API_LATEST_VERSION) From 6e6b35044955e7b34688ed9a1389e82e50dc9e79 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 07:54:21 +0700 Subject: [PATCH 13/17] chore(*): fix go.mod files --- api/go.mod | 2 +- go.mod | 2 +- pkg/plugins/resources/k8s/native/go.mod | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/go.mod b/api/go.mod index a9f40d3444fe..8ae039da9b6a 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/api -go 1.14 +go 1.13 require ( github.com/cncf/udpa v0.0.0-20200313221541-5f7e5dd04533 // indirect diff --git a/go.mod b/go.mod index efad61a918fc..a31f31af072b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma -go 1.14 +go 1.13 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 diff --git a/pkg/plugins/resources/k8s/native/go.mod b/pkg/plugins/resources/k8s/native/go.mod index d486875c396d..f67801eb07da 100644 --- a/pkg/plugins/resources/k8s/native/go.mod +++ b/pkg/plugins/resources/k8s/native/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/pkg/plugins/resources/k8s/native -go 1.14 +go 1.13 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 From 5c717bb31baa6a57a77b0a6eb53d231f57188a40 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 08:04:27 +0700 Subject: [PATCH 14/17] chore(*): restore proxy_template.pb.go --- api/mesh/v1alpha1/proxy_template.pb.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/mesh/v1alpha1/proxy_template.pb.go b/api/mesh/v1alpha1/proxy_template.pb.go index fbdee36eef1c..b83ddd811ff2 100644 --- a/api/mesh/v1alpha1/proxy_template.pb.go +++ b/api/mesh/v1alpha1/proxy_template.pb.go @@ -373,9 +373,7 @@ func init() { proto.RegisterType((*ProxyTemplateRawResource)(nil), "kuma.mesh.v1alpha1.ProxyTemplateRawResource") } -func init() { - proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) -} +func init() { proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) } var fileDescriptor_129e53d675ac14f4 = []byte{ // 392 bytes of a gzipped FileDescriptorProto From d000975b385f021ac78b50f9fac710ecafaef75c Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 18:06:04 +0700 Subject: [PATCH 15/17] chore(*): revert go to version 1.14 --- .circleci/config.yml | 6 ++-- Makefile | 32 ++++++++++++--------- api/go.mod | 2 +- api/mesh/v1alpha1/proxy_template.pb.go | 4 ++- go.mod | 2 +- pkg/plugins/resources/k8s/native/Dockerfile | 2 +- pkg/plugins/resources/k8s/native/go.mod | 2 +- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb1e4adfa063..a076ca5551cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,11 +3,11 @@ version: 2.1 # Adds support for executors, parameterized jobs, etc reusable: constants: - - &go_version "1.13.10" + - &go_version "1.14.2" docker_images: - - &golang_image "golang:1.13.10" - - &circleci_golang_image "circleci/golang:1.13.10" + - &golang_image "golang:1.14.2" + - &circleci_golang_image "circleci/golang:1.14.2" vm_images: - &ubuntu_vm_image "ubuntu-1604:201903-01" diff --git a/Makefile b/Makefile index 96c52b540073..f80cecbcd033 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,10 @@ build_info_ld_flags := $(foreach entry,$(build_info_fields), -X github.com/Kong/ LD_FLAGS := -ldflags="-s -w $(build_info_ld_flags)" GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) -GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(LD_FLAGS) +GOFLAGS := -mod=mod +GO_BUILD := GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -v $(GOFLAGS) $(LD_FLAGS) GO_RUN := CGO_ENABLED=0 go run $(LD_FLAGS) -GO_TEST := go test $(LD_FLAGS) +GO_TEST := go test $(GOFLAGS) $(LD_FLAGS) BUILD_DIR ?= build BUILD_ARTIFACTS_DIR ?= $(BUILD_DIR)/artifacts-${GOOS}-${GOARCH} @@ -116,7 +117,7 @@ else endif PROTOC_VERSION := 3.6.1 -PROTOC_PGV_VERSION := v0.3.0-java +PROTOC_PGV_VERSION := v0.3.0-java.0.20200311152155-ab56c3dd1cf9 GOLANG_PROTOBUF_VERSION := v1.3.2 GOLANGCI_LINT_VERSION := v1.21.0 @@ -125,7 +126,7 @@ CI_KIND_VERSION ?= v0.7.0 CI_MINIKUBE_VERSION ?= v1.4.0 CI_KUBERNETES_VERSION ?= v1.15.3 CI_KUBECTL_VERSION ?= v1.14.0 -CI_TOOLS_IMAGE ?= circleci/golang:1.13.10 +CI_TOOLS_IMAGE ?= circleci/golang:1.14.2 CI_TOOLS_DIR ?= $(HOME)/bin GOPATH_DIR := $(shell go env GOPATH | awk -F: '{print $$1}') @@ -273,7 +274,7 @@ generate/gui: ## Generate go files with GUI static files to embed it into binary fmt: fmt/go fmt/proto ## Dev: Run various format tools fmt/go: ## Dev: Run go fmt - go fmt ./... + go fmt $(GOFLAGS) ./... @# apparently, it's not possible to simply use `go fmt ./pkg/plugins/resources/k8s/native/...` make fmt -C pkg/plugins/resources/k8s/native @@ -281,7 +282,7 @@ fmt/proto: ## Dev: Run clang-format on .proto files which $(CLANG_FORMAT_PATH) && find . -name '*.proto' | xargs -L 1 $(CLANG_FORMAT_PATH) -i || true vet: ## Dev: Run go vet - go vet ./... + go vet $(GOFLAGS) ./... @# for consistency with `fmt` make vet -C pkg/plugins/resources/k8s/native @@ -301,18 +302,23 @@ ${COVERAGE_PROFILE}: mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")" coverage: ${COVERAGE_PROFILE} - go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" + GOFLAGS='${GOFLAGS}' go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT_HTML)" test/kuma: # Dev: Run tests for the module github.com/Kong/kuma $(GO_TEST) $(GO_TEST_OPTS) -race -covermode=atomic -coverpkg=./... -coverprofile="$(COVERAGE_PROFILE)" $(PKG_LIST) -test/api: # Dev: Run tests for the module github.com/Kong/kuma/api - GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../$(BUILD_COVERAGE_DIR)/coverage-api.out' \ - make test -C ./api +test/api: \ + MODULE=./api \ + COVERAGE_PROFILE=../$(BUILD_COVERAGE_DIR)/coverage-api.out +test/api: test/module -test/k8s: # Dev: Run tests for the module github.com/Kong/kuma/pkg/plugins/resources/k8s/native - GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='../../../../../$(BUILD_COVERAGE_DIR)/coverage-k8s.out' \ - make test -C ./pkg/plugins/resources/k8s/native +test/k8s: \ + MODULE=./pkg/plugins/resources/k8s/native \ + COVERAGE_PROFILE=../../../../../$(BUILD_COVERAGE_DIR)/coverage-k8s.out +test/k8s: test/module + +test/module: + GO_TEST='${GO_TEST}' GO_TEST_OPTS='${GO_TEST_OPTS}' COVERAGE_PROFILE='${COVERAGE_PROFILE}' make test -C ${MODULE} test/kuma-cp: PKG_LIST=./app/kuma-cp/... ./pkg/config/app/kuma-cp/... test/kuma-cp: test/kuma ## Dev: Run `kuma-cp` tests only diff --git a/api/go.mod b/api/go.mod index 8ae039da9b6a..a9f40d3444fe 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/api -go 1.13 +go 1.14 require ( github.com/cncf/udpa v0.0.0-20200313221541-5f7e5dd04533 // indirect diff --git a/api/mesh/v1alpha1/proxy_template.pb.go b/api/mesh/v1alpha1/proxy_template.pb.go index b83ddd811ff2..fbdee36eef1c 100644 --- a/api/mesh/v1alpha1/proxy_template.pb.go +++ b/api/mesh/v1alpha1/proxy_template.pb.go @@ -373,7 +373,9 @@ func init() { proto.RegisterType((*ProxyTemplateRawResource)(nil), "kuma.mesh.v1alpha1.ProxyTemplateRawResource") } -func init() { proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) } +func init() { + proto.RegisterFile("mesh/v1alpha1/proxy_template.proto", fileDescriptor_129e53d675ac14f4) +} var fileDescriptor_129e53d675ac14f4 = []byte{ // 392 bytes of a gzipped FileDescriptorProto diff --git a/go.mod b/go.mod index a31f31af072b..efad61a918fc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma -go 1.13 +go 1.14 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 diff --git a/pkg/plugins/resources/k8s/native/Dockerfile b/pkg/plugins/resources/k8s/native/Dockerfile index 127ad0e7448f..15d56f8a680c 100644 --- a/pkg/plugins/resources/k8s/native/Dockerfile +++ b/pkg/plugins/resources/k8s/native/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.13.10 as builder +FROM golang:1.14.2 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/pkg/plugins/resources/k8s/native/go.mod b/pkg/plugins/resources/k8s/native/go.mod index f67801eb07da..d486875c396d 100644 --- a/pkg/plugins/resources/k8s/native/go.mod +++ b/pkg/plugins/resources/k8s/native/go.mod @@ -1,6 +1,6 @@ module github.com/Kong/kuma/pkg/plugins/resources/k8s/native -go 1.13 +go 1.14 require ( github.com/Kong/kuma/api v0.0.0-00010101000000-000000000000 From 64bb207ad939d321463d8f7bda43270af8848686 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Tue, 5 May 2020 18:29:09 +0700 Subject: [PATCH 16/17] chore(*): add GOFLAGS for 'go tool cover' --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f80cecbcd033..8537839ce471 100644 --- a/Makefile +++ b/Makefile @@ -334,7 +334,7 @@ ${COVERAGE_INTEGRATION_PROFILE}: integration: ${COVERAGE_INTEGRATION_PROFILE} ## Dev: Run integration tests tools/test/run-integration-tests.sh '$(GO_TEST) -race -covermode=atomic -tags=integration -count=1 -coverpkg=./... -coverprofile=$(COVERAGE_INTEGRATION_PROFILE) $(PKG_LIST)' - go tool cover -html="$(COVERAGE_INTEGRATION_PROFILE)" -o "$(COVERAGE_INTEGRATION_REPORT_HTML)" + GOFLAGS='${GOFLAGS}' go tool cover -html="$(COVERAGE_INTEGRATION_PROFILE)" -o "$(COVERAGE_INTEGRATION_REPORT_HTML)" build: build/kuma-cp build/kuma-dp build/kumactl build/kuma-prometheus-sd ## Dev: Build all binaries From 85b15afbb89d446d774164ddb84a1be178897900 Mon Sep 17 00:00:00 2001 From: Ilya Lobkov Date: Thu, 7 May 2020 20:27:47 +0700 Subject: [PATCH 17/17] chore(*): delete '-u' for 'go get' --- Makefile.dev.mk | 4 ++-- api/Makefile | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.dev.mk b/Makefile.dev.mk index b94e5302fd13..7fdc0c5fb9ce 100644 --- a/Makefile.dev.mk +++ b/Makefile.dev.mk @@ -45,7 +45,7 @@ dev/install/protobuf-wellknown-types:: ## Bootstrap: Install Protobuf well-known && echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi dev/install/protoc-gen-go: ## Bootstrap: Install Protoc Go Plugin (protobuf Go generator) - go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) + go get github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) dev/install/protoc-gen-validate: ## Bootstrap: Install Protoc Gen Validate Plugin (protobuf validation code generator) go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) @@ -131,4 +131,4 @@ dev/install/golangci-lint: ## Bootstrap: Install golangci-lint curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOLANGCI_LINT_DIR) $(GOLANGCI_LINT_VERSION) dev/install/goimports: ## Bootstrap: Install goimports - go get -u golang.org/x/tools/cmd/goimports + go get golang.org/x/tools/cmd/goimports diff --git a/api/Makefile b/api/Makefile index ce316277507a..1bdb9f290449 100644 --- a/api/Makefile +++ b/api/Makefile @@ -107,15 +107,15 @@ install/protobuf-wellknown-types: && echo "Protobuf well-known types $(PROTOC_VERSION) have been installed at $(PROTOBUF_WKT_DIR)" ; fi install/protoc-gen-go: - go get -u github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) + go get github.com/golang/protobuf/protoc-gen-go@$(GOLANG_PROTOBUF_VERSION) install/protoc-gen-validate: go get github.com/envoyproxy/protoc-gen-validate@$(PROTOC_PGV_VERSION) install/data-plane-api: - go get -u github.com/envoyproxy/data-plane-api@$(DATAPLANE_API_LATEST_VERSION) - go get -u github.com/cncf/udpa@$(UDPA_LATEST_VERSION) - go get -u github.com/googleapis/googleapis@$(GOOGLEAPIS_LATEST_VERSION) + go get github.com/envoyproxy/data-plane-api@$(DATAPLANE_API_LATEST_VERSION) + go get github.com/cncf/udpa@$(UDPA_LATEST_VERSION) + go get github.com/googleapis/googleapis@$(GOOGLEAPIS_LATEST_VERSION) clean: ## Remove generated files find . -name '*.pb.go' -delete