Skip to content

[golang] bump to golang 1.22 #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: tools
namespace: openstack-k8s-operators
tag: ci-build-root-golang-1.21-sdk-1.31
tag: ci-build-root-golang-1.22-sdk-1.31
2 changes: 1 addition & 1 deletion .github/workflows/build-ovn-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/reusable-build-operator.yaml@main
with:
operator_name: ovn
go_version: 1.21.x
go_version: 1.22.x
operator_sdk_version: 1.31.0
secrets:
IMAGENAMESPACE: ${{ secrets.IMAGENAMESPACE }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ repos:
# E012: here doc didn't end before EOF

- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
rev: v1.63.4
hooks:
- id: golangci-lint-full
args: ["-v"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.21
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.22
ARG OPERATOR_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest

FROM $GOLANG_BUILDER AS builder
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ SHELL = /usr/bin/env bash -o pipefail
# Extra vars which will be passed to the Docker-build
DOCKER_BUILD_ARGS ?=

GOTOOLCHAIN_VERSION ?= go1.21.0
GOTOOLCHAIN_VERSION ?= go1.22.0
.PHONY: all
all: build

Expand Down Expand Up @@ -116,9 +116,10 @@ tidy: ## Run go mod tidy on every mod file in the repo
go mod tidy
cd ./api && go mod tidy

GOLANGCI_LINT_VERSION ?= v1.63.4
.PHONY: golangci-lint
golangci-lint:
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.59.1
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
$(LOCALBIN)/golangci-lint run --fix

PROCS?=$(shell expr $(shell nproc --ignore 2) / 2)
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/ovn-operator/api

go 1.21
go 1.22

require (
github.com/go-logr/logr v1.4.2
Expand Down
4 changes: 2 additions & 2 deletions controllers/ovncontroller_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName)))
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -421,7 +421,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, err.Error())))
condition.TLSInputReadyWaitingMessage, err.Error()))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand Down
7 changes: 3 additions & 4 deletions controllers/ovndbcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName)))
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -484,7 +484,7 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, err.Error())))
condition.TLSInputReadyWaitingMessage, err.Error()))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand Down Expand Up @@ -877,8 +877,7 @@ func (r *OVNDBClusterReconciler) reconcileServices(
// get it automatically registered in DNS.
if instance.Spec.NetworkAttachment != "" && ssvc.GetServiceType() != corev1.ServiceTypeLoadBalancer {
var dnsIPsList []string
// TODO(averdagu): use built in Min once go1.21 is used
minLen := ovn_common.Min(len(podList.Items), int(*(instance.Spec.Replicas)))
minLen := min(len(podList.Items), int(*(instance.Spec.Replicas)))
for _, ovnPod := range podList.Items[:minLen] {
svc, err = service.GetServiceWithName(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions controllers/ovnnorthd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (r *OVNNorthdReconciler) reconcileNormal(ctx context.Context, instance *ovn
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName)))
condition.TLSInputReadyWaitingMessage, instance.Spec.TLS.CaBundleSecretName))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand All @@ -424,7 +424,7 @@ func (r *OVNNorthdReconciler) reconcileNormal(ctx context.Context, instance *ovn
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, err.Error())))
condition.TLSInputReadyWaitingMessage, err.Error()))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/ovn-operator

go 1.21
go 1.22

require (
github.com/go-logr/logr v1.4.2
Expand Down
9 changes: 0 additions & 9 deletions pkg/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@ limitations under the License.
*/

package common

// Helper function while can't use buildin min
// TOOD(averdagu) remove when using go1.21.0
func Min(x, y int) int {
if x < y {
return x
}
return y
}