You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prevent Unnecessary Version Bumps in go.mod During Go Version Updates (#20781)
* Prevent Unnecessary Version Bumps in `go.mod` During Go Version Updates
This PR addresses issue #20770, where the minikube automation (triggered by make `update-golang-version`) unnecessarily bumped minor or patch versions in `go.mod` when updating the Go version. Following Kubernetes' practice, which avoids such bumps in `go.mod`, this change ensures only the go directive is updated to the stable Go version.
**Changes:**
- Added `go.mod` to the schema map in `hack/update/golang_version/update_golang_version.go` with a regex (go 1\.\d+\.\d+) to update the go directive to {{.StableVersion}} (e.g., go 1.24.2).
- This ensures the automation updates only the go directive without modifying module dependencies, aligning with Kubernetes' `go.mod` behavior.
**Impact:**
- Running make `update-golang-version` now updates the go directive (e.g., from go 1.22.3 to go 1.24.2) without unintended dependency version bumps.
- Tested by setting go 1.22.3 in go.mod, running go mod tidy and make update-golang-version, and verifying only the go directive and toolchain changed.
fixes: #20773
* Pin `go.mod` to Major.Minor Go Version (e.g., `1.24.0`)
**Description**:
Fixes#20773 by updating the automation to pin the `go` directive in `go.mod` to the major.minor Go version (e.g., `1.24.0`) instead of the full version (e.g., `1.24.2`), aligning with Kubernetes’ `go.mod`. This prevents breaking users relying on minikube packages.
**Changes**:
- Modified `hack/update/golang_version/update_golang_version.go` to compute `MajorMinor` version (e.g., `1.24.0`) from `StableVersion`.
- Updated `schema` to set `go.mod`’s `go` directive to `{{.MajorMinor}}`.
- Tested by setting `go 1.23.4`, running `make update-golang-version`, and verifying `go 1.24.0` with no dependency bumps.
**Closes**: #20773
* Reverted all 66 files to upstream master except update_golang_version.go
Copy file name to clipboardExpand all lines: hack/update/golang_version/update_golang_version.go
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,11 @@ var (
36
36
}
37
37
38
38
schema=map[string]update.Item{
39
+
"go.mod": {
40
+
Replace: map[string]string{
41
+
`go 1\.\d+\.\d+`: `go {{.MajorMinor}}`, // Match and replace only the major.minor Go version
42
+
},
43
+
},
39
44
"Makefile": {
40
45
Replace: map[string]string{
41
46
// searching for 1.* so it does NOT match "KVM_GO_VERSION ?= $(GO_VERSION:.0=)" in the Makefile
@@ -74,8 +79,8 @@ var (
74
79
// Data holds stable Golang version - in full and in <major>.<minor> format
75
80
typeDatastruct {
76
81
StableVersionstring
82
+
MajorMinorstring// Major.minor version (e.g., 1.24.0)
77
83
K8SVersionstring// as of v1.23.0 Kubernetes uses k8s version in golang image name because: https://github.com/kubernetes/kubernetes/pull/103692#issuecomment-908659826
78
-
79
84
}
80
85
81
86
funcmain() {
@@ -91,8 +96,13 @@ func main() {
91
96
klog.Warningf("Golang stable version is a release candidate, skipping: %s", stable)
0 commit comments