Skip to content
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

chore: Update to Go 1.22 #1400

Closed
wants to merge 2 commits into from
Closed
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 Dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
ARG GOLANG_VERSION=1.21
ARG GOLANG_VERSION=1.22

################################################################################
FROM registry.access.redhat.com/ubi8/toolbox as manifests
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/toolbox.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM registry.fedoraproject.org/fedora-toolbox:38

ARG GOLANG_VERSION=1.21
ARG GOLANG_VERSION=1.22.9
grdryn marked this conversation as resolved.
Show resolved Hide resolved
ARG OPERATOR_SDK_VERSION=1.31.0

ENV GOLANG_VERSION=$GOLANG_VERSION \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ catalog-build: opm ## Build a catalog image.
catalog-push: ## Push a catalog image.
$(MAKE) image-push IMG=$(CATALOG_IMG)

TOOLBOX_GOLANG_VERSION := 1.21
TOOLBOX_GOLANG_VERSION := 1.22.9

# Generate a Toolbox container for locally testing changes easily
.PHONY: toolbox
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Additionally installing `Authorino operator` & `Service Mesh operator` enhances

#### Pre-requisites

- Go version **go1.21**
- Go version **go1.22**
- operator-sdk version can be updated to **v1.31.1**

#### Download manifests
Expand Down
1 change: 0 additions & 1 deletion components/kserve/kserve_config_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func (k *Kserve) setDefaultDeploymentMode(ctx context.Context, cli client.Client
return fmt.Errorf("failed to list pods: %w", err)
}
for _, pod := range podList.Items {
pod := pod
if err := cli.Delete(ctx, &pod); err != nil {
return fmt.Errorf("failed to delete pod %s: %w", pod.Name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/secretgenerator/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func generateSecretValue(secret *Secret) error {
switch secret.Type {
case "random":
randomValue := make([]byte, secret.Complexity)
for i := 0; i < secret.Complexity; i++ {
for i := range secret.Complexity {
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letterRunes))))
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion controllers/secretgenerator/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestNewSecret(t *testing.T) {
}

for name, tc := range cases {
tc := tc
t.Run(name, func(t *testing.T) {
secret, err := secretgenerator.NewSecretFrom(tc.annotations)
if err != nil {
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/opendatahub-io/opendatahub-operator/v2

go 1.21
go 1.22

require (
github.com/blang/semver/v4 v4.0.0
Expand Down
2 changes: 0 additions & 2 deletions pkg/upgrade/uninstallation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func OperatorUninstall(ctx context.Context, cli client.Client, platform cluster.
}

for _, namespace := range generatedNamespaces.Items {
namespace := namespace
if namespace.Status.Phase == corev1.NamespaceActive {
if err := cli.Delete(ctx, &namespace); err != nil {
return fmt.Errorf("error deleting namespace %v: %w", namespace.Name, err)
Expand Down Expand Up @@ -95,7 +94,6 @@ func removeDSCInitialization(ctx context.Context, cli client.Client) error {

var multiErr *multierror.Error
for _, dsciInstance := range instanceList.Items {
dsciInstance := dsciInstance
if err := cli.Delete(ctx, &dsciInstance); !k8serr.IsNotFound(err) {
multiErr = multierror.Append(multiErr, err)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func deleteOneResource(ctx context.Context, c client.Client, res ResourceSpec) e
}

for _, item := range list.Items {
item := item
v, ok, err := unstructured.NestedString(item.Object, res.Path...)
if err != nil {
return fmt.Errorf("failed to get field %v for %s %s/%s: %w", res.Path, res.Gvk.Kind, res.Namespace, item.GetName(), err)
Expand Down Expand Up @@ -352,7 +351,7 @@ func deleteDeprecatedResources(ctx context.Context, cli client.Client, namespace
multiErr = multierror.Append(multiErr, err)
}
items := reflect.ValueOf(resourceType).Elem().FieldByName("Items")
for i := 0; i < items.Len(); i++ {
for i := range items.Len() {
item := items.Index(i).Addr().Interface().(client.Object) //nolint:errcheck,forcetypeassert
for _, name := range resourceList {
if name == item.GetName() {
Expand Down Expand Up @@ -383,7 +382,6 @@ func deleteDeprecatedServiceMonitors(ctx context.Context, cli client.Client, nam
}

for _, servicemonitor := range servicemonitors.Items {
servicemonitor := servicemonitor
for _, name := range resourceList {
if name == servicemonitor.Name {
log.Info("Attempting to delete " + servicemonitor.Name + " in namespace " + namespace)
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ func (tc *testContext) testAllComponentCreation(t *testing.T) error { //nolint:f
}

for _, c := range components {
c := c
name := c.GetComponentName()
t.Run("Validate "+name, func(t *testing.T) {
t.Parallel()
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/deletion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (tc *testContext) testAllApplicationDeletion(t *testing.T) error { //nolint
}

for _, c := range components {
c := c
t.Run("Delete "+c.GetComponentName(), func(t *testing.T) {
t.Parallel()
err = tc.testComponentDeletion(c)
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func getCSV(ctx context.Context, cli client.Client, name string, namespace strin
}

// do not use range Items to avoid pointer to the loop variable
for i := 0; i < len(csvList.Items); i++ {
for i := range len(csvList.Items) {
csv := &csvList.Items[i]
if isMatched(csv, name) {
return csv, nil
Expand Down Expand Up @@ -409,15 +409,14 @@ func ensureServicemeshOperators(t *testing.T, tc *testContext) error { //nolint:
c := make(chan error)

for _, op := range ops {
op := op // to avoid loop variable in the closures
t.Logf("Ensuring %s is installed", op)
go func(op string) {
err := ensureOperator(tc, op, servicemeshNamespace)
c <- err
}(op)
}

for i := 0; i < len(ops); i++ {
for range len(ops) {
err := <-c
errors = multierror.Append(errors, err)
}
Expand Down
1 change: 0 additions & 1 deletion tests/envtestutil/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func CreateCleaner(c client.Client, config *rest.Config, timeout, interval time.

func (c *Cleaner) DeleteAll(ctx context.Context, objects ...client.Object) {
for _, obj := range objects {
obj := obj
Expect(client.IgnoreNotFound(c.client.Delete(ctx, obj))).Should(Succeed())

if ns, ok := obj.(*corev1.Namespace); ok {
Expand Down