Skip to content

Commit 4147a8e

Browse files
committed
Add a make target: imports
We will use it to sort imports. I tried openshift-goimports [1] and it did not work out for us because * It does not work with comments [2]. * We do have a comment to make golang linter happy [3]. [1]. https://github.com/openshift-eng/openshift-goimports [2]. openshift-eng/openshift-goimports#16 [3]. https://github.com/openshift/cluster-version-operator/blob/ac127d3a5d45f60eb54e5c5acc3711a284728499/pkg/cvo/updatepayload_test.go#L14-L15
1 parent c38734f commit 4147a8e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ format:
3434
go fmt ./...
3535
.PHONY: format
3636

37+
imports:
38+
which goimports || go install -mod=mod golang.org/x/tools/cmd/goimports@latest
39+
go list ./... | sed "s|^github.com/openshift/cluster-version-operator/||" | xargs goimports -w -local "k8s.io,github.com/openshift"
40+
go list ./... | sed "s|^github.com/openshift/cluster-version-operator/||" | xargs goimports -w -local "github.com/openshift/cluster-version-operator"
41+
.PHONY: imports
42+
3743
verify: verify-yaml verify-update
3844
.PHONY: verify
3945

4046
verify-yaml:
4147
hack/verify-yaml.sh
4248
.PHONY: verify-yaml
4349

44-
verify-update: update
50+
verify-update: imports update
4551
git diff --exit-code HEAD
4652
.PHONY: verify-update
4753

0 commit comments

Comments
 (0)