Skip to content

Commit

Permalink
Add goimports to make fmt goal:
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jacobweinstock committed Sep 20, 2023
1 parent 2fc3dc9 commit 4a2f0b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a2f0b7

Please sign in to comment.