From bb920b545129639b7cf5f1692dc06503f721c7f8 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 13 Jul 2023 07:45:25 +0000 Subject: [PATCH] cleanup: remove secret print in error message --- pkg/blob/blob.go | 4 ++-- pkg/blob/blob_test.go | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pkg/blob/blob.go b/pkg/blob/blob.go index a96e4606b..107477c1c 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -661,10 +661,10 @@ func getStorageAccount(secrets map[string]string) (string, string, error) { } if accountName == "" { - return accountName, accountKey, fmt.Errorf("could not find %s or %s field secrets(%v)", accountNameField, defaultSecretAccountName, secrets) + return accountName, accountKey, fmt.Errorf("could not find %s or %s field in secrets", accountNameField, defaultSecretAccountName) } if accountKey == "" { - return accountName, accountKey, fmt.Errorf("could not find %s or %s field in secrets(%v)", accountKeyField, defaultSecretAccountKey, secrets) + return accountName, accountKey, fmt.Errorf("could not find %s or %s field in secrets", accountKeyField, defaultSecretAccountKey) } accountName = strings.TrimSpace(accountName) diff --git a/pkg/blob/blob_test.go b/pkg/blob/blob_test.go index 0af2d0447..447a17bd6 100644 --- a/pkg/blob/blob_test.go +++ b/pkg/blob/blob_test.go @@ -779,31 +779,31 @@ func TestGetStorageAccount(t *testing.T) { }, expectedAccountName: "", expectedAccountKey: "", - expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field secrets(map[accountname: accountkey:])"), + expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field"), }, { options: emptyAccountKeyMap, expectedAccountName: "testaccount", expectedAccountKey: "", - expectedError: fmt.Errorf("could not find accountkey or azurestorageaccountkey field in secrets(%v)", emptyAccountKeyMap), + expectedError: fmt.Errorf("could not find accountkey or azurestorageaccountkey field in secrets"), }, { options: emptyAccountNameMap, expectedAccountName: "", expectedAccountKey: "testkey", - expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field secrets(%v)", emptyAccountNameMap), + expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field in secrets"), }, { options: emptyAzureAccountKeyMap, expectedAccountName: "testaccount", expectedAccountKey: "", - expectedError: fmt.Errorf("could not find accountkey or azurestorageaccountkey field in secrets(%v)", emptyAzureAccountKeyMap), + expectedError: fmt.Errorf("could not find accountkey or azurestorageaccountkey field in secrets"), }, { options: emptyAzureAccountNameMap, expectedAccountName: "", expectedAccountKey: "testkey", - expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field secrets(%v)", emptyAzureAccountNameMap), + expectedError: fmt.Errorf("could not find accountname or azurestorageaccountname field in secrets"), }, { options: nil, @@ -844,9 +844,7 @@ func TestGetContainerReference(t *testing.T) { secrets: map[string]string{ "accountKey": fakeAccountKey, }, - expectedError: fmt.Errorf("could not find %s or %s field secrets(%v)", accountNameField, defaultSecretAccountName, map[string]string{ - "accountKey": fakeAccountKey, - }), + expectedError: fmt.Errorf("could not find %s or %s field in secrets", accountNameField, defaultSecretAccountName), }, { name: "failed to retrieve accountKey", @@ -854,9 +852,7 @@ func TestGetContainerReference(t *testing.T) { secrets: map[string]string{ "accountName": fakeAccountName, }, - expectedError: fmt.Errorf("could not find %s or %s field in secrets(%v)", accountKeyField, defaultSecretAccountKey, map[string]string{ - "accountName": fakeAccountName, - }), + expectedError: fmt.Errorf("could not find %s or %s field in secrets", accountKeyField, defaultSecretAccountKey), }, { name: "failed to obtain client",