build: address nolintlint errors from new golangci-lint

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2023-06-02 10:59:52 +02:00 committed by mergify[bot]
parent 5913ed92fe
commit 81218a69f9
30 changed files with 43 additions and 43 deletions

View File

@ -23,7 +23,7 @@ import (
"sync"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
. "github.com/onsi/ginkgo/v2" // nolint
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"

View File

@ -21,7 +21,7 @@ import (
"fmt"
"strings"
. "github.com/onsi/gomega" // nolint
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"

View File

@ -21,7 +21,7 @@ import (
"testing"
)
// nolint:lll // error string cannot be split into multiple lines as is a
//nolint:lll // error string cannot be split into multiple lines as is a
// output from kubectl.
func TestGetStdErr(t *testing.T) {
t.Parallel()

View File

@ -30,7 +30,7 @@ import (
// composeIntreeMigVolID create a volID similar to intree migration volID
// the migration volID format looks like below
// mig-mons-<hash>-image-<UUID_<poolhash>
// nolint:lll // ex: "mig_mons-b7f67366bb43f32e07d8a261a7840da9_image-e0b45b52-7e09-47d3-8f1b-806995fa4412_706f6f6c5f7265706c6963615f706f6f6c
//nolint:lll // ex: "mig_mons-b7f67366bb43f32e07d8a261a7840da9_image-e0b45b52-7e09-47d3-8f1b-806995fa4412_706f6f6c5f7265706c6963615f706f6f6c
func composeIntreeMigVolID(mons, rbdImageName string) string {
poolField := hex.EncodeToString([]byte(defaultRBDPool))
monsField := monsPrefix + getMonsHash(mons)

View File

@ -24,7 +24,7 @@ import (
"time"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
. "github.com/onsi/ginkgo/v2" // nolint
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -420,7 +420,7 @@ func deletePod(name, ns string, c kubernetes.Interface, t int) error {
})
}
// nolint:unparam // currently skipNotFound is always false, this can change in the future
//nolint:unparam // currently skipNotFound is always false, this can change in the future
func deletePodWithLabel(label, ns string, skipNotFound bool) error {
err := retryKubectlArgs(
ns,

View File

@ -25,7 +25,7 @@ import (
"github.com/ceph/ceph-csi/internal/util"
. "github.com/onsi/ginkgo/v2" // nolint
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
@ -204,7 +204,7 @@ func checkGetKeyError(err error, stdErr string) bool {
}
// checkClusternameInMetadata check for cluster name metadata on RBD image.
// nolint:nilerr // intentionally returning nil on error in the retry loop.
//nolint:nilerr // intentionally returning nil on error in the retry loop.
func checkClusternameInMetadata(f *framework.Framework, ns, pool, image string) {
t := time.Duration(deployTimeout) * time.Minute
var (

View File

@ -37,7 +37,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
)
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
var nbdResizeSupport = []util.KernelVersion{
{
Version: 5,
@ -49,7 +49,7 @@ var nbdResizeSupport = []util.KernelVersion{
}, // standard 5.3+ versions
}
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
var fastDiffSupport = []util.KernelVersion{
{
Version: 5,
@ -61,7 +61,7 @@ var fastDiffSupport = []util.KernelVersion{
}, // standard 5.3+ versions
}
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
var deepFlattenSupport = []util.KernelVersion{
{
Version: 5,
@ -75,7 +75,7 @@ var deepFlattenSupport = []util.KernelVersion{
// To use `io-timeout=0` we need
// www.mail-archive.com/linux-block@vger.kernel.org/msg38060.html
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
var nbdZeroIOtimeoutSupport = []util.KernelVersion{
{
Version: 5,

View File

@ -22,7 +22,7 @@ import (
"strings"
"time"
. "github.com/onsi/gomega" // nolint
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -23,7 +23,7 @@ import (
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
snapclient "github.com/kubernetes-csi/external-snapshotter/client/v6/clientset/versioned/typed/volumesnapshot/v1"
. "github.com/onsi/gomega" // nolint
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
@ -293,7 +293,7 @@ func getVolumeSnapshotContent(namespace, snapshotName string) (*snapapi.VolumeSn
return volumeSnapshotContent, nil
}
// nolint:gocyclo,cyclop // reduce complexity
//nolint:gocyclo,cyclop // reduce complexity
func validateBiggerPVCFromSnapshot(f *framework.Framework,
pvcPath,
appPath,

View File

@ -322,7 +322,7 @@ func validateRBDStaticMigrationPVC(f *framework.Framework, appPath, scName strin
return err
}
// nolint:gocyclo,cyclop // reduce complexity
//nolint:gocyclo,cyclop // reduce complexity
func validateCephFsStaticPV(f *framework.Framework, appPath, scPath string) error {
opt := make(map[string]string)
var (

View File

@ -23,7 +23,7 @@ import (
"path/filepath"
"strings"
. "github.com/onsi/ginkgo/v2" // nolint
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -23,7 +23,7 @@ import (
"path/filepath"
"strings"
. "github.com/onsi/ginkgo/v2" // nolint
. "github.com/onsi/ginkgo/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -852,7 +852,7 @@ func writeDataAndCalChecksum(app *v1.Pod, opt *metav1.ListOptions, f *framework.
return checkSum, nil
}
// nolint:gocyclo,gocognit,nestif,cyclop // reduce complexity
//nolint:gocyclo,gocognit,nestif,cyclop // reduce complexity
func validatePVCClone(
totalCount int,
sourcePvcPath, sourceAppPath, clonePvcPath, clonePvcAppPath,
@ -1067,7 +1067,7 @@ func validatePVCClone(
validateRBDImageCount(f, 0, defaultRBDPool)
}
// nolint:gocyclo,gocognit,nestif,cyclop // reduce complexity
//nolint:gocyclo,gocognit,nestif,cyclop // reduce complexity
func validatePVCSnapshot(
totalCount int,
pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath string,
@ -1529,7 +1529,7 @@ func validateController(
return deleteResource(rbdExamplePath + "storageclass.yaml")
}
// nolint:deadcode,unused // Unused code will be used in future.
//nolint:deadcode,unused // Unused code will be used in future.
// k8sVersionGreaterEquals checks the ServerVersion of the Kubernetes cluster
// and compares it to the major.minor version passed. In case the version of
// the cluster is equal or higher to major.minor, `true` is returned, `false`
@ -1681,7 +1681,7 @@ func retryKubectlFile(namespace string, action kubectlAction, filename string, t
// retryKubectlArgs takes a namespace and action telling kubectl what to do
// with the passed arguments. This function retries until no error occurred, or
// the timeout passed.
// nolint:unparam // retryKubectlArgs will be used with kubectlDelete arg later on.
//nolint:unparam // retryKubectlArgs will be used with kubectlDelete arg later on.
func retryKubectlArgs(namespace string, action kubectlAction, t int, args ...string) error {
timeout := time.Duration(t) * time.Minute
args = append([]string{string(action)}, args...)

View File

@ -241,7 +241,7 @@ func checkValidCreateVolumeRequest(
}
// CreateVolume creates a reservation and the volume in backend, if it is not already present.
// nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity
//nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity
func (cs *ControllerServer) CreateVolume(
ctx context.Context,
req *csi.CreateVolumeRequest,
@ -730,7 +730,7 @@ func (cs *ControllerServer) ControllerExpandVolume(
// CreateSnapshot creates the snapshot in backend and stores metadata
// in store
// nolint:gocognit,gocyclo,cyclop // golangci-lint did not catch this earlier, needs to get fixed late
//nolint:gocognit,gocyclo,cyclop // golangci-lint did not catch this earlier, needs to get fixed late
func (cs *ControllerServer) CreateSnapshot(
ctx context.Context,
req *csi.CreateSnapshotRequest,
@ -986,7 +986,7 @@ func (cs *ControllerServer) validateSnapshotReq(ctx context.Context, req *csi.Cr
// DeleteSnapshot deletes the snapshot in backend and removes the
// snapshot metadata from store.
// nolint:gocyclo,cyclop // TODO: reduce complexity
//nolint:gocyclo,cyclop // TODO: reduce complexity
func (cs *ControllerServer) DeleteSnapshot(
ctx context.Context,
req *csi.DeleteSnapshotRequest,

View File

@ -31,7 +31,7 @@ import (
var (
availableMounters []string
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
quotaSupport = []util.KernelVersion{
{
Version: 4,

View File

@ -71,7 +71,7 @@ because, the order of omap creation and deletion are inverse of each other, and
request name lock, and hence any stale omaps are leftovers from incomplete transactions and are
hence safe to garbage collect.
*/
// nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity
//nolint:gocognit,gocyclo,nestif,cyclop // TODO: reduce complexity
func CheckVolExists(ctx context.Context,
volOptions,
parentVolOpt *VolumeOptions,

View File

@ -210,7 +210,7 @@ func fmtBackingSnapshotOptionMismatch(optName, expected, actual string) error {
// NewVolumeOptions generates a new instance of volumeOptions from the provided
// CSI request parameters.
// nolint:gocyclo,cyclop // TODO: reduce complexity
//nolint:gocyclo,cyclop // TODO: reduce complexity
func NewVolumeOptions(
ctx context.Context,
requestName,
@ -348,7 +348,7 @@ func IsVolumeCreateRO(caps []*csi.VolumeCapability) bool {
// newVolumeOptionsFromVolID generates a new instance of volumeOptions and VolumeIdentifier
// from the provided CSI VolumeID.
// nolint:gocyclo,cyclop // TODO: reduce complexity
//nolint:gocyclo,cyclop // TODO: reduce complexity
func NewVolumeOptionsFromVolID(
ctx context.Context,
volID string,

View File

@ -82,7 +82,7 @@ func (d *CSIDriver) ValidateControllerServiceRequest(c csi.ControllerServiceCapa
}
}
return status.Error(codes.InvalidArgument, fmt.Sprintf("%s", c)) //nolint
return status.Error(codes.InvalidArgument, fmt.Sprintf("%s", c))
}
// AddControllerServiceCapabilities stores the controller capabilities

View File

@ -53,7 +53,7 @@ func TestGenerateNonce(t *testing.T) {
func TestGenerateCipher(t *testing.T) {
t.Parallel()
// nolint:gosec // this passphrase is intentionally hardcoded
//nolint:gosec // this passphrase is intentionally hardcoded
passphrase := "my-cool-luks-passphrase"
salt := "unique-id-for-the-volume"

View File

@ -123,7 +123,7 @@ func setConfigString(option *string, config map[string]interface{}, key string)
// these settings will be used when connecting to the Vault service with
// vc.connectVault().
//
// nolint:gocyclo,cyclop // iterating through many config options, not complex at all.
//nolint:gocyclo,cyclop // iterating through many config options, not complex at all.
func (vc *vaultConnection) initConnection(config map[string]interface{}) error {
vaultConfig := make(map[string]interface{})
keyContext := make(map[string]string)

View File

@ -353,7 +353,7 @@ func (kms *vaultTokensKMS) setTokenName(config map[string]interface{}) error {
// initCertificates updates the kms.vaultConfig with the options from config
// it calls the kubernetes secrets and get the required data.
// nolint:gocyclo,cyclop // iterating through many config options, not complex at all.
//nolint:gocyclo,cyclop // iterating through many config options, not complex at all.
func (vtc *vaultTenantConnection) initCertificates(config map[string]interface{}) error {
vaultConfig := make(map[string]interface{})

View File

@ -1060,7 +1060,7 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
}
// CreateSnapshot creates the snapshot in backend and stores metadata in store.
// nolint:gocyclo,cyclop // TODO: reduce complexity.
//nolint:gocyclo,cyclop // TODO: reduce complexity.
func (cs *ControllerServer) CreateSnapshot(
ctx context.Context,
req *csi.CreateSnapshotRequest,

View File

@ -78,7 +78,7 @@ var (
kernelRelease = ""
// deepFlattenSupport holds the list of kernel which support mapping rbd
// image with deep-flatten image feature
// nolint:gomnd // numbers specify Kernel versions.
//nolint:gomnd // numbers specify Kernel versions.
deepFlattenSupport = []util.KernelVersion{
{
Version: 5,
@ -114,7 +114,7 @@ var (
// parseBoolOption checks if parameters contain option and parse it. If it is
// empty or not set return default.
// nolint:unparam // currently defValue is always false, this can change in the future
//nolint:unparam // currently defValue is always false, this can change in the future
func parseBoolOption(ctx context.Context, parameters map[string]string, optionName string, defValue bool) bool {
boolVal := defValue

View File

@ -538,7 +538,7 @@ func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
// Generate new volume Handler
// The volume handler won't remain same as its contains poolID,clusterID etc
// which are not same across clusters.
// nolint:gocyclo,cyclop,nestif // TODO: reduce complexity
//nolint:gocyclo,cyclop,nestif // TODO: reduce complexity
func RegenerateJournal(
volumeAttributes map[string]string,
claimName,

View File

@ -1161,7 +1161,7 @@ func generateVolumeFromVolumeID(
// GenVolFromVolID generates a rbdVolume structure from the provided identifier, updating
// the structure with elements from on-disk image metadata as well.
//
// nolint // returns non-exported *rbdVolume, which is fine
func GenVolFromVolID(
ctx context.Context,
volumeID string,
@ -1702,7 +1702,7 @@ func (ri *rbdImageMetadataStash) String() string {
func stashRBDImageMetadata(volOptions *rbdVolume, metaDataPath string) error {
imgMeta := rbdImageMetadataStash{
// there are no checks for this at present
Version: 3, // nolint:gomnd // number specifies version.
Version: 3, //nolint:gomnd // number specifies version.
Pool: volOptions.Pool,
RadosNamespace: volOptions.RadosNamespace,
ImageName: volOptions.RbdImageName,

View File

@ -73,7 +73,7 @@ func (cp *ConnPool) fakeGet(monitors, user, keyfile string) (*rados.Conn, string
return conn, unique, nil
}
// nolint:paralleltest // these tests cannot run in parallel
//nolint:paralleltest // these tests cannot run in parallel
func TestConnPool(t *testing.T) {
cp := NewConnPool(interval, expiry)
defer cp.Destroy()

View File

@ -67,7 +67,7 @@ type ClusterInfo struct {
}
// Expected JSON structure in the passed in config file is,
// nolint:godot // example json content should not contain unwanted dot.
//nolint:godot // example json content should not contain unwanted dot.
/*
[{
"clusterID": "<cluster-id>",

View File

@ -70,7 +70,7 @@ func TryRADOSAborted(opErr error) error {
return opErr
}
// nolint:errorlint // Can't use errors.As() because rados.radosError is private.
//nolint:errorlint // Can't use errors.As() because rados.radosError is private.
errnoErr, ok := radosOpErr.OpError.(interface{ ErrorCode() int })
if !ok {
return opErr

View File

@ -54,7 +54,7 @@ func FromBytes(bs []byte) (RefType, error) {
}
num := RefType(bs[0])
switch num { // nolint:exhaustive // reftype.Unknown is handled in default case.
switch num { //nolint:exhaustive // reftype.Unknown is handled in default case.
case Normal, Mask:
return num, nil
default: