Merge pull request #8385 from mmorel-35/golangci-lint/perfsprint
golangci-lint: enable int-conversion and fiximports rule of perfsprintpull/8603/head
commit
225db5e8c0
|
@ -227,6 +227,12 @@ linters-settings:
|
||||||
require-explanation: true
|
require-explanation: true
|
||||||
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
|
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
|
||||||
require-specific: true
|
require-specific: true
|
||||||
|
perfsprint:
|
||||||
|
strconcat: false
|
||||||
|
sprintf1: false
|
||||||
|
errorf: false
|
||||||
|
int-conversion: true
|
||||||
|
fiximports: true
|
||||||
revive:
|
revive:
|
||||||
rules:
|
rules:
|
||||||
- name: unexported-return
|
- name: unexported-return
|
||||||
|
@ -310,6 +316,7 @@ linters:
|
||||||
- nilerr
|
- nilerr
|
||||||
- noctx
|
- noctx
|
||||||
- nolintlint
|
- nolintlint
|
||||||
|
- perfsprint
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck
|
- stylecheck
|
||||||
|
|
|
@ -19,6 +19,7 @@ package csi
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
|
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -484,9 +485,7 @@ func newDataUpload(
|
||||||
if backup.Spec.UploaderConfig != nil &&
|
if backup.Spec.UploaderConfig != nil &&
|
||||||
backup.Spec.UploaderConfig.ParallelFilesUpload > 0 {
|
backup.Spec.UploaderConfig.ParallelFilesUpload > 0 {
|
||||||
dataUpload.Spec.DataMoverConfig = make(map[string]string)
|
dataUpload.Spec.DataMoverConfig = make(map[string]string)
|
||||||
dataUpload.Spec.DataMoverConfig[uploaderUtil.ParallelFilesUpload] = fmt.Sprintf(
|
dataUpload.Spec.DataMoverConfig[uploaderUtil.ParallelFilesUpload] = strconv.Itoa(backup.Spec.UploaderConfig.ParallelFilesUpload)
|
||||||
"%d", backup.Spec.UploaderConfig.ParallelFilesUpload,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataUpload
|
return dataUpload
|
||||||
|
|
|
@ -19,6 +19,7 @@ package backup
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -222,7 +223,7 @@ func TestCreateCommand(t *testing.T) {
|
||||||
flags.Parse([]string{"--default-volumes-to-fs-backup", defaultVolumesToFsBackup})
|
flags.Parse([]string{"--default-volumes-to-fs-backup", defaultVolumesToFsBackup})
|
||||||
flags.Parse([]string{"--resource-policies-configmap", resPoliciesConfigmap})
|
flags.Parse([]string{"--resource-policies-configmap", resPoliciesConfigmap})
|
||||||
flags.Parse([]string{"--data-mover", dataMover})
|
flags.Parse([]string{"--data-mover", dataMover})
|
||||||
flags.Parse([]string{"--parallel-files-upload", fmt.Sprintf("%d", parallelFilesUpload)})
|
flags.Parse([]string{"--parallel-files-upload", strconv.Itoa(parallelFilesUpload)})
|
||||||
//flags.Parse([]string{"--wait"})
|
//flags.Parse([]string{"--wait"})
|
||||||
|
|
||||||
client := velerotest.NewFakeControllerRuntimeClient(t).(kbclient.WithWatch)
|
client := velerotest.NewFakeControllerRuntimeClient(t).(kbclient.WithWatch)
|
||||||
|
|
|
@ -18,6 +18,7 @@ package label
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -38,7 +39,7 @@ func GetValidName(label string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
sha := sha256.Sum256([]byte(label))
|
sha := sha256.Sum256([]byte(label))
|
||||||
strSha := fmt.Sprintf("%x", sha)
|
strSha := hex.EncodeToString(sha[:])
|
||||||
charsFromLabel := validation.DNS1035LabelMaxLength - 6
|
charsFromLabel := validation.DNS1035LabelMaxLength - 6
|
||||||
if charsFromLabel < 0 {
|
if charsFromLabel < 0 {
|
||||||
// Derive the label name from sha hash in case the DNS1035LabelMaxLength is less than 6
|
// Derive the label name from sha hash in case the DNS1035LabelMaxLength is less than 6
|
||||||
|
|
Loading…
Reference in New Issue