You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Makefile
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -30,13 +30,16 @@ install-goimports: FORCE
30
30
install-golangci-lint: FORCE
31
31
@if !hash golangci-lint 2>/dev/null;thenprintf"\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest;fi
32
32
33
+
install-modernize: FORCE
34
+
@if !hash modernize 2>/dev/null;thenprintf"\e[1;36m>> Installing modernize (this may take a while)...\e[0m\n"; go install golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest;fi
35
+
33
36
install-go-licence-detector: FORCE
34
37
@if !hash go-licence-detector 2>/dev/null;thenprintf"\e[1;36m>> Installing go-licence-detector (this may take a while)...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest;fi
35
38
36
39
install-addlicense: FORCE
37
40
@if !hash addlicense 2>/dev/null;thenprintf"\e[1;36m>> Installing addlicense (this may take a while)...\e[0m\n"; go install github.com/google/addlicense@latest;fi
38
41
39
-
prepare-static-check: FORCE install-golangci-lint install-go-licence-detector install-addlicense
42
+
prepare-static-check: FORCE install-golangci-lint install-modernize install-go-licence-detector install-addlicense
40
43
41
44
install-controller-gen: FORCE
42
45
@if !hash controller-gen 2>/dev/null;thenprintf"\e[1;36m>> Installing controller-gen (this may take a while)...\e[0m\n"; go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest;fi
@@ -90,6 +93,10 @@ run-golangci-lint: FORCE install-golangci-lint
90
93
@golangci-lint config verify
91
94
@golangci-lint run
92
95
96
+
run-modernize: FORCE install-modernize
97
+
@printf "\e[1;36m>> modernize\e[0m\n"
98
+
@modernize $(GO_TESTPKGS)
99
+
93
100
build/cover.out: FORCE generate install-setup-envtest | build
94
101
@printf "\e[1;36m>> Running tests\e[0m\n"
95
102
KUBEBUILDER_ASSETS=$$(setup-envtest use 1.31 -p path) go test -shuffle=on -p 1 -coverprofile=$@$(GO_BUILDFLAGS) -ldflags '-s -w $(GO_LDFLAGS)' -covermode=count -coverpkg=$(subst$(space),$(comma),$(GO_COVERPKGS))$(GO_TESTPKGS)
@goimports -w -local github.com/sapcc/ccloud-nodeCIDR-controller $(patsubst$(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
130
137
138
+
modernize: FORCE install-modernize
139
+
@printf "\e[1;36m>> modernize -fix ./...\e[0m\n"
140
+
@modernize -fix ./...
141
+
131
142
clean: FORCE
132
143
git clean -dxf build
133
144
@@ -154,6 +165,7 @@ help: FORCE
154
165
@printf "\e[1mPrepare\e[0m\n"
155
166
@printf " \e[36minstall-goimports\e[0m Install goimports required by goimports/static-check\n"
156
167
@printf " \e[36minstall-golangci-lint\e[0m Install golangci-lint required by run-golangci-lint/static-check\n"
168
+
@printf " \e[36minstall-modernize\e[0m Install modernize required by modernize/static-check\n"
157
169
@printf " \e[36minstall-go-licence-detector\e[0m Install-go-licence-detector required by check-dependency-licenses/static-check\n"
158
170
@printf " \e[36minstall-addlicense\e[0m Install addlicense required by check-license-headers/license-headers/static-check\n"
159
171
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@@ -169,6 +181,7 @@ help: FORCE
169
181
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
170
182
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
171
183
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
184
+
@printf " \e[36mrun-modernize\e[0m Install and run modernize. Installing is used in CI, but you should probably install modernize using your package manager.\n"
172
185
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
173
186
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
174
187
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
@@ -179,6 +192,7 @@ help: FORCE
179
192
@printf " \e[36mcheck-license-headers\e[0m Check license headers in all non-vendored .go files.\n"
180
193
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
181
194
@printf " \e[36mgoimports\e[0m Run goimports on all non-vendored .go files\n"
195
+
@printf " \e[36mmodernize\e[0m Run modernize on all non-vendored .go files\n"
0 commit comments