Skip to content

Commit f9f4f9f

Browse files
authored
Merge pull request #413 from justinsb/codebot-update-golang-version-go1.23.5
chore: script to update golang; update go to 1.23.5
2 parents 371c146 + a32343a commit f9f4f9f

File tree

7 files changed

+64
-6
lines changed

7 files changed

+64
-6
lines changed

Diff for: applylib/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/applylib
22

33
go 1.22.0
44

5-
toolchain go1.23.1
5+
toolchain go1.23.5
66

77
// Sometimes handy for development, but breaks usage as a library
88
// Instead, please break apart commits to this module

Diff for: dev/codebots/update-golang-version

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Copyright 2022 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# Helper script to update golang to latest version
19+
20+
set -o errexit
21+
set -o nounset
22+
set -o pipefail
23+
24+
REPO_ROOT=$(git rev-parse --show-toplevel)
25+
cd ${REPO_ROOT}
26+
27+
# TODO: Should we update to the latest go, or the latest go in a particular minor?
28+
GO_TOOLCHAIN=$(curl https://go.dev/dl/?mode=json | jq -r '[.[] | select(.stable == true)] | .[0].version')
29+
echo "GO_TOOLCHAIN=$GO_TOOLCHAIN"
30+
31+
git switch --force-create codebot-update-golang-version-${GO_TOOLCHAIN}
32+
33+
# GO_VERSION is the GO_TOOLCHAIN without the go prefix
34+
GO_VERSION=${GO_TOOLCHAIN#go}
35+
echo "GO_VERSION=$GO_VERSION"
36+
37+
# Update go.mod files
38+
# Tidy each individual go.mod
39+
for gomod_file in $(find "${REPO_ROOT}" -name "go.mod"); do
40+
dir=$(dirname ${gomod_file})
41+
cd "${dir}"
42+
echo "Updating $gomod_file to toolchain $GO_TOOLCHAIN"
43+
go mod edit -toolchain=${GO_TOOLCHAIN}
44+
done
45+
46+
# Update Docker images
47+
for dockerfile in $(find "${REPO_ROOT}" -name "Dockerfile*"); do
48+
echo "Updating Dockerfile $dockerfile to go image $GO_VERSION"
49+
sed -i -e "s/FROM golang:[0-9.]*/FROM golang:$GO_VERSION/g" $dockerfile
50+
done
51+
52+
if $(git diff --quiet); then
53+
echo "No changes"
54+
else
55+
cd ${REPO_ROOT}
56+
git add .
57+
git commit -m "codebot: update go to ${GO_VERSION}"
58+
fi

Diff for: examples/guestbook-operator/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.17 as builder
2+
FROM golang:1.23.5 as builder
33

44
# Copy in the go src
55
WORKDIR /workspace

Diff for: examples/guestbook-operator/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/examples/guestbook-operator
22

33
go 1.22.0
44

5-
toolchain go1.22.4
5+
toolchain go1.23.5
66

77
require (
88
github.com/go-logr/logr v1.4.2

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern
22

33
go 1.22.0
44

5-
toolchain go1.22.4
5+
toolchain go1.23.5
66

77
// Sometimes handy for development, but breaks usage as a library
88
// Instead, please break apart commits to this module

Diff for: ktest/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/ktest
22

33
go 1.22.0
44

5-
toolchain go1.23.1
5+
toolchain go1.23.5
66

77
require (
88
github.com/google/go-cmp v0.6.0

Diff for: mockkubeapiserver/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/mockkubeapiserver
22

33
go 1.22.0
44

5-
toolchain go1.23.1
5+
toolchain go1.23.5
66

77
require (
88
github.com/google/go-cmp v0.6.0

0 commit comments

Comments
 (0)