Skip to content

Commit

Permalink
[release/v0.6] Upgrade go version to 1.23 (#585)
Browse files Browse the repository at this point in the history
* Upgrade go version to 1.23

Signed-off-by: Vatsal Parekh <[email protected]>

* Update golangci-lint to v1.63.4 for Go 1.23 support

* Add codegen fix for Go 1.23 support

---------

Signed-off-by: Vatsal Parekh <[email protected]>
Co-authored-by: Tom Lebreux <[email protected]>
  • Loading branch information
vatsalparekh and tomleb authored Jan 14, 2025
1 parent 638b624 commit 84f6d2a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.suse.com/bci/golang:1.22
FROM registry.suse.com/bci/golang:1.23

ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
Expand All @@ -11,7 +11,7 @@ RUN zypper -n install git docker vim less file curl wget awk
RUN curl -sL https://get.helm.sh/helm-${HELM_VERSION}-linux-${ARCH}.tar.gz | tar xvzf - -C /usr/local/bin --strip-components=1

RUN if [ "${ARCH}" = "amd64" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.1; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.63.4; \
helm plugin install https://github.com/helm-unittest/helm-unittest.git --version ${HELM_UNITTEST_VERSION}>/out.txt 2>&1; \
fi

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/rancher/webhook

go 1.22.0
go 1.23.0

toolchain go1.22.7
toolchain go1.23.4

replace (
github.com/rancher/rke => github.com/rancher/rke v1.6.2
Expand Down
5 changes: 5 additions & 0 deletions pkg/codegen/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Turn off creation of Alias types, which break code generation.
// This can be removed after migrating to k8s 1.32 code generators that are aware of the new type.
// For more details see https://github.com/rancher/rancher/issues/47207
//go:debug gotypesalias=0

package main

import (
Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/common/psa-validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ var psaLabels = []string{

// IsUpdatingPSAConfig will indicate whether or not the labels being passed in
// are attempting to update PSA-related configuration.
func IsUpdatingPSAConfig(old map[string]string, new map[string]string) bool {
func IsUpdatingPSAConfig(oldLabels map[string]string, newLabels map[string]string) bool {
for _, label := range psaLabels {
if old[label] != new[label] {
if oldLabels[label] != newLabels[label] {
return true
}
}
Expand All @@ -34,8 +34,8 @@ func IsUpdatingPSAConfig(old map[string]string, new map[string]string) bool {

// IsCreatingPSAConfig will indicate whether or not the labels being passed in
// are attempting to create PSA-related configuration.
func IsCreatingPSAConfig(new map[string]string) bool {
for label := range new {
func IsCreatingPSAConfig(newLabels map[string]string) bool {
for label := range newLabels {
if slices.Contains(psaLabels, label) {
return true
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/resources/management.cattle.io/v3/feature/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ func (a *admitter) Admit(request *admission.Request) (*admissionv1.AdmissionResp

// isUpdateAllowed checks that the new value does not change on spec unless it's equal to the lockedValue,
// or lockedValue is nil.
func isUpdateAllowed(old, new *v3.Feature) bool {
if old == nil || new == nil {
func isUpdateAllowed(oldFeature, newFeature *v3.Feature) bool {
if oldFeature == nil || newFeature == nil {
return false
}
if new.Status.LockedValue == nil {
if newFeature.Status.LockedValue == nil {
return true
}
if old.Spec.Value == nil && new.Spec.Value == nil {
if oldFeature.Spec.Value == nil && newFeature.Spec.Value == nil {
return true
}
if old.Spec.Value != nil && new.Spec.Value != nil && *old.Spec.Value == *new.Spec.Value {
if oldFeature.Spec.Value != nil && newFeature.Spec.Value != nil && *oldFeature.Spec.Value == *newFeature.Spec.Value {
return true
}
if new.Spec.Value != nil && *new.Spec.Value == *new.Status.LockedValue {
if newFeature.Spec.Value != nil && *newFeature.Spec.Value == *newFeature.Status.LockedValue {
return true
}
return false
Expand Down

0 comments on commit 84f6d2a

Please sign in to comment.