Skip to content
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

Allow setting golang executable from environment variable #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
CWD := $(shell pwd)

GO ?= go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using different versions can cause unwanted confusion (for example go.mod/go.sum gets generated differently with 1.16 and 1.17) . best option is to stick to the required versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the default behavior will remain the same nonetheless. But sometimes we might need to test out multiple golang executable, usually when updating dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we temporarily set PATH and test it?


.DEFAULT_GOAL := help

# All variables are defined here
Expand All @@ -10,10 +12,10 @@ include hack/make/vars.mk
include hack/make/tools.mk

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
ifeq (,$(shell $(GO) env GOBIN))
GOBIN=$(shell $(GO) env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
GOBIN=$(shell $(GO) env GOBIN)
endif

# Setting SHELL to bash allows bash commands to be executed by recipes.
Expand Down Expand Up @@ -41,10 +43,10 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

fmt: ## Run go fmt against code.
go fmt ./...
$(GO) fmt ./...

vet: ## Run go vet against code.
go vet ./...
$(GO) vet ./...

golangci-lint: golangci-bin ## Run golangci-lint against code.
$(GOLANGCI_BIN) run ./...
Expand All @@ -53,14 +55,14 @@ kube-linter: kubelinter-bin ## Run kube-linter against YAML files
$(KUBELINTER_BIN) lint ./ --config ./.kube-linter-config.yaml

unit-test: ## Run unit tests
go test ./... -v -tags unit -coverprofile unit-cover.out
$(GO) test ./... -v -tags unit -coverprofile unit-cover.out

ENVTEST_ASSETS_DIR=$(CWD)/testbin
OPENSHIFT_CI ?= false
test: ## Run integration tests.
ifeq ($(OPENSHIFT_CI), true)
@echo "Running in OpenShift CI. Syncing vendor"
go mod tidy && go mod vendor
$(GO) mod tidy && $(GO) mod vendor
else
@echo "Running outside OpenShift CI. Ignoring vendor"
endif
Expand All @@ -72,10 +74,10 @@ endif
##@ Build

build: generate fmt vet golangci-lint kube-linter ## Build manager binary.
go build -o bin/manager main.go
$(GO) build -o bin/manager main.go

run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
$(GO) run ./main.go

docker-build: generate fmt vet golangci-lint kube-linter ## Build docker image with the manager.
docker build -t ${IMG} .
Expand Down Expand Up @@ -127,7 +129,7 @@ catalog-push: ## Push a catalog image.
##@ Actions

ensure-clean-workdir: ## Ensure all required changes are generated and committed
go mod tidy
$(GO) mod tidy
$(MAKE) manifests generate fmt vet
git --no-pager diff
git status --porcelain 2>&1 | tee /dev/stderr | (! read)