Skip to content

Commit

Permalink
Merge pull request #973 from andyzhangx/remove-secret-print
Browse files Browse the repository at this point in the history
cleanup: remove secret print in error message
  • Loading branch information
andyzhangx authored Jul 13, 2023
2 parents 9c74b4a + db30b63 commit 3a9dba2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,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)
Expand Down
18 changes: 7 additions & 11 deletions pkg/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,31 +840,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,
Expand Down Expand Up @@ -905,19 +905,15 @@ 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",
containerName: fakeContainerName,
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",
Expand Down

0 comments on commit 3a9dba2

Please sign in to comment.