mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-14 11:57:59 +00:00
fix: return not found error when there is no secret for vault provider (#4183)
* feat: add option to ignore not found secrets on a path Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> * return not found instead of ignoring it Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> --------- Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
This commit is contained in:
parent
388158a4d4
commit
fa8941a526
2 changed files with 19 additions and 1 deletions
|
@ -118,7 +118,7 @@ func (c *client) listSecrets(ctx context.Context, path string) ([]string, error)
|
|||
return nil, fmt.Errorf(errReadSecret, err)
|
||||
}
|
||||
if secret == nil {
|
||||
return nil, fmt.Errorf("provided path %v does not contain any secrets", url)
|
||||
return nil, esv1beta1.NoSecretError{}
|
||||
}
|
||||
t, ok := secret.Data["keys"]
|
||||
if !ok {
|
||||
|
|
|
@ -283,6 +283,24 @@ func TestGetAllSecrets(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"FilterByPathReturnsNotFound": {
|
||||
reason: "should return a not found error if there are no more secrets on the path",
|
||||
args: args{
|
||||
store: makeValidSecretStoreWithVersion(esv1beta1.VaultKVStoreV2).Spec.Provider.Vault,
|
||||
vLogical: &fake.Logical{
|
||||
ListWithContextFn: func(ctx context.Context, path string) (*vault.Secret, error) {
|
||||
return nil, nil
|
||||
},
|
||||
ReadWithDataWithContextFn: newReadtWithContextFn(map[string]any{}),
|
||||
},
|
||||
data: esv1beta1.ExternalSecretFind{
|
||||
Path: &path,
|
||||
},
|
||||
},
|
||||
want: want{
|
||||
err: esv1beta1.NoSecretError{},
|
||||
},
|
||||
},
|
||||
"FilterByPathKv1": {
|
||||
reason: "should filter secrets based on path for kv1",
|
||||
args: args{
|
||||
|
|
Loading…
Reference in a new issue