From a761111ba1479cd6a417969620a4363882fa38b7 Mon Sep 17 00:00:00 2001 From: Fish-pro Date: Mon, 6 Feb 2023 14:52:01 +0800 Subject: [PATCH] Optimize string contrast judgment (#5821) Signed-off-by: Fish-pro --- pkg/repository/config/azure.go | 5 ++--- test/e2e/util/velero/velero_utils.go | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/repository/config/azure.go b/pkg/repository/config/azure.go index 7716c73c7..1c203330e 100644 --- a/pkg/repository/config/azure.go +++ b/pkg/repository/config/azure.go @@ -112,9 +112,8 @@ func getStorageAccountKey(config map[string]string) (string, error) { var storageKey string for _, key := range *res.Keys { - // uppercase both strings for comparison because the ListKeys call returns e.g. "FULL" but - // the storagemgmt.Full constant in the SDK is defined as "Full". - if strings.ToUpper(string(key.Permissions)) == strings.ToUpper(string(storagemgmt.Full)) { + // The ListKeys call returns e.g. "FULL" but the storagemgmt.Full constant in the SDK is defined as "Full". + if strings.EqualFold(string(key.Permissions), string(storagemgmt.Full)) { storageKey = *key.Value break } diff --git a/test/e2e/util/velero/velero_utils.go b/test/e2e/util/velero/velero_utils.go index 2a471c53a..5805cdd58 100644 --- a/test/e2e/util/velero/velero_utils.go +++ b/test/e2e/util/velero/velero_utils.go @@ -462,9 +462,9 @@ func VeleroScheduleCreate(ctx context.Context, veleroCLI string, veleroNamespace func VeleroSchedulePause(ctx context.Context, veleroCLI string, veleroNamespace string, scheduleName string) error { var args []string - args = append([]string{ + args = []string{ "--namespace", veleroNamespace, "schedule", "pause", scheduleName, - }) + } if err := VeleroCmdExec(ctx, veleroCLI, args); err != nil { return err } @@ -473,9 +473,9 @@ func VeleroSchedulePause(ctx context.Context, veleroCLI string, veleroNamespace func VeleroScheduleUnpause(ctx context.Context, veleroCLI string, veleroNamespace string, scheduleName string) error { var args []string - args = append([]string{ + args = []string{ "--namespace", veleroNamespace, "schedule", "unpause", scheduleName, - }) + } if err := VeleroCmdExec(ctx, veleroCLI, args); err != nil { return err }