@@ -137,10 +137,23 @@ endif
137137
138138.PHONY : lint.%
139139lint.% : # # Runs golangci-lint for a specific module
140- lint.% : ; $(info $(M ) linting $* module)
141- $(if $(filter-out root,$* ) ,cd $* && ) golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m ) |.|" )
140+ lint.% : golines.% ; $(info $(M ) linting $* module)
142141 $(if $(filter-out root,$* ) ,cd $* && ) golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE )
143- $(if $(filter-out root,$* ) ,cd $* && ) golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m ) |.|" )
142+ $(MAKE ) golines.$*
143+
144+ .PHONY : golines
145+ golines : # # Runs golines for all modules in repository
146+ ifneq ($(wildcard $(REPO_ROOT ) /go.mod) ,)
147+ golines : golines.root
148+ endif
149+ ifneq ($(words $(GO_SUBMODULES_NO_DOCS ) ) ,0)
150+ golines : $(addprefix golines.,$(GO_SUBMODULES_NO_DOCS:/go.mod= ) )
151+ endif
152+
153+ .PHONY : golines.%
154+ golines.% : # # Runs golines for a specific module
155+ golines.% :
156+ $(if $(filter-out root,$* ) ,cd $* && ) golines -w --ignored-dirs external $$(GOWORK=off go list -tags e2e ./... | sed "s|^$$(GOWORK=off go list -m ) |.|" )
144157
145158.PHONY : mod-tidy
146159mod-tidy : # # Run go mod tidy for all modules
@@ -185,9 +198,9 @@ go-fix: $(addprefix go-fix.,$(GO_SUBMODULES_NO_DOCS:/go.mod=))
185198endif
186199
187200.PHONY : go-fix.%
188- go-fix.% : # # Runs golangci-lint for a specific module
201+ go-fix.% : # # Runs go fix for a specific module
189202go-fix.% : ; $(info $(M ) go fixing $* module)
190- $(if $(filter-out root,$* ) ,cd $* && ) go fix ./...
203+ $(if $(filter-out root,$* ) ,cd $* && ) go fix $$( GOWORK=off go list ./... | sed "s|^ $$( GOWORK=off go list -m ) |.|" | grep -v external )
191204
192205.PHONY : go-generate
193206go-generate : # # Runs go generate
@@ -210,7 +223,7 @@ go-generate: ; $(info $(M) running go generate)
210223 yq --inplace \
211224 --from-file=hack/update-webhook-configurations.yq \
212225 charts/cluster-api-runtime-extensions-nutanix/templates/webhooks.yaml
213- # $(MAKE) go-fix
226+ $(MAKE ) go-fix golines
214227 $(MAKE ) configure-csi-providers
215228 # Update anyOf schemas for resource.Quantity fields to only accept strings
216229 # until CAPI ClusterClass variables support anyOf schemas.
0 commit comments