Enable staticcheck and resolve found issues.

Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
This commit is contained in:
Xun Jiang
2023-04-25 11:33:40 +08:00
parent 1fd28e8a36
commit cb0ada1e1c
24 changed files with 51 additions and 45 deletions
+2 -2
View File
@@ -105,10 +105,10 @@ func TestCreateOptions_BuildBackupFromSchedule(t *testing.T) {
}
func TestCreateOptions_OrderedResources(t *testing.T) {
orderedResources, err := ParseOrderedResources("pods= ns1/p1; ns1/p2; persistentvolumeclaims=ns2/pvc1, ns2/pvc2")
_, err := ParseOrderedResources("pods= ns1/p1; ns1/p2; persistentvolumeclaims=ns2/pvc1, ns2/pvc2")
assert.NotNil(t, err)
orderedResources, err = ParseOrderedResources("pods= ns1/p1,ns1/p2 ; persistentvolumeclaims=ns2/pvc1,ns2/pvc2")
orderedResources, err := ParseOrderedResources("pods= ns1/p1,ns1/p2 ; persistentvolumeclaims=ns2/pvc1,ns2/pvc2")
assert.NoError(t, err)
expectedResources := map[string]string{
+4 -3
View File
@@ -18,9 +18,10 @@ package cli
import (
"errors"
"strings"
"github.com/spf13/pflag"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"github.com/vmware-tanzu/velero/pkg/cmd/util/flag"
)
@@ -64,6 +65,6 @@ func (o *SelectOptions) Validate() error {
// BindFlags binds options for this command to flags.
func (o *SelectOptions) BindFlags(flags *pflag.FlagSet) {
flags.BoolVar(&o.All, "all", o.All, strings.Title(o.CMD)+" all "+o.SingularTypeName+"s")
flags.VarP(&o.Selector, "selector", "l", strings.Title(o.CMD)+" all "+o.SingularTypeName+"s matching this label selector.")
flags.BoolVar(&o.All, "all", o.All, cases.Title(language.Und).String(o.CMD)+" all "+o.SingularTypeName+"s")
flags.VarP(&o.Selector, "selector", "l", cases.Title(language.Und).String(o.CMD)+" all "+o.SingularTypeName+"s matching this label selector.")
}
+1 -1
View File
@@ -83,7 +83,7 @@ func TestPrintVersion(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
var (
kbClient = fake.NewFakeClientWithScheme(scheme.Scheme)
kbClient = fake.NewClientBuilder().WithScheme(scheme.Scheme).Build()
serverStatusGetter = new(mockServerStatusGetter)
buf = new(bytes.Buffer)
)