generic_store.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 v1alpha1
  13. import (
  14. "fmt"
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. "k8s.io/apimachinery/pkg/runtime"
  17. )
  18. // +kubebuilder:object:root=false
  19. // +kubebuilder:object:generate:false
  20. // +k8s:deepcopy-gen:interfaces=nil
  21. // +k8s:deepcopy-gen=nil
  22. // GenericStore is a common interface for interacting with ClusterSecretStore
  23. // or a namespaced SecretStore.
  24. type GenericStore interface {
  25. runtime.Object
  26. metav1.Object
  27. GetProvider() *SecretStoreProvider
  28. GetNamespacedName() string
  29. }
  30. // +kubebuilder:object:root:false
  31. // +kubebuilder:object:generate:false
  32. var _ GenericStore = &SecretStore{}
  33. // GetProvider returns the underlying provider.
  34. func (c *SecretStore) GetProvider() *SecretStoreProvider {
  35. return c.Spec.Provider
  36. }
  37. func (c *SecretStore) GetNamespacedName() string {
  38. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  39. }
  40. // Copy returns a DeepCopy of the Store.
  41. func (c *SecretStore) Copy() GenericStore {
  42. return c.DeepCopy()
  43. }