secretsclient.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 ydxcommon
  14. import (
  15. "context"
  16. "errors"
  17. corev1 "k8s.io/api/core/v1"
  18. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  19. )
  20. const (
  21. errNotImplemented = "not implemented"
  22. )
  23. // https://github.com/external-secrets/external-secrets/issues/644
  24. var _ esv1.SecretsClient = &yandexCloudSecretsClient{}
  25. // Implementation of v1beta1.SecretsClient.
  26. type yandexCloudSecretsClient struct {
  27. secretGetter SecretGetter
  28. secretSetter SecretSetter
  29. iamToken string
  30. resourceKeyType ResourceKeyType
  31. folderID string
  32. }
  33. func (c *yandexCloudSecretsClient) GetSecret(ctx context.Context, ref esv1.ExternalSecretDataRemoteRef) ([]byte, error) {
  34. return c.secretGetter.GetSecret(ctx, c.iamToken, ref.Key, c.resourceKeyType, c.folderID, ref.Version, ref.Property)
  35. }
  36. func (c *yandexCloudSecretsClient) DeleteSecret(_ context.Context, _ esv1.PushSecretRemoteRef) error {
  37. return errors.New(errNotImplemented)
  38. }
  39. func (c *yandexCloudSecretsClient) SecretExists(_ context.Context, _ esv1.PushSecretRemoteRef) (bool, error) {
  40. return false, errors.New(errNotImplemented)
  41. }
  42. func (c *yandexCloudSecretsClient) PushSecret(_ context.Context, _ *corev1.Secret, _ esv1.PushSecretData) error {
  43. return errors.New(errNotImplemented)
  44. }
  45. func (c *yandexCloudSecretsClient) Validate() (esv1.ValidationResult, error) {
  46. return esv1.ValidationResultReady, nil
  47. }
  48. func (c *yandexCloudSecretsClient) GetSecretMap(ctx context.Context, ref esv1.ExternalSecretDataRemoteRef) (map[string][]byte, error) {
  49. return c.secretGetter.GetSecretMap(ctx, c.iamToken, ref.Key, c.resourceKeyType, c.folderID, ref.Version)
  50. }
  51. func (c *yandexCloudSecretsClient) GetAllSecrets(_ context.Context, _ esv1.ExternalSecretFind) (map[string][]byte, error) {
  52. // TO be implemented
  53. return nil, errors.New(errNotImplemented)
  54. }
  55. func (c *yandexCloudSecretsClient) Close(_ context.Context) error {
  56. return nil
  57. }