secretsclient.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package common
  13. import (
  14. "context"
  15. "fmt"
  16. esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
  17. )
  18. // https://github.com/external-secrets/external-secrets/issues/644
  19. var _ esv1beta1.SecretsClient = &yandexCloudSecretsClient{}
  20. // Implementation of v1beta1.SecretsClient.
  21. type yandexCloudSecretsClient struct {
  22. secretGetter SecretGetter
  23. secretSetter SecretSetter
  24. iamToken string
  25. }
  26. func (c *yandexCloudSecretsClient) GetSecret(ctx context.Context, ref esv1beta1.ExternalSecretDataRemoteRef) ([]byte, error) {
  27. return c.secretGetter.GetSecret(ctx, c.iamToken, ref.Key, ref.Version, ref.Property)
  28. }
  29. func (c *yandexCloudSecretsClient) DeleteSecret(ctx context.Context, remoteRef esv1beta1.PushRemoteRef) error {
  30. return fmt.Errorf("not implemented")
  31. }
  32. func (c *yandexCloudSecretsClient) PushSecret(ctx context.Context, value []byte, remoteRef esv1beta1.PushRemoteRef) error {
  33. return fmt.Errorf("not implemented")
  34. }
  35. func (c *yandexCloudSecretsClient) Validate() (esv1beta1.ValidationResult, error) {
  36. return esv1beta1.ValidationResultReady, nil
  37. }
  38. func (c *yandexCloudSecretsClient) GetSecretMap(ctx context.Context, ref esv1beta1.ExternalSecretDataRemoteRef) (map[string][]byte, error) {
  39. return c.secretGetter.GetSecretMap(ctx, c.iamToken, ref.Key, ref.Version)
  40. }
  41. func (c *yandexCloudSecretsClient) GetAllSecrets(ctx context.Context, ref esv1beta1.ExternalSecretFind) (map[string][]byte, error) {
  42. // TO be implemented
  43. return nil, fmt.Errorf("GetAllSecrets not supported")
  44. }
  45. func (c *yandexCloudSecretsClient) Close(ctx context.Context) error {
  46. return nil
  47. }