Skip to content

ENVTEST_VERSION and ENVTEST_K8S_VERSION got incorrect values when using replace in go.mod #5088

@dmvolod

Description

@dmvolod

What broke? What's expected?

We use a replacement in go.mod for sigs.k8s.io/controller-runtime and k8s.io/api.
When running a make test in a kubebuilder generating project, the ENVTEST_VERSION and ENVTEST_K8S_VERSION values ​​are taken from the original go versions, rather than being replaced.

Reproducing this issue

Create basic kubebuilder project. Edit go/mod and replace sigs.k8s.io/controller-runtime and k8s.io/api component versions.

The main problem of this issue, that go list -m -f "{{ .Version }}" k8s.io/api command in Makefile doesn't utilize replace info in this manner. Seems to command should be like this

go list -m k8s.io/api | rev | cut -d' ' -f1 | rev | awk -F'[v.]' '{printf "1.%d", $$3}

Or can be optimized a bit with raw awk code, like

go list -m k8s.io/api | awk '{print $$NF}' | awk -F'[v.]' '{printf "1.%d", $$3}

KubeBuilder (CLI) Version

4.6.0

PROJECT version

3

Plugin versions

Other versions

No response

Extra Labels

No response

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions