Skip to content

build: Make module-relative "go list -m" compatible with GOWORK #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/apis.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ api.sync.%: ; $(info $(M) syncing external API: $(PROVIDER_MODULE_$*)/$(PROVIDER
--exclude='*webhook*.go' \
--exclude='*test.go' \
--exclude='s3bucket.go' \
$$(cd $(PROVIDER_MODULE_DIR) && go list -m -f '{{ .Dir }}' $(PROVIDER_MODULE_$*))/$(PROVIDER_API_PATH_$*)/$(PROVIDER_API_VERSION_$*)/*.go \
$$(cd $(PROVIDER_MODULE_DIR) && GOWORK=off go list -m -f '{{ .Dir }}' $(PROVIDER_MODULE_$*))/$(PROVIDER_API_PATH_$*)/$(PROVIDER_API_VERSION_$*)/*.go \
$(PROVIDER_API_DIR)
find $(PROVIDER_API_DIR) -type d -exec chmod 0755 {} \;
find $(PROVIDER_API_DIR) -type f -exec chmod 0644 {} \;
10 changes: 5 additions & 5 deletions make/clusterctl.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2023 Nutanix. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

export CAPI_VERSION := $(shell go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api)
export CAPD_VERSION := $(shell go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api/test)
export CAPA_VERSION := $(shell cd hack/third-party/capa && go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api-provider-aws/v2)
export CAPX_VERSION := $(shell cd hack/third-party/capx && go list -m -f '{{ .Version }}' github.com/nutanix-cloud-native/cluster-api-provider-nutanix)
export CAAPH_VERSION := $(shell cd hack/third-party/caaph && go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api-addon-provider-helm)
export CAPI_VERSION := $(shell GOWORK=off go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api)
export CAPD_VERSION := $(shell GOWORK=off go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api/test)
export CAPA_VERSION := $(shell cd hack/third-party/capa && GOWORK=off go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api-provider-aws/v2)
export CAPX_VERSION := $(shell cd hack/third-party/capx && GOWORK=off go list -m -f '{{ .Version }}' github.com/nutanix-cloud-native/cluster-api-provider-nutanix)
export CAAPH_VERSION := $(shell cd hack/third-party/caaph && GOWORK=off go list -m -f '{{ .Version }}' sigs.k8s.io/cluster-api-addon-provider-helm)

# Leave Nutanix credentials empty here and set it when creating the clusters
.PHONY: clusterctl.init
Expand Down
4 changes: 2 additions & 2 deletions make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ endif
.PHONY: lint.%
lint.%: ## Runs golangci-lint for a specific module
lint.%: ; $(info $(M) linting $* module)
$(if $(filter-out root,$*),cd $* && )golines -w $$(go list -tags e2e ./... | grep -v external | sed "s|^$$(go list -m)|.|")
$(if $(filter-out root,$*),cd $* && )golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m)|.|")
$(if $(filter-out root,$*),cd $* && )golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE)
$(if $(filter-out root,$*),cd $* && )golines -w $$(go list -tags e2e ./... | grep -v external | sed "s|^$$(go list -m)|.|")
$(if $(filter-out root,$*),cd $* && )golines -w $$(GOWORK=off go list -tags e2e ./... | grep -v external | sed "s|^$$(GOWORK=off go list -m)|.|")

.PHONY: mod-tidy
mod-tidy: ## Run go mod tidy for all modules
Expand Down
2 changes: 2 additions & 0 deletions test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
goruntime "runtime"
Expand Down Expand Up @@ -200,6 +201,7 @@ func getFilePathsToCAPICRDs() []string {
func getModulePath(moduleDir, moduleName string) string {
cmd := exec.Command("go", "list", "-m", "-f", "{{ .Dir }}", moduleName)
cmd.Dir = moduleDir
cmd.Env = append(os.Environ(), "GOWORK=off")
out, err := cmd.CombinedOutput()
if err != nil {
// We include the combined output because the error is usually
Expand Down
Loading