From 106ab8f5d806a39eafcb6c51ebb1164088667321 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Wed, 9 Oct 2024 18:06:38 +0200 Subject: [PATCH] chore: Address linter issues Some are rather nitpicky, others are more of the "how do I Go" category. Signed-off-by: Manuel Hutter --- operator/backupcontroller/executor.go | 2 +- operator/backupcontroller/prebackup.go | 4 ++-- operator/backupcontroller/prebackup_utils.go | 4 ++-- restic/s3/client.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/operator/backupcontroller/executor.go b/operator/backupcontroller/executor.go index c89553e53..0cd83e112 100644 --- a/operator/backupcontroller/executor.go +++ b/operator/backupcontroller/executor.go @@ -185,7 +185,7 @@ func (b *BackupExecutor) startBackup(ctx context.Context) error { backupItems, err := b.listAndFilterPVCs(ctx, cfg.Config.BackupAnnotation) if err != nil { - b.Generic.SetConditionFalseWithMessage(ctx, k8upv1.ConditionReady, k8upv1.ReasonRetrievalFailed, err.Error()) + b.Generic.SetConditionFalseWithMessage(ctx, k8upv1.ConditionReady, k8upv1.ReasonRetrievalFailed, "%s", err.Error()) return err } diff --git a/operator/backupcontroller/prebackup.go b/operator/backupcontroller/prebackup.go index 24c92f242..b6719b9ef 100644 --- a/operator/backupcontroller/prebackup.go +++ b/operator/backupcontroller/prebackup.go @@ -71,8 +71,8 @@ func (b *BackupExecutor) allDeploymentsAreReady(ctx context.Context, deployments ready, err := isPreBackupDeploymentReady(deployment) if err != nil { log.Info("backup failed: deadline exceeded on pre backup deployment") - b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonFailed, err.Error()) - b.SetConditionTrueWithMessage(ctx, k8upv1.ConditionReady, k8upv1.ReasonFailed, err.Error()) + b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonFailed, "%s", err.Error()) + b.SetConditionTrueWithMessage(ctx, k8upv1.ConditionReady, k8upv1.ReasonFailed, "%s", err.Error()) b.deletePreBackupDeployment(ctx, deployment) return false, err } diff --git a/operator/backupcontroller/prebackup_utils.go b/operator/backupcontroller/prebackup_utils.go index 7c6608fad..133530240 100644 --- a/operator/backupcontroller/prebackup_utils.go +++ b/operator/backupcontroller/prebackup_utils.go @@ -87,14 +87,14 @@ func (b *BackupExecutor) fetchOrCreatePreBackupDeployment(ctx context.Context, d if fetchErr != nil { if !errors.IsNotFound(fetchErr) { err := fmt.Errorf("error getting pre backup pod '%v': %w", name.String(), fetchErr) - b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonRetrievalFailed, err.Error()) + b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonRetrievalFailed, "%s", err.Error()) return err } createErr := b.Client.Create(ctx, deployment) if createErr != nil { err := fmt.Errorf("error creating pre backup pod '%v': %w", name.String(), createErr) - b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonCreationFailed, err.Error()) + b.SetConditionFalseWithMessage(ctx, k8upv1.ConditionPreBackupPodReady, k8upv1.ReasonCreationFailed, "%s", err.Error()) return err } log.Info("started pre backup pod", "preBackup", name.String()) diff --git a/restic/s3/client.go b/restic/s3/client.go index b65ffa1d3..030751c8c 100644 --- a/restic/s3/client.go +++ b/restic/s3/client.go @@ -148,7 +148,7 @@ func (c *Client) deleteBucketByName(ctx context.Context, name string) error { // Print errors received from RemoveObjects API for e := range errorCh { - return fmt.Errorf("Failed to remove " + e.ObjectName + ", error: " + e.Err.Error()) + return fmt.Errorf("Failed to remove %v ,error: %v", e.ObjectName, e.Err.Error()) } return c.minioClient.RemoveBucket(ctx, name)