Skip to content

Commit 33369e1

Browse files
committed
bump to golang 1.24
* bump in go.mod (base and api) * bump go-toolset in Dockerfile * bump in github jobs ('.github/workflows') * Bump the golangci-lint version in the .pre-commit-config.yaml to v2.4.0 * Bump build_root_image in .ci-operator.yaml to ci-build-root-golang-1.24-sdk-1.31 Also fixes golangci-lint reported issues for new v2.4.0 version. Jira: OSPRH-12935 Signed-off-by: Martin Schuppert <mschuppert@redhat.com> Co-authored-by: Claude (Anthropic) claude@anthropic.com
1 parent 7cfe04e commit 33369e1

16 files changed

Lines changed: 43 additions & 35 deletions

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: tools
33
namespace: openstack-k8s-operators
4-
tag: ci-build-root-golang-1.21-sdk-1.31
4+
tag: ci-build-root-golang-1.24-sdk-1.31

.github/workflows/build-neutron-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/reusable-build-operator.yaml@main
1616
with:
1717
operator_name: neutron
18-
go_version: 1.21.x
18+
go_version: 1.24.x
1919
operator_sdk_version: 1.31.0
2020
secrets:
2121
IMAGENAMESPACE: ${{ secrets.IMAGENAMESPACE }}

.github/workflows/force-bump-pr-manual.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ jobs:
99
with:
1010
operator_name: neutron
1111
branch_name: ${{ github.ref_name }}
12+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
1213
secrets:
1314
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.github/workflows/force-bump-pr-scheduled.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ jobs:
1010
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
1111
with:
1212
operator_name: neutron
13+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
1314
secrets:
1415
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.golangci.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
version: 2
2+
13
linters:
24
# Enable specific linter
35
# https://golangci-lint.run/usage/linters/#enabled-by-default
46
enable:
57
- errorlint
68
- revive
79
- ginkgolinter
8-
- gofmt
910
- govet
1011
- gosec
1112
- errname
1213
- err113
14+
15+
formatters:
16+
enable:
17+
- gofmt
18+
1319
run:
1420
timeout: 5m
15-
16-
issues:
17-
exclude-rules:
18-
- path: '(.+)_test\.go'
19-
linters:
20-
- gosec

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ repos:
7979
# E012: here doc didn't end before EOF
8080

8181
- repo: https://github.com/golangci/golangci-lint
82-
rev: v1.59.1
82+
rev: v2.4.0
8383
hooks:
8484
- id: golangci-lint-full
8585
args: ["-v"]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.21
2+
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.24
33
ARG OPERATOR_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
44

55
FROM $GOLANG_BUILDER AS builder

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ IMG ?= quay.io/openstack-k8s-operators/neutron-operator:latest
5656
ENVTEST_K8S_VERSION = 1.29
5757

5858
# Set minimum Go version
59-
GOTOOLCHAIN_VERSION ?= go1.21.0
59+
GOTOOLCHAIN_VERSION ?= go1.24.0
6060

6161
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6262
ifeq (,$(shell go env GOBIN))
@@ -119,9 +119,10 @@ tidy: ## Run go mod tidy on every mod file in the repo
119119
go mod tidy
120120
cd ./api && go mod tidy
121121

122+
GOLANGCI_LINT_VERSION ?= v2.4.0
122123
.PHONY: golangci-lint
123124
golangci-lint:
124-
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.59.1
125+
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
125126
$(LOCALBIN)/golangci-lint run --fix
126127

127128
PROCS?=$(shell expr $(shell nproc --ignore 2) / 2)

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/openstack-k8s-operators/neutron-operator/api
22

3-
go 1.21
3+
go 1.24
44

55
require (
66
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250909143828-e33d35ffd64f

controllers/neutronapi_controller.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package controllers contains the NeutronAPI controller for the neutron-operator.
1718
package controllers
1819

1920
import (
@@ -73,7 +74,7 @@ import (
7374
// errTransportURLSecretNameNilOrEmpty
7475
var errTransportURLSecretNameNilOrEmpty = errors.New("transport_url secret name is nil or empty")
7576

76-
// getlogger returns a logger object with a prefix of "conroller.name" and aditional controller context fields
77+
// GetLogger returns a logger object with a prefix of "controller.name" and additional controller context fields
7778
func (r *NeutronAPIReconciler) GetLogger(ctx context.Context) logr.Logger {
7879
return log.FromContext(ctx).WithName("Controllers").WithName("NeutronAPI")
7980
}
@@ -119,7 +120,7 @@ func (r *NeutronAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request)
119120

120121
// Fetch the NeutronAPI instance
121122
instance := &neutronv1beta1.NeutronAPI{}
122-
err := r.Client.Get(ctx, req.NamespacedName, instance)
123+
err := r.Get(ctx, req.NamespacedName, instance)
123124
if err != nil {
124125
if k8s_errors.IsNotFound(err) {
125126
// Request object not found, could have been deleted after reconcile request.
@@ -391,7 +392,7 @@ func (r *NeutronAPIReconciler) findObjectForSrc(ctx context.Context, src client.
391392
listOps := &client.ListOptions{
392393
Namespace: src.GetNamespace(),
393394
}
394-
err := r.Client.List(ctx, crList, listOps)
395+
err := r.List(ctx, crList, listOps)
395396
if err != nil {
396397
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
397398
return requests
@@ -532,7 +533,7 @@ func (r *NeutronAPIReconciler) reconcileInit(
532533
condition.TLSInputReadyCondition,
533534
condition.RequestedReason,
534535
condition.SeverityInfo,
535-
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName)))
536+
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
536537
return ctrl.Result{}, nil
537538
}
538539
instance.Status.Conditions.Set(condition.FalseCondition(
@@ -557,7 +558,7 @@ func (r *NeutronAPIReconciler) reconcileInit(
557558
condition.TLSInputReadyCondition,
558559
condition.RequestedReason,
559560
condition.SeverityInfo,
560-
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, err.Error())))
561+
condition.TLSInputReadyWaitingMessage, err.Error()))
561562
return ctrl.Result{}, nil
562563
}
563564
instance.Status.Conditions.Set(condition.FalseCondition(
@@ -582,7 +583,7 @@ func (r *NeutronAPIReconciler) reconcileInit(
582583
condition.TLSInputReadyCondition,
583584
condition.RequestedReason,
584585
condition.SeverityInfo,
585-
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, err.Error())))
586+
condition.TLSInputReadyWaitingMessage, err.Error()))
586587
return ctrl.Result{}, nil
587588
}
588589
instance.Status.Conditions.Set(condition.FalseCondition(
@@ -1365,7 +1366,7 @@ func (r *NeutronAPIReconciler) transportURLDeleted(
13651366
},
13661367
}
13671368

1368-
err := r.Client.Delete(ctx, transportURL)
1369+
err := r.Delete(ctx, transportURL)
13691370
if err != nil {
13701371
if k8s_errors.IsNotFound(err) {
13711372
return nil
@@ -1761,7 +1762,7 @@ func (r *NeutronAPIReconciler) generateServiceSecrets(
17611762
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(neutronapi.ServiceName), map[string]string{})
17621763

17631764
var tlsCfg *tls.Service
1764-
if instance.Spec.TLS.Ca.CaBundleSecretName != "" {
1765+
if instance.Spec.TLS.CaBundleSecretName != "" {
17651766
tlsCfg = &tls.Service{}
17661767
}
17671768
// customData hold any customization for the service.
@@ -1958,7 +1959,7 @@ func (r *NeutronAPIReconciler) memcachedNamespaceMapFunc(ctx context.Context) ha
19581959
listOpts := []client.ListOption{
19591960
client.InNamespace(o.GetNamespace()),
19601961
}
1961-
if err := r.Client.List(context.Background(), neutrons, listOpts...); err != nil {
1962+
if err := r.List(context.Background(), neutrons, listOpts...); err != nil {
19621963
Log.Error(err, "Unable to retrieve Neutron CRs %w")
19631964
return nil
19641965
}

0 commit comments

Comments
 (0)