From 564df982fe2bc674b279fed0171780d6cc2dfcab Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 27 Jan 2024 08:57:12 +0000 Subject: [PATCH] :bug: revert the change to use envtest version based on controller-runtime branch releases --- .../testdata/project/Makefile | 2 +- .../testdata/project/Makefile | 2 +- .../scaffolds/internal/templates/makefile.go | 35 ++++++------------- .../Makefile | 2 +- testdata/project-v4-multigroup/Makefile | 2 +- .../project-v4-with-deploy-image/Makefile | 2 +- testdata/project-v4-with-grafana/Makefile | 2 +- testdata/project-v4/Makefile | 2 +- 8 files changed, 17 insertions(+), 32 deletions(-) diff --git a/docs/book/src/component-config-tutorial/testdata/project/Makefile b/docs/book/src/component-config-tutorial/testdata/project/Makefile index 9df78666630..39aea442b52 100644 --- a/docs/book/src/component-config-tutorial/testdata/project/Makefile +++ b/docs/book/src/component-config-tutorial/testdata/project/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Makefile b/docs/book/src/cronjob-tutorial/testdata/project/Makefile index 9df78666630..39aea442b52 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Makefile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go index a04392c86df..667aef73350 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go @@ -17,8 +17,6 @@ limitations under the License. package templates import ( - "strings" - "sigs.k8s.io/kubebuilder/v3/pkg/machinery" ) @@ -40,8 +38,8 @@ type Makefile struct { KustomizeVersion string // ControllerRuntimeVersion version to be used to download the envtest setup script ControllerRuntimeVersion string - // ControllerRuntimeReleaseBranchName store the name of the branch to be used to install setup-envtest - ControllerRuntimeReleaseBranchName string + // EnvtestVersion store the name of the verions to be used to install setup-envtest + EnvtestVersion string } // SetTemplateDefaults implements file.Template @@ -58,30 +56,17 @@ func (f *Makefile) SetTemplateDefaults() error { f.Image = "controller:latest" } - if f.ControllerRuntimeReleaseBranchName == "" { - f.ControllerRuntimeReleaseBranchName = getControllerRuntimeReleaseBranch(f.ControllerRuntimeVersion) + // TODO: Looking for ways to tag the controller-runtime + // release using tag versions. Note that we cannot + // relay upon the branch since we cannot ensure that + // it will be generated for all releases. We must be + // able to use the tag. + if f.EnvtestVersion == "" { + f.EnvtestVersion = "latest" } - return nil } -func getControllerRuntimeReleaseBranch(version string) string { - // Remove the "v" prefix - version = strings.TrimPrefix(version, "v") - - // Split the version string into its components - parts := strings.SplitN(version, ".", 3) - - // Check if we have at least two components (major and minor) - if len(parts) < 2 { - // return latest working version as invalid - return "latest" - } - - // Return the formatted version - return "release-" + parts[0] + "." + parts[1] -} - //nolint:lll const makefileTemplate = ` # Image URL to use all building/pushing image targets @@ -254,7 +239,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= {{ .KustomizeVersion }} CONTROLLER_TOOLS_VERSION ?= {{ .ControllerToolsVersion }} -ENVTEST_VERSION ?= {{ .ControllerRuntimeReleaseBranchName }} +ENVTEST_VERSION ?= {{ .EnvtestVersion }} GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/testdata/project-v4-multigroup-with-deploy-image/Makefile b/testdata/project-v4-multigroup-with-deploy-image/Makefile index 9df78666630..39aea442b52 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/Makefile +++ b/testdata/project-v4-multigroup-with-deploy-image/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/testdata/project-v4-multigroup/Makefile b/testdata/project-v4-multigroup/Makefile index 9df78666630..39aea442b52 100644 --- a/testdata/project-v4-multigroup/Makefile +++ b/testdata/project-v4-multigroup/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/testdata/project-v4-with-deploy-image/Makefile b/testdata/project-v4-with-deploy-image/Makefile index 9df78666630..39aea442b52 100644 --- a/testdata/project-v4-with-deploy-image/Makefile +++ b/testdata/project-v4-with-deploy-image/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/testdata/project-v4-with-grafana/Makefile b/testdata/project-v4-with-grafana/Makefile index 9df78666630..39aea442b52 100644 --- a/testdata/project-v4-with-grafana/Makefile +++ b/testdata/project-v4-with-grafana/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize diff --git a/testdata/project-v4/Makefile b/testdata/project-v4/Makefile index 9df78666630..39aea442b52 100644 --- a/testdata/project-v4/Makefile +++ b/testdata/project-v4/Makefile @@ -165,7 +165,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions KUSTOMIZE_VERSION ?= v5.3.0 CONTROLLER_TOOLS_VERSION ?= v0.14.0 -ENVTEST_VERSION ?= release-0.17 +ENVTEST_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.54.2 .PHONY: kustomize