Skip to content

Commit 5dba9e0

Browse files
authored
chore: πŸ”¨ add fmt-imports tool for import order. (#1228)
* chore: πŸ”¨ add gci format tool. * chore: πŸ“ remove fmt-imports from verify. * chore: πŸ“ Delete some spaces.
1 parent eb7dc7c commit 5dba9e0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

β€ŽMakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ code-generator:
115115
fmt: ## Run go fmt against code.
116116
go fmt ./...
117117

118+
.PHONY: fmt-imports
119+
fmt-imports: gci ## Run gci formatter on go files and verify.
120+
$(GCI) write -s standard -s default -s 'prefix(sigs.k8s.io/gateway-api-inference-extension)' --skip-generated --skip-vendor .
121+
118122
.PHONY: fmt-verify
119123
fmt-verify:
120124
@out=`gofmt -w -l -d $$(find . -name '*.go')`; \
@@ -363,6 +367,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
363367
HELM = $(PROJECT_DIR)/bin/helm
364368
YQ = $(PROJECT_DIR)/bin/yq
365369
KUBECTL_VALIDATE = $(PROJECT_DIR)/bin/kubectl-validate
370+
GCI = $(LOCALBIN)/gci
366371

367372
## Tool Versions
368373
KUSTOMIZE_VERSION ?= v5.4.3
@@ -371,6 +376,7 @@ ENVTEST_VERSION ?= release-0.19
371376
GOLANGCI_LINT_VERSION ?= v1.62.2
372377
HELM_VERSION ?= v3.17.1
373378
KUBECTL_VALIDATE_VERSION ?= v0.0.4
379+
GCI_VERSION ?= v0.13.6
374380

375381
.PHONY: kustomize
376382
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -405,6 +411,11 @@ kubectl-validate: $(KUBECTL_VALIDATE) ## Download kubectl-validate locally if ne
405411
$(KUBECTL_VALIDATE): $(LOCALBIN)
406412
$(call go-install-tool,$(KUBECTL_VALIDATE),sigs.k8s.io/kubectl-validate,$(KUBECTL_VALIDATE_VERSION))
407413

414+
.PHONY: gci
415+
gci: $(GCI) ## Download gci locally if necessary.
416+
$(GCI): $(LOCALBIN)
417+
$(call go-install-tool,$(GCI),github.com/daixiang0/gci,$(GCI_VERSION))
418+
408419
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
409420
# $1 - target path with name of binary
410421
# $2 - package url which can be installed

0 commit comments

Comments
Β (0)