Skip to content

Commit b374e47

Browse files
authored
Update Go version (Azure#3890)
This was required as setup-envtest@latest no longer works with Go versions less than 1.22. controller-tools was also updated as it panics if 0.13.0 is used with Go 1.22. 0.14.0 must be used instead. Go version also moved to 1.21 to comply with new mod shape.
1 parent 6c47c53 commit b374e47

File tree

11 files changed

+40
-23
lines changed

11 files changed

+40
-23
lines changed

.devcontainer/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.137.0/containers/go/.devcontainer/base.Dockerfile
1+
# See here for image contents: https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/Dockerfile
22

33
# This is pinned to a particular version of go:
4-
FROM mcr.microsoft.com/vscode/devcontainers/go:0-1.20
4+
FROM mcr.microsoft.com/devcontainers/go:1.22
55

66
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
77
ARG TARGETARCH

.devcontainer/install-dependencies.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fi
9494

9595
# Ensure we have the right version of GO
9696

97-
#doc# | Go | 1.20 | https://golang.org/doc/install #
97+
#doc# | Go | 1.22 | https://golang.org/doc/install #
9898
if ! command -v go > /dev/null 2>&1; then
9999
write-error "Go must be installed manually; see https://golang.org/doc/install"
100100
exit 1
@@ -104,7 +104,7 @@ GOVER=$(go version)
104104
write-info "Go version: ${GOVER[*]}"
105105

106106
GOVERREGEX=".*go1.([0-9]+).([0-9]+).*"
107-
GOVERREQUIRED="go1.20.*"
107+
GOVERREQUIRED="go1.22.*"
108108
GOVERACTUAL=$(go version | { read _ _ ver _; echo "$ver"; })
109109

110110
if ! [[ $GOVERACTUAL =~ $GOVERREGEX ]]; then
@@ -113,7 +113,7 @@ if ! [[ $GOVERACTUAL =~ $GOVERREGEX ]]; then
113113
fi
114114

115115
GOMINORVER="${BASH_REMATCH[1]}"
116-
GOMINORREQUIRED=20
116+
GOMINORREQUIRED=22
117117

118118
# We allow for Go versions above the min version, but prevent versions below. This is safe given Go's back-compat guarantees
119119
if ! [[ $GOMINORVER -ge $GOMINORREQUIRED ]]; then
@@ -179,11 +179,11 @@ go-install() {
179179
fi
180180
}
181181

182-
#doc# | conversion-gen | v0.28.0 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
183-
go-install conversion-gen k8s.io/code-generator/cmd/[email protected].0
182+
#doc# | conversion-gen | v0.28.8 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
183+
go-install conversion-gen k8s.io/code-generator/cmd/[email protected].8
184184

185-
#doc# | controller-gen | v0.13.0 | https://book.kubebuilder.io/reference/controller-gen |
186-
go-install controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0
185+
#doc# | controller-gen | v0.14.0 | https://book.kubebuilder.io/reference/controller-gen |
186+
go-install controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0
187187

188188
#doc# | kind | v0.20.0 | https://kind.sigs.k8s.io/ |
189189
go-install kind sigs.k8s.io/[email protected]

.github/workflows/pr-validation.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,20 @@ jobs:
153153
if-no-files-found: error
154154
if: steps.check-changes.outputs.code-changed == 'true'
155155

156+
# Workaround for getting "Permission denied" errors when trying to perform code coverage upload
157+
- name: Take Ownership
158+
run: sudo chown -R $USER:$USER .
159+
160+
# We were using bash upload previously, but it's unsupported since 2022 and
161+
# seems to hang forever now. There seems to be significant throttling of tokenless requests (from forks)
162+
# errors like: Upload failed: {"detail":"Tokenless has reached GitHub rate limit. Please upload using a token:
163+
# https://docs.codecov.com/docs/adding-the-codecov-token. Expected available in 395 seconds."}
164+
# Unfortunately I don't see another choice for this so for now we'll live with it
156165
- name: Upload code coverage to Codecov
157-
run: bash <(curl -s https://codecov.io/bash)
158-
if: steps.check-changes.outputs.code-changed == 'true'
166+
uses: codecov/codecov-action@v4
167+
with:
168+
token: ${{ secrets.CODECOV_TOKEN }}
169+
verbose: true
159170

160171
# TODO: Changing this name requires changing the github API calls in pr-validation-fork.yml
161172
integration-tests:

Dockerfile

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

44
# need jq for running the Makefile
55
RUN curl -L -o /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && chmod +x /usr/local/bin/jq

Taskfile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ tasks:
9191
desc: Ensure all code is formatted
9292
dir: v2
9393
cmds:
94-
- gofumpt -l -s -w .
94+
- gofumpt -l -w .
9595

9696
build-docs-site:
9797
cmds:
@@ -620,7 +620,7 @@ tasks:
620620
- if [ -d "{{.CONTROLLER_OUTPUT}}/crd/generated/patches" ]; then find "{{.CONTROLLER_OUTPUT}}/crd/generated/patches" -type f -delete; fi
621621
- cd v2/api && controller-gen {{.OBJECT_OPTIONS}} paths=./...
622622
- cd v2/api && controller-gen {{.CRD_OPTIONS}} {{.WEBHOOK_OPTIONS}} {{.RBAC_OPTIONS}} paths=./...
623-
- cd v2/api && gofumpt -l -s -w . # format all generated code
623+
- cd v2/api && gofumpt -l -w . # format all generated code
624624
vars:
625625
OBJECT_OPTIONS: object:headerFile={{.HEADER_FILE}}
626626
CRD_OPTIONS: crd:crdVersions=v1,allowDangerousTypes=true output:crd:artifacts:config={{.CONTROLLER_OUTPUT}}/crd/generated/bases
@@ -1040,7 +1040,7 @@ tasks:
10401040
- if [ -d "{{.CROSSPLANE_OUTPUT}}/crd/patches" ]; then find "{{.CROSSPLANE_OUTPUT}}/crd/patches" -type f -delete; fi
10411041
- cd apis && controller-gen {{.OBJECT_OPTIONS}} paths=./...
10421042
- cd apis && controller-gen {{.CRD_OPTIONS}} {{.WEBHOOK_OPTIONS}} {{.RBAC_OPTIONS}} paths=./...
1043-
- cd apis && gofumpt -l -s -w . # format all generated code
1043+
- cd apis && gofumpt -l -w . # format all generated code
10441044
vars:
10451045
OBJECT_OPTIONS: object:headerFile={{.HEADER_FILE}}
10461046
CRD_OPTIONS: crd:crdVersions=v1,allowDangerousTypes=true output:crd:artifacts:config={{.CROSSPLANE_OUTPUT}}/crd/bases

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
displayName: 'Validate Source'
7373
continueOnError: 'false'
7474
75-
75+
# TODO: Tried to update to Go 1.22 but failed, see https://github.com/microsoft/azure-pipelines-tasks/issues/19690
7676
- task: GoTool@0
7777
displayName: Get Go 1.20
7878
condition: or(eq(variables['check_changes.SOURCE_CODE_CHANGED'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

docs/hugo/content/contributing/dependencies.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ If you prefer to install those dependencies manually (instead of using the `.dev
1212
| AZWI | v1.2.0 | https://github.com/Azure/azure-workload-identity |
1313
| BuildX | v0.11.2 | https://github.com/docker/buildx |
1414
| cmctl | latest | https://cert-manager.io/docs/reference/cmctl |
15-
| controller-gen | v0.13.0 | https://book.kubebuilder.io/reference/controller-gen |
16-
| conversion-gen | v0.28.0 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
15+
| controller-gen | v0.14.0 | https://book.kubebuilder.io/reference/controller-gen |
16+
| conversion-gen | v0.28.8 | https://pkg.go.dev/k8s.io/code-generator/cmd/conversion-gen |
1717
| gen-crd-api-reference-docs | 11fe95cb | https://github.com/ahmetb/gen-crd-api-reference-docs |
18-
| Go | 1.20 | https://golang.org/doc/install #
18+
| Go | 1.22 | https://golang.org/doc/install #
1919
| gofumpt | latest | https://pkg.go.dev/mvdan.cc/gofumpt |
2020
| golangci-lint | 1.51.2 | https://github.com/golangci/golangci-lint |
2121
| Helm | v3.8.0 | https://helm.sh/ |

v2/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG VERSION_FLAGS
33

44
# Build the manager binary
5-
FROM golang:1.20 as builder
5+
FROM golang:1.22 as builder
66
ARG VERSION_FLAGS
77

88
WORKDIR /workspace/

v2/cmd/asoctl/go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/Azure/azure-service-operator/v2/cmd/asoctl
22

3-
go 1.20
3+
go 1.21
4+
5+
toolchain go1.21.8
46

57
replace github.com/Azure/azure-service-operator/v2 => ../../
68

v2/go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/Azure/azure-service-operator/v2
22

3-
go 1.20
3+
go 1.21
4+
5+
toolchain go1.21.8
46

57
require (
68
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0

v2/tools/generator/go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/Azure/azure-service-operator/v2/tools/generator
22

3-
go 1.20
3+
go 1.21
4+
5+
toolchain go1.21.8
46

57
// Needed to reference shared version numbering:
68
replace github.com/Azure/azure-service-operator/v2 => ../../

0 commit comments

Comments
 (0)