From 82cfe1975a758982eeaf29ece66ff21269777faf Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Thu, 22 Oct 2020 11:50:23 -0700 Subject: [PATCH 1/2] Not running govet or gofmt in Dockerfile builds Signed-off-by: Aaron Schlesinger --- .pre-commit-config.yaml | 2 ++ Dockerfile | 2 +- Dockerfile.adapter | 2 +- Makefile | 18 ++++++++++++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5bfb4aa824..f51acf5e8eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,8 @@ repos: hooks: - id: go-fmt name: Run go fmt against the code + - id: go-vet + name: Run go vet against the code - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: diff --git a/Dockerfile b/Dockerfile index 303245bfd05..1bfcffe4f0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ COPY pkg/ pkg/ COPY .git/ .git/ # Build -RUN VERSION=${BUILD_VERSION} make manager +RUN VERSION=${BUILD_VERSION} make manager-dockerfile # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Dockerfile.adapter b/Dockerfile.adapter index 749001fb73e..26ccfb83b71 100644 --- a/Dockerfile.adapter +++ b/Dockerfile.adapter @@ -28,7 +28,7 @@ COPY .git/ .git/ RUN mkdir -p /apiserver.local.config/certificates && chmod -R 777 /apiserver.local.config # Build -RUN VERSION=${BUILD_VERSION} make adapter +RUN VERSION=${BUILD_VERSION} make adapter-dockerfile # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index dcd2bc63c59..14bffd57035 100644 --- a/Makefile +++ b/Makefile @@ -136,14 +136,28 @@ docker-build: # Build KEDA Operator binary .PHONY: manager -manager: generate gofmt govet +manager: manager-dockerfile gofmt govet + +# Build the manager inside the Dockerfile. This elides +# the gofmt and govet commands. Since code quality checks +# are already in CI, we don't need to run them every +# time we build the image +.PHONY: manager-dockerfile +manager-dockerfile: generate ${GO_BUILD_VARS} go build \ -ldflags "-X=github.com/kedacore/keda/version.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(VERSION)" \ -o bin/keda main.go # Build KEDA Metrics Server Adapter binary .PHONY: adapter -adapter: generate gofmt govet +adapter: adapter-dockerfile gofmt govet + +# Build the adapter inside the Dockerfile. This elides +# the gofmt and govet commands. Since code quality checks +# are already in CI, we don't need to run them every +# time we build the image +.PHONY: adapter-dockerfile +adapter-dockerfile: generate ${GO_BUILD_VARS} go build \ -ldflags "-X=github.com/kedacore/keda/version.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(VERSION)" \ -o bin/keda-adapter adapter/main.go From 60d598bcd87781306aaff7a34cf01f1c2b020797 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Thu, 3 Dec 2020 12:01:08 -0800 Subject: [PATCH 2/2] not running go-vet in precommit Signed-off-by: Aaron Schlesinger --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f51acf5e8eb..e5bfb4aa824 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,8 +6,6 @@ repos: hooks: - id: go-fmt name: Run go fmt against the code - - id: go-vet - name: Run go vet against the code - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: