secretsclient.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. corev1 "k8s.io/api/core/v1"
  17. esv1beta1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1beta1"
  18. )
  19. // https://github.com/external-secrets/external-secrets/issues/644
  20. var _ esv1beta1.SecretsClient = &yandexCloudSecretsClient{}
  21. // Implementation of v1beta1.SecretsClient.
  22. type yandexCloudSecretsClient struct {
  23. secretGetter SecretGetter
  24. secretSetter SecretSetter
  25. iamToken string
  26. }
  27. func (c *yandexCloudSecretsClient) GetSecret(ctx context.Context, ref esv1beta1.ExternalSecretDataRemoteRef) ([]byte, error) {
  28. return c.secretGetter.GetSecret(ctx, c.iamToken, ref.Key, ref.Version, ref.Property)
  29. }
  30. func (c *yandexCloudSecretsClient) DeleteSecret(_ context.Context, _ esv1beta1.PushSecretRemoteRef) error {
  31. return fmt.Errorf("not implemented")
  32. }
  33. func (c *yandexCloudSecretsClient) PushSecret(_ context.Context, _ *corev1.Secret, _ esv1beta1.PushSecretData) error {
  34. return fmt.Errorf("not implemented")
  35. }
  36. func (c *yandexCloudSecretsClient) Validate() (esv1beta1.ValidationResult, error) {
  37. return esv1beta1.ValidationResultReady, nil
  38. }
  39. func (c *yandexCloudSecretsClient) GetSecretMap(ctx context.Context, ref esv1beta1.ExternalSecretDataRemoteRef) (map[string][]byte, error) {
  40. return c.secretGetter.GetSecretMap(ctx, c.iamToken, ref.Key, ref.Version)
  41. }
  42. func (c *yandexCloudSecretsClient) GetAllSecrets(_ context.Context, _ esv1beta1.ExternalSecretFind) (map[string][]byte, error) {
  43. // TO be implemented
  44. return nil, fmt.Errorf("GetAllSecrets not supported")
  45. }
  46. func (c *yandexCloudSecretsClient) Close(_ context.Context) error {
  47. return nil
  48. }