Skip to content

Commit b1bd7ef

Browse files
committed
Install goimports into hack/tools
On-behalf-of: SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
1 parent 488cc08 commit b1bd7ef

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Makefile

+9-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ GOLANGCI_LINT_VER := v1.62.2
5454
GOLANGCI_LINT_BIN := golangci-lint
5555
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
5656

57+
GOIMPORTS_VER := v0.31.0
58+
GOIMPORTS_BIN := goimports
59+
GOIMPORTS := $(TOOLS_GOBIN_DIR)/$(GOIMPORTS_BIN)-$(GOIMPORTS_VER)
60+
5761
HTTEST_VER := v0.3.2
5862
HTTEST_BIN := httest
5963
HTTEST := $(TOOLS_GOBIN_DIR)/$(HTTEST_BIN)-$(HTTEST_VER)
@@ -135,6 +139,9 @@ install: require-jq require-go require-git verify-go-versions ## Install the pro
135139
$(GOLANGCI_LINT):
136140
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
137141

142+
$(GOIMPORTS):
143+
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) golang.org/x/tools/cmd/goimports $(GOIMPORTS_BIN) $(GOIMPORTS_VER)
144+
138145
$(HTTEST):
139146
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) go.xrstf.de/httest $(HTTEST_BIN) $(HTTEST_VER)
140147

@@ -185,7 +192,7 @@ vendor: ## Vendor the dependencies
185192
go mod vendor
186193
.PHONY: vendor
187194

188-
tools: $(GOLANGCI_LINT) $(HTTEST) $(CONTROLLER_GEN) $(KCP_APIGEN_GEN) $(YAML_PATCH) $(GOTESTSUM) $(CODE_GENERATOR) ## Install tools
195+
tools: $(GOLANGCI_LINT) $(GOIMPORTS) $(HTTEST) $(CONTROLLER_GEN) $(KCP_APIGEN_GEN) $(YAML_PATCH) $(GOTESTSUM) $(CODE_GENERATOR) ## Install tools
189196
.PHONY: tools
190197

191198
$(CONTROLLER_GEN):
@@ -201,7 +208,7 @@ crds: $(CONTROLLER_GEN) $(YAML_PATCH) ## Generate crds
201208
./hack/update-codegen-crds.sh
202209
.PHONY: crds
203210

204-
codegen: $(KCP_APIGEN_GEN) $(CODE_GENERATOR) crds ## Generate all
211+
codegen: $(KCP_APIGEN_GEN) $(CODE_GENERATOR) $(GOIMPORTS) crds ## Generate all
205212
go mod download
206213
./hack/update-codegen-clients.sh
207214
$(MAKE) imports

hack/gen-patch-defaultrestmapper.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ for sym in ${symbols_from_meta_pkg[@]}; do
9797
gofmt -w -r "${sym} -> meta.${sym}" "${DEFAULTRESTMAPPER_PATCH_FILEPATH}"
9898
done
9999

100-
goimports -w "${DEFAULTRESTMAPPER_PATCH_FILEPATH}"
100+
"${REPO_ROOT}/hack/tools/goimports" -w "${DEFAULTRESTMAPPER_PATCH_FILEPATH}"
101101

102102
# Inform the caller if there were changes. Something could have broken.
103103

0 commit comments

Comments
 (0)