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
@@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
core "k8s.io/client-go/testing"
testclocks "k8s.io/utils/clock/testing"
ctrl "sigs.k8s.io/controller-runtime"
@@ -669,22 +668,10 @@ var _ = Describe("Backup Sync Reconciler", func() {
logger: velerotest.NewLogger(),
}
expectedDeleteActions := make([]core.Action, 0)
for _, backup := range test.k8sBackups {
// add test backup to client
err := client.Create(context.TODO(), backup, &ctrlClient.CreateOptions{})
Expect(err).ShouldNot(HaveOccurred())
// if we expect this backup to be deleted, set up the expected DeleteAction
if test.expectedDeletes.Has(backup.Name) {
actionDelete := core.NewDeleteAction(
velerov1api.SchemeGroupVersion.WithResource("backups"),
test.namespace,
backup.Name,
)
expectedDeleteActions = append(expectedDeleteActions, actionDelete)
}
}
bslName := "default"
@@ -114,7 +114,7 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
func(test request) {
ctx := context.Background()
fakeClient := fake.NewFakeClientWithScheme(scheme.Scheme)
fakeClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).Build()
err = fakeClient.Create(ctx, test.pvb)
Expect(err).To(BeNil())
@@ -139,6 +139,8 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
fakeFS,
)
Expect(err).To(BeNil())
// Setup reconciler
Expect(velerov1api.AddToScheme(scheme.Scheme)).To(Succeed())
r := PodVolumeBackupReconciler{
@@ -218,6 +218,7 @@ func (r *restoreOperationsReconciler) updateRestoreAndOperationsJSON(
completionChanges bool) error {
if len(operations.ErrsSinceUpdate) > 0 {
// FIXME: download/upload results
r.logger.WithField("restore", restore.Name).Infof("Restore has %d errors", len(operations.ErrsSinceUpdate))
}
removeIfComplete := true
defer func() {