From c709a4f5576fff3bc22b110beefdd93b97524693 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 17b23d8a6..9d0259ddd 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -716,10 +716,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 d22f78f96..54f355e76 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",