generic_store.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. GetObjectMeta() *metav1.ObjectMeta
  28. GetSpec() *SecretStoreSpec
  29. GetNamespacedName() string
  30. }
  31. // +kubebuilder:object:root:false
  32. // +kubebuilder:object:generate:false
  33. var _ GenericStore = &SecretStore{}
  34. func (c *SecretStore) GetObjectMeta() *metav1.ObjectMeta {
  35. return &c.ObjectMeta
  36. }
  37. func (c *SecretStore) GetSpec() *SecretStoreSpec {
  38. return &c.Spec
  39. }
  40. func (c *SecretStore) GetNamespacedName() string {
  41. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  42. }
  43. func (c *SecretStore) Copy() GenericStore {
  44. return c.DeepCopy()
  45. }
  46. // +kubebuilder:object:root:false
  47. // +kubebuilder:object:generate:false
  48. var _ GenericStore = &ClusterSecretStore{}
  49. func (c *ClusterSecretStore) GetObjectMeta() *metav1.ObjectMeta {
  50. return &c.ObjectMeta
  51. }
  52. func (c *ClusterSecretStore) GetSpec() *SecretStoreSpec {
  53. return &c.Spec
  54. }
  55. func (c *ClusterSecretStore) Copy() GenericStore {
  56. return c.DeepCopy()
  57. }
  58. func (c *ClusterSecretStore) GetNamespacedName() string {
  59. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  60. }