provider.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 v1beta1
  13. import (
  14. "context"
  15. "sigs.k8s.io/controller-runtime/pkg/client"
  16. )
  17. // +kubebuilder:object:root=false
  18. // +kubebuilder:object:generate:false
  19. // +k8s:deepcopy-gen:interfaces=nil
  20. // +k8s:deepcopy-gen=nil
  21. // Provider is a common interface for interacting with secret backends.
  22. type Provider interface {
  23. // NewClient constructs a SecretsManager Provider
  24. NewClient(ctx context.Context, store GenericStore, kube client.Client, namespace string) (SecretsClient, error)
  25. // ValidateStore checks if the provided store is valid
  26. ValidateStore(store GenericStore) error
  27. }
  28. // +kubebuilder:object:root=false
  29. // +kubebuilder:object:generate:false
  30. // +k8s:deepcopy-gen:interfaces=nil
  31. // +k8s:deepcopy-gen=nil
  32. // SecretsClient provides access to secrets.
  33. type SecretsClient interface {
  34. // GetSecret returns a single secret from the provider
  35. GetSecret(ctx context.Context, ref ExternalSecretDataRemoteRef) ([]byte, error)
  36. // Validate checks if the client is configured correctly
  37. // and is able to retrieve secrets from the provider
  38. Validate() error
  39. // GetSecretMap returns multiple k/v pairs from the provider
  40. GetSecretMap(ctx context.Context, ref ExternalSecretDataRemoteRef) (map[string][]byte, error)
  41. // GetAllSecrets returns multiple k/v pairs from the provider
  42. GetAllSecrets(ctx context.Context, ref ExternalSecretFind) (map[string][]byte, error)
  43. Close(ctx context.Context) error
  44. }