From 2ea688a54b6bcc8ea15b5e35dbc98ad5786873ae Mon Sep 17 00:00:00 2001 From: Pooya Azarpour Date: Mon, 18 Mar 2024 19:39:05 +0330 Subject: [PATCH] [ADD] Add GO_EXEC variable for using multiply version of go binary Signed-off-by: Pooya Azarpour --- Makefile | 14 +++++++------- Makefile.restic-integration.vars.mk | 2 +- Makefile.vars.mk | 1 + e2e/kind.mk | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 0d3e4b409..5ac35a5fb 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ include Makefile.restic-integration.mk envtest/integration.mk # E2E tests -include e2e/Makefile -go_build ?= go build -o $(BIN_FILENAME) $(K8UP_MAIN_GO) +go_build ?= $(GO_EXEC) build -o $(BIN_FILENAME) $(K8UP_MAIN_GO) .PHONY: test test: ## Run tests - go test ./... -coverprofile cover.out + $(GO_EXEC) test ./... -coverprofile cover.out .PHONY: build build: generate fmt vet $(BIN_FILENAME) docs-update-usage ## Build manager binary @@ -41,7 +41,7 @@ run: export BACKUP_ENABLE_LEADER_ELECTION = $(ENABLE_LEADER_ELECTION) run: export K8UP_DEBUG = true run: export BACKUP_OPERATOR_NAMESPACE = default run: fmt vet ## Run against the configured Kubernetes cluster in ~/.kube/config. Use ARGS to pass arguments to the command, e.g. `make run ARGS="--help"` - go run $(K8UP_MAIN_GO) $(ARGS) $(CMD) $(CMD_ARGS) + $(GO_EXEC) run $(K8UP_MAIN_GO) $(ARGS) $(CMD) $(CMD_ARGS) .PHONY: run-operator run-operator: CMD := operator @@ -80,9 +80,9 @@ deploy: kind-load-image install ## Deploy controller in the configured Kubernete .PHONY: generate generate: ## Generate manifests e.g. CRD, RBAC etc. # Generate code - go run sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile=".github/boilerplate.go.txt" paths="./..." + $(GO_EXEC) run sigs.k8s.io/controller-tools/cmd/controller-gen object:headerFile=".github/boilerplate.go.txt" paths="./..." # Generate CRDs - go run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=$(CRD_ROOT_DIR)/v1 crd:crdVersions=v1 + $(GO_EXEC) run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=$(CRD_ROOT_DIR)/v1 crd:crdVersions=v1 .PHONY: crd crd: generate ## Generate CRD to file @@ -90,11 +90,11 @@ crd: generate ## Generate CRD to file .PHONY: fmt fmt: ## Run go fmt against code - go fmt ./... + $(GO_EXEC) fmt ./... .PHONY: vet vet: ## Run go vet against code - go vet ./... + $(GO_EXEC) vet ./... .PHONY: lint lint: fmt vet golangci-lint ## Invokes all linting targets diff --git a/Makefile.restic-integration.vars.mk b/Makefile.restic-integration.vars.mk index d3d0e2ff4..0555f857d 100644 --- a/Makefile.restic-integration.vars.mk +++ b/Makefile.restic-integration.vars.mk @@ -13,7 +13,7 @@ restore_dir ?= $(integrationtest_dir)/restore stats_url ?= http://localhost:8091 -restic_version ?= $(shell go mod edit -json | jq -r '.Require[] | select(.Path == "github.com/restic/restic").Version' | sed "s/v//") +restic_version ?= $(shell $(GO_EXEC) mod edit -json | jq -r '.Require[] | select(.Path == "github.com/restic/restic").Version' | sed "s/v//") restic_path ?= $(go_bin)/restic restic_pid ?= $(integrationtest_dir)/restic.pid restic_url ?= https://github.com/restic/restic/releases/download/v$(restic_version)/restic_$(restic_version)_$(os)_$(arch).bz2 diff --git a/Makefile.vars.mk b/Makefile.vars.mk index 781dc9e7b..9c0af0a7a 100644 --- a/Makefile.vars.mk +++ b/Makefile.vars.mk @@ -1,5 +1,6 @@ IMG_TAG ?= latest +GO_EXEC ?= go K8UP_MAIN_GO ?= cmd/k8up/main.go K8UP_GOOS ?= linux K8UP_GOARCH ?= amd64 diff --git a/e2e/kind.mk b/e2e/kind.mk index 901fef148..ea752fdff 100644 --- a/e2e/kind.mk +++ b/e2e/kind.mk @@ -34,4 +34,4 @@ $(KIND_KUBECONFIG): $(KIND) $(KIND): export GOBIN = $(go_bin) $(KIND): | $(go_bin) - go install sigs.k8s.io/kind@latest + $(GO_EXEC) install sigs.k8s.io/kind@latest