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

Update golangci-lint version to v1.63.4 along with required fixes #2945

Merged
Merged
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 .github/workflows/ocs-operator-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- uses: golangci/golangci-lint-action@v6
with:
version: v1.54.2
version: v1.63.4
args: "--out-format=colored-line-number --timeout=6m ./..."

go-test:
Expand Down
16 changes: 5 additions & 11 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 2m

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- revive
issues:
exclude:
#https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.1/pkg/handler#TypedMapFunc
- "parameter 'context' seems to be unused"
- "parameter 'obj' seems to be unused"
10 changes: 6 additions & 4 deletions controllers/mirroring/mirroring_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ package mirroring

import (
"context"
"errors"
"fmt"
"golang.org/x/exp/maps"
"k8s.io/utils/ptr"
"slices"
"time"

"golang.org/x/exp/maps"
"k8s.io/utils/ptr"

ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
providerClient "github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client"
Expand Down Expand Up @@ -337,7 +339,7 @@ func (r *MirroringReconciler) reconcileBlockPoolMirroring(
for i := range response.Errors {
resp := response.Errors[i]
r.log.Error(
fmt.Errorf(resp.Message),
errors.New(resp.Message),
"failed to get BlockPoolsInfo",
"CephBlockPool",
resp.BlockPoolName,
Expand Down Expand Up @@ -494,7 +496,7 @@ func (r *MirroringReconciler) reconcileRadosNamespaceMirroring(
for i := range response.Errors {
resp := response.Errors[i]
r.log.Error(
fmt.Errorf(resp.Message),
errors.New(resp.Message),
"failed to get StorageClientsInfo",
"CephBlockPool",
resp.ClientID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,8 @@ func getFailureDomainKeyFromStorageClassParameter(sc *storagev1.StorageClass) st
return "topology.rook.io/rack"
} else if failuredomain == "hostname" || failuredomain == "host" {
return "kubernetes.io/hostname"
} else {
return ""
}
return ""
}

func (r *OCSInitializationReconciler) reconcileUXBackendSecret(initialData *ocsv1.OCSInitialization) error {
Expand Down
9 changes: 4 additions & 5 deletions controllers/storagecluster/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
error1 "errors"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"strings"
"time"

"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/util"
Expand Down Expand Up @@ -212,9 +213,8 @@ func (r *StorageClusterReconciler) Reconcile(ctx context.Context, request reconc
return result, reconcileError
} else if statusError != nil {
return result, statusError
} else {
return result, nil
}
return result, nil
}

func (r *StorageClusterReconciler) initializeImagesStatus(sc *ocsv1.StorageCluster) {
Expand Down Expand Up @@ -699,9 +699,8 @@ func (r *StorageClusterReconciler) SetOperatorConditions(message string, reason
return error1.New(prevError.Error() + operatorConditionErr.Error())
} else if prevError != nil {
return prevError
} else {
return operatorConditionErr
}
return operatorConditionErr
}

// validateStorageDeviceSets checks the StorageDeviceSets of the given
Expand Down
2 changes: 1 addition & 1 deletion hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ OPERATOR_SDK="${LOCALBIN}/operator-sdk-${OPERATOR_SDK_VERSION}"
OPM_VERSION="v1.28.0"
OPM="${LOCALBIN}/opm-${OPM_VERSION}"
GINKGO="${LOCALBIN}/ginkgo"
GOLANGCI_LINT_VERSION="v1.54.2"
GOLANGCI_LINT_VERSION="v1.63.4"
GOLANGCI_LINT="${LOCALBIN}/golangci-lint"
SHELLCHECK_VERSION="v0.9.0"
SHELLCHECK="${LOCALBIN}/shellcheck"
Expand Down
6 changes: 3 additions & 3 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (s *OCSProviderServer) getExternalResources(ctx context.Context, consumerRe
if err = s.client.Get(ctx, client.ObjectKeyFromObject(noobaMgmtRoute), noobaMgmtRoute); err != nil {
return nil, fmt.Errorf("failed to get noobaa-mgmt route. %v", err)
}
if noobaMgmtRoute.Status.Ingress == nil || len(noobaMgmtRoute.Status.Ingress) == 0 {
if len(noobaMgmtRoute.Status.Ingress) == 0 {
return nil, fmt.Errorf("no Ingress available in noobaa-mgmt route")
}

Expand Down Expand Up @@ -660,7 +660,7 @@ func (s *OCSProviderServer) FulfillStorageClaim(ctx context.Context, req *pb.Ful
// Get storage consumer resource using UUID
consumerObj, err := s.consumerManager.Get(ctx, req.StorageConsumerUUID)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

klog.Infof("Found StorageConsumer %q (%q)", consumerObj.Name, req.StorageConsumerUUID)
Expand Down Expand Up @@ -695,7 +695,7 @@ func (s *OCSProviderServer) RevokeStorageClaim(ctx context.Context, req *pb.Revo
if err != nil {
errMsg := fmt.Sprintf("failed to revoke storage class claim %q for %q. %v", req.StorageClaimName, req.StorageConsumerUUID, err)
klog.Error(errMsg)
return nil, status.Errorf(codes.Internal, errMsg)
return nil, status.Error(codes.Internal, errMsg)
}

return &pb.RevokeStorageClaimResponse{}, nil
Expand Down
11 changes: 7 additions & 4 deletions services/ux-backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ type serverConfig struct {
}

func readEnvVar[T any](envVarName string, defaultValue T, parser func(str string) (T, error)) (T, error) {
if str := os.Getenv(envVarName); str == "" {
str := os.Getenv(envVarName)
if str == "" {
klog.Infof("no user-defined %s provided, defaulting to %v", envVarName, defaultValue)
return defaultValue, nil
} else if value, err := parser(str); err != nil {
}

value, err := parser(str)
if err != nil {
return *new(T), fmt.Errorf("malformed user-defined %s value %s: %v", envVarName, str, err)
} else {
return value, nil
}
return value, nil
}

func loadAndValidateServerConfig() (*serverConfig, error) {
Expand Down
Loading