Skip to content

Commit

Permalink
Merge pull request #977 from k8s-infra-cherrypick-robot/cherry-pick-9…
Browse files Browse the repository at this point in the history
…73-to-release-1.19

[release-1.19] cleanup: remove secret print in error message
  • Loading branch information
andyzhangx committed Jul 14, 2023
2 parents 077358e + bb920b5 commit 9dac566
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 @@ -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)
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 @@ -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,
Expand Down Expand Up @@ -844,19 +844,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 9dac566

Please sign in to comment.