client_delete_secret.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Copyright © The ESO Authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package ovh
  14. import (
  15. "context"
  16. "errors"
  17. "fmt"
  18. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  19. )
  20. // If deletionPolicy is set to Delete, the Secret Manager Secret
  21. // created from the Push Secret will be automatically removed
  22. // when the associated Push Secret is deleted.
  23. func (cl *ovhClient) DeleteSecret(ctx context.Context, remoteRef esv1.PushSecretRemoteRef) error {
  24. err := cl.okmsClient.DeleteSecretV2(ctx, cl.okmsID, remoteRef.GetRemoteKey())
  25. if err != nil {
  26. err = handleOkmsError(err)
  27. if errors.Is(err, esv1.NoSecretErr) {
  28. return nil
  29. }
  30. return fmt.Errorf("failed to delete secret at path %q: %w", remoteRef.GetRemoteKey(), err)
  31. }
  32. return nil
  33. }