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

RFC: Makefile: fetch GOLANG_VERSION from go.mod #1047

Open
wants to merge 1 commit into
base: incubation
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
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ YQ_VERSION ?= v4.12.2
ENVTEST_K8S_VERSION = 1.24.2
ENVTEST_PACKAGE_VERSION = v0.0.0-20240320141353-395cfc7486e6
CRD_REF_DOCS_VERSION = 0.0.11
GOLANG_VERSION := $(shell sed -n '/^go/s/go \(.*\)/\1/p' < go.mod)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the name shouldn't be REQUIRED_GOLANG_VERSION. IIUC the goal here is to ensure we build against this exact version.


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -93,6 +94,7 @@ E2E_TEST_FLAGS = "--skip-deletion=false" -timeout 20m # See README.md, default g
# set to "true" to use local instead
# see target "image-build"
IMAGE_BUILD_FLAGS ?= --build-arg USE_LOCAL=false
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this one used anywhere after rename. Am I missing some other piece that depends on IMAGE_BUILD_FLAGS? Or is it intended now to be a customization point for the caller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see this one used anywhere after rename. Am I missing some other piece that depends on IMAGE_BUILD_FLAGS? Or is it intended now to be a customization point for the caller?

Yes, for you :) I remember you told that you have it in some alias.

IMAGE_BUILD_FLAGS_ALL := --build-arg GOLANG_VERSION=$(GOLANG_VERSION) $(IMAGE_BUILD_FLAGS)

# Read any custom variables overrides from a local.mk file. This will only be read if it exists in the
# same directory as this Makefile. Variables can be specified in the standard format supported by
Expand Down Expand Up @@ -172,7 +174,13 @@ CLEANFILES += odh-manifests/*
api-docs: crd-ref-docs ## Creates API docs using https://github.com/elastic/crd-ref-docs
$(CRD_REF_DOCS) --source-path ./ --output-path ./docs/api-overview.md --renderer markdown --config ./crd-ref-docs.config.yaml && \
egrep -v '\.io/[^v][^1].*)$$' ./docs/api-overview.md > temp.md && mv ./temp.md ./docs/api-overview.md


.PHONY: go-version-update
golang-version-update:
for f in Dockerfiles/*; do \
sed -i -e 's/\(ARG GOLANG_VERSION=\).*/\1$(GOLANG_VERSION)/g' $$f ; \
done

Copy link
Member

Choose a reason for hiding this comment

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

but "make build" is still using the local Go, which can be different version from go.mod, right?

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 it is out of scope of go updates (#811) anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

@ykaliuta Can you list steps one needs to take now in order to perform a correct golang version bump for this project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure:

  1. update the version in go.mod
  2. run make golang-version-update
  3. commit the changes to git and create a pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally do not see it really necessary to have default version in the Dockerfiles, #811 (comment) but I was told that people can use it

##@ Build

.PHONY: build
Expand All @@ -185,7 +193,7 @@ run: manifests generate fmt vet ## Run a controller from your host.

.PHONY: image-build
image-build: # unit-test ## Build image with the manager.
$(IMAGE_BUILDER) build --no-cache -f Dockerfiles/Dockerfile ${IMAGE_BUILD_FLAGS} -t $(IMG) .
$(IMAGE_BUILDER) build --no-cache -f Dockerfiles/Dockerfile $(IMAGE_BUILD_FLAGS_ALL) -t $(IMG) .

.PHONY: image-push
image-push: ## Push image with the manager.
Expand Down Expand Up @@ -335,7 +343,7 @@ catalog-build: opm ## Build a catalog image.
catalog-push: ## Push a catalog image.
$(MAKE) image-push IMG=$(CATALOG_IMG)

TOOLBOX_GOLANG_VERSION := 1.20
TOOLBOX_GOLANG_VERSION := $(GOLANG_VERSION)
TOOLBOX_OPERATOR_SDK_VERSION := 1.24.1

# Generate a Toolbox container for locally testing changes easily
Expand Down
Loading