From c8a8299f67c00bd7ed44e440a44e520f925fe9b9 Mon Sep 17 00:00:00 2001
From: justinsb
Date: Wed, 29 Jan 2025 11:25:52 -0500
Subject: [PATCH 1/2] chore: create script to update golang
---
dev/codebots/update-golang-version | 58 ++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100755 dev/codebots/update-golang-version
diff --git a/dev/codebots/update-golang-version b/dev/codebots/update-golang-version
new file mode 100755
index 00000000..3b36c32a
--- /dev/null
+++ b/dev/codebots/update-golang-version
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+# Copyright 2022 The Kubernetes Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# Helper script to update golang to latest version
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+cd ${REPO_ROOT}
+
+# TODO: Should we update to the latest go, or the latest go in a particular minor?
+GO_TOOLCHAIN=$(curl https://go.dev/dl/?mode=json | jq -r '[.[] | select(.stable == true)] | .[0].version')
+echo "GO_TOOLCHAIN=$GO_TOOLCHAIN"
+
+git switch --force-create codebot-update-golang-version-${GO_TOOLCHAIN}
+
+# GO_VERSION is the GO_TOOLCHAIN without the go prefix
+GO_VERSION=${GO_TOOLCHAIN#go}
+echo "GO_VERSION=$GO_VERSION"
+
+# Update go.mod files
+# Tidy each individual go.mod
+for gomod_file in $(find "${REPO_ROOT}" -name "go.mod"); do
+ dir=$(dirname ${gomod_file})
+ cd "${dir}"
+ echo "Updating $gomod_file to toolchain $GO_TOOLCHAIN"
+ go mod edit -toolchain=${GO_TOOLCHAIN}
+done
+
+# Update Docker images
+for dockerfile in $(find "${REPO_ROOT}" -name "Dockerfile*"); do
+ echo "Updating Dockerfile $dockerfile to go image $GO_VERSION"
+ sed -i -e "s/FROM golang:[0-9.]*/FROM golang:$GO_VERSION/g" $dockerfile
+done
+
+if $(git diff --quiet); then
+ echo "No changes"
+else
+ cd ${REPO_ROOT}
+ git add .
+ git commit -m "codebot: update go to ${GO_VERSION}"
+fi
From a32343a6ad33816a90e258d1313535b5fa71f036 Mon Sep 17 00:00:00 2001
From: justinsb
Date: Wed, 29 Jan 2025 11:32:26 -0500
Subject: [PATCH 2/2] codebot: update go to 1.23.5
---
applylib/go.mod | 2 +-
examples/guestbook-operator/Dockerfile | 2 +-
examples/guestbook-operator/go.mod | 2 +-
go.mod | 2 +-
ktest/go.mod | 2 +-
mockkubeapiserver/go.mod | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/applylib/go.mod b/applylib/go.mod
index a2fc731f..1a1bc83b 100644
--- a/applylib/go.mod
+++ b/applylib/go.mod
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/applylib
go 1.22.0
-toolchain go1.23.1
+toolchain go1.23.5
// Sometimes handy for development, but breaks usage as a library
// Instead, please break apart commits to this module
diff --git a/examples/guestbook-operator/Dockerfile b/examples/guestbook-operator/Dockerfile
index e8511b29..57d0fca4 100644
--- a/examples/guestbook-operator/Dockerfile
+++ b/examples/guestbook-operator/Dockerfile
@@ -1,5 +1,5 @@
# Build the manager binary
-FROM golang:1.17 as builder
+FROM golang:1.23.5 as builder
# Copy in the go src
WORKDIR /workspace
diff --git a/examples/guestbook-operator/go.mod b/examples/guestbook-operator/go.mod
index 01339e3c..3a505ab7 100644
--- a/examples/guestbook-operator/go.mod
+++ b/examples/guestbook-operator/go.mod
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/examples/guestbook-operator
go 1.22.0
-toolchain go1.22.4
+toolchain go1.23.5
require (
github.com/go-logr/logr v1.4.2
diff --git a/go.mod b/go.mod
index 26f5e363..ab8a9c5e 100644
--- a/go.mod
+++ b/go.mod
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern
go 1.22.0
-toolchain go1.22.4
+toolchain go1.23.5
// Sometimes handy for development, but breaks usage as a library
// Instead, please break apart commits to this module
diff --git a/ktest/go.mod b/ktest/go.mod
index b3244eb9..297abb75 100644
--- a/ktest/go.mod
+++ b/ktest/go.mod
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/ktest
go 1.22.0
-toolchain go1.23.1
+toolchain go1.23.5
require (
github.com/google/go-cmp v0.6.0
diff --git a/mockkubeapiserver/go.mod b/mockkubeapiserver/go.mod
index 52f007fa..4b7ad860 100644
--- a/mockkubeapiserver/go.mod
+++ b/mockkubeapiserver/go.mod
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/mockkubeapiserver
go 1.22.0
-toolchain go1.23.1
+toolchain go1.23.5
require (
github.com/google/go-cmp v0.6.0