Fix a bug in storage/driver/secrets.go Delete() (#7348)

* Fix a bug in storage/driver/secrets.go
pull/7777/head
tiendc 5 years ago committed by GitHub
parent 3cc5811de5
commit 06bc18c624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -185,11 +185,7 @@ func (secrets *Secrets) Update(key string, rls *rspb.Release) error {
func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error) {
// fetch the release to check existence
if rls, err = secrets.Get(key); err != nil {
if apierrors.IsNotFound(err) {
return nil, ErrReleaseExists
}
return nil, errors.Wrapf(err, "delete: failed to get release %q", key)
return nil, err
}
// delete the release
err = secrets.impl.Delete(key, &metav1.DeleteOptions{})

@ -194,6 +194,12 @@ func TestSecretDelete(t *testing.T) {
secrets := newTestFixtureSecrets(t, []*rspb.Release{rel}...)
// perform the delete on a non-existing release
_, err := secrets.Delete("nonexistent")
if err != ErrReleaseNotFound {
t.Fatalf("Expected ErrReleaseNotFound, got: {%v}", err)
}
// perform the delete
rls, err := secrets.Delete(key)
if err != nil {

Loading…
Cancel
Save