Skip to content

Commit 3f5e55d

Browse files
anishasthanaopenshift-merge-robot
authored andcommitted
Add Make Target for organizing go imports
Signed-off-by: Anish Asthana <[email protected]>
1 parent a822747 commit 3f5e55d

File tree

5 files changed

+136
-0
lines changed

5 files changed

+136
-0
lines changed

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ LISTER_GEN ?= $(LOCALBIN)/lister-gen
278278
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
279279
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
280280
ENVTEST ?= $(LOCALBIN)/setup-envtest
281+
OPENSHIFT-GOIMPORTS ?= $(LOCALBIN)/openshift-goimports
281282
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
282283
GH_CLI ?= $(LOCALBIN)/gh
283284

@@ -338,6 +339,11 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
338339
$(ENVTEST): $(LOCALBIN)
339340
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
340341

342+
.PHONY: openshift-goimports
343+
openshift-goimports: $(OPENSHIFT-GOIMPORTS) ## Download openshift-goimports locally if necessary.
344+
$(OPENSHIFT-GOIMPORTS): $(LOCALBIN)
345+
test -s $(LOCALBIN)/openshift-goimports || GOBIN=$(LOCALBIN) go install github.com/openshift-eng/openshift-goimports@latest
346+
341347
OPERATOR_SDK_DL_URL := https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)
342348
.PHONY: install-operator-sdk
343349
install-operator-sdk: $(OPERATOR_SDK) ## Download fixed version operator-sdk binary for consist outcome
@@ -440,3 +446,11 @@ test-e2e: defaults manifests generate fmt vet ## Run e2e tests.
440446
.PHONY: setup-e2e
441447
setup-e2e: ## Set up e2e tests.
442448
KUBERAY_VERSION=$(KUBERAY_VERSION) test/e2e/setup.sh
449+
450+
.PHONY: imports
451+
imports: openshift-goimports ## Organize imports in go files using openshift-goimports. Example: make imports
452+
$(OPENSHIFT-GOIMPORTS)
453+
454+
.PHONY: verify-imports
455+
verify-imports: openshift-goimports ## Run import verifications.
456+
./hack/verify-imports.sh $(OPENSHIFT-GOIMPORTS)

go.mod

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/manifestival/manifestival v0.7.2
99
github.com/onsi/ginkgo/v2 v2.9.2
1010
github.com/onsi/gomega v1.27.6
11+
github.com/openshift-eng/openshift-goimports v0.0.0-20230304234052-c70783e636f2
1112
github.com/openshift/api v0.0.0-20230213134911-7ba313770556
1213
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c
1314
github.com/project-codeflare/multi-cluster-app-dispatcher v1.32.0
@@ -41,22 +42,35 @@ require (
4142
github.com/google/gofuzz v1.2.0 // indirect
4243
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
4344
github.com/google/uuid v1.1.2 // indirect
45+
github.com/hashicorp/hcl v1.0.0 // indirect
4446
github.com/imdario/mergo v0.3.12 // indirect
47+
github.com/inconshreveable/mousetrap v1.0.1 // indirect
4548
github.com/josharian/intern v1.0.0 // indirect
4649
github.com/json-iterator/go v1.1.12 // indirect
50+
github.com/magiconair/properties v1.8.4 // indirect
4751
github.com/mailru/easyjson v0.7.6 // indirect
4852
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
53+
github.com/mitchellh/go-homedir v1.1.0 // indirect
54+
github.com/mitchellh/mapstructure v1.4.1 // indirect
4955
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5056
github.com/modern-go/reflect2 v1.0.2 // indirect
5157
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
58+
github.com/pelletier/go-toml v1.8.1 // indirect
5259
github.com/pkg/errors v0.9.1 // indirect
5360
github.com/prometheus/client_golang v1.14.0 // indirect
5461
github.com/prometheus/client_model v0.3.0 // indirect
5562
github.com/prometheus/common v0.37.0 // indirect
5663
github.com/prometheus/procfs v0.8.0 // indirect
64+
github.com/spf13/afero v1.4.1 // indirect
65+
github.com/spf13/cast v1.3.1 // indirect
66+
github.com/spf13/cobra v1.6.0 // indirect
67+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
5768
github.com/spf13/pflag v1.0.5 // indirect
69+
github.com/spf13/viper v1.7.1 // indirect
70+
github.com/subosito/gotenv v1.2.0 // indirect
5871
go.uber.org/atomic v1.7.0 // indirect
5972
go.uber.org/multierr v1.6.0 // indirect
73+
golang.org/x/mod v0.9.0 // indirect
6074
golang.org/x/net v0.8.0 // indirect
6175
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
6276
golang.org/x/sys v0.6.0 // indirect
@@ -68,6 +82,7 @@ require (
6882
google.golang.org/appengine v1.6.7 // indirect
6983
google.golang.org/protobuf v1.28.1 // indirect
7084
gopkg.in/inf.v0 v0.9.1 // indirect
85+
gopkg.in/ini.v1 v1.62.0 // indirect
7186
gopkg.in/yaml.v2 v2.4.0 // indirect
7287
gopkg.in/yaml.v3 v3.0.1 // indirect
7388
k8s.io/apiextensions-apiserver v0.26.1 // indirect

0 commit comments

Comments
 (0)