Skip to content

Commit

Permalink
Update Go version in go.mod to 1.22
Browse files Browse the repository at this point in the history
JIRA: https://issues.redhat.com/browse/RHOAIENG-16819

This just updates the Go version in the go directive in go.mod. The
code changes to add nolint suppression is temporary and those will be
addressed in a separate commit.
  • Loading branch information
grdryn committed Dec 10, 2024
1 parent 8a8ff10 commit b569371
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
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
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 := 0; i < secret.Complexity; i++ { //nolint: intrange
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letterRunes))))
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion controllers/secretgenerator/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestNewSecret(t *testing.T) {
}

for name, tc := range cases {
tc := tc
tc := tc //nolint: copyloopvar
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
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestRenderResourcesWithCacheAction(t *testing.T) {

render.RenderedResourcesTotal.Reset()

for i := int64(0); i < 3; i++ {
for i := int64(0); i < 3; i++ { //nolint: intrange
d := componentApi.Dashboard{}

if i >= 1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestRenderTemplateWithCache(t *testing.T) {
},
}

for i := int64(0); i < 3; i++ {
for i := int64(0); i < 3; i++ { //nolint: intrange
d := componentApi.Dashboard{
ObjectMeta: metav1.ObjectMeta{
Name: ns,
Expand Down
4 changes: 2 additions & 2 deletions pkg/upgrade/uninstallation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func OperatorUninstall(ctx context.Context, cli client.Client, platform cluster.
}

for _, namespace := range generatedNamespaces.Items {
namespace := namespace
namespace := namespace //nolint: copyloopvar

Check warning on line 51 in pkg/upgrade/uninstallation.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/uninstallation.go#L51

Added line #L51 was not covered by tests
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 +95,7 @@ func removeDSCInitialization(ctx context.Context, cli client.Client) error {

var multiErr *multierror.Error
for _, dsciInstance := range instanceList.Items {
dsciInstance := dsciInstance
dsciInstance := dsciInstance //nolint: copyloopvar

Check warning on line 98 in pkg/upgrade/uninstallation.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/uninstallation.go#L98

Added line #L98 was not covered by tests
if err := cli.Delete(ctx, &dsciInstance); !k8serr.IsNotFound(err) {
multiErr = multierror.Append(multiErr, err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func deleteOneResource(ctx context.Context, c client.Client, res ResourceSpec) e
}

for _, item := range list.Items {
item := item
item := item //nolint: copyloopvar

Check warning on line 316 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L316

Added line #L316 was not covered by tests
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 @@ -345,7 +345,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 := 0; i < items.Len(); i++ { //nolint: intrange

Check warning on line 348 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L348

Added line #L348 was not covered by tests
item := items.Index(i).Addr().Interface().(client.Object) //nolint:errcheck,forcetypeassert
for _, name := range resourceList {
if name == item.GetName() {
Expand Down Expand Up @@ -376,7 +376,7 @@ func deleteDeprecatedServiceMonitors(ctx context.Context, cli client.Client, nam
}

for _, servicemonitor := range servicemonitors.Items {
servicemonitor := servicemonitor
servicemonitor := servicemonitor //nolint: copyloopvar

Check warning on line 379 in pkg/upgrade/upgrade.go

View check run for this annotation

Codecov / codecov/patch

pkg/upgrade/upgrade.go#L379

Added line #L379 was not covered by tests
for _, name := range resourceList {
if name == servicemonitor.Name {
log.Info("Attempting to delete " + servicemonitor.Name + " in namespace " + namespace)
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,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 := 0; i < len(csvList.Items); i++ { //nolint: intrange
csv := &csvList.Items[i]
if isMatched(csv, name) {
return csv, nil
Expand Down Expand Up @@ -416,15 +416,15 @@ 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
op := op //nolint: copyloopvar
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 i := 0; i < len(ops); i++ { //nolint: intrange
err := <-c
errors = multierror.Append(errors, err)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/envtestutil/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ 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
obj := obj //nolint: copyloopvar
Expect(client.IgnoreNotFound(c.client.Delete(ctx, obj))).Should(Succeed())

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

0 comments on commit b569371

Please sign in to comment.