From 4a2f0b71dd4c6181ebecbc7394b9ad9222225936 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 20 Sep 2023 10:01:46 -0600 Subject: [PATCH] Add goimports to make fmt goal: controller-gen doesn't format the imports like goimports does so the CI run of goimports will fail. This provides a make goal to run the go fmt and goimports. Signed-off-by: Jacob Weinstock --- Makefile | 8 +++++++- api/v1alpha1/zz_generated.deepcopy.go | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fa07ba3..9807303 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,9 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." .PHONY: fmt -fmt: ## Run go fmt against code. +fmt: goimports ## Run go fmt against code. go fmt ./... + $(GOIMPORTS) -w . .PHONY: vet vet: ## Run go vet against code. @@ -125,6 +126,11 @@ ENVTEST = $(shell pwd)/bin/setup-envtest envtest: ## Download envtest-setup locally if necessary. $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) +GOIMPORTS = $(shell pwd)/bin/goimports +.PHONY: goimports +goimports: ## Download goimports locally if necessary. + $(call go-get-tool,$(GOIMPORTS),golang.org/x/tools/cmd/goimports@latest) + ##@ Release RELEASE_TAG := $(shell git describe --abbrev=0 2>/dev/null) diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 38fb05b..afea220 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -21,9 +21,10 @@ limitations under the License. package v1alpha1 import ( - "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" "net/http" + + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.