Skip to content

Commit

Permalink
🐛 revert the change to use envtest version based on controller-runtim…
Browse files Browse the repository at this point in the history
…e branch releases
  • Loading branch information
camilamacedo86 committed Jan 28, 2024
1 parent 885b45a commit 564df98
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/cronjob-tutorial/testdata/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 10 additions & 25 deletions pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package templates

import (
"strings"

"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
)

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup-with-deploy-image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-multigroup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-with-deploy-image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4-with-grafana/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 564df98

Please sign in to comment.