generic_store.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. GetTypeMeta() *metav1.TypeMeta
  29. GetSpec() *SecretStoreSpec
  30. GetNamespacedName() string
  31. GetStatus() SecretStoreStatus
  32. SetStatus(status SecretStoreStatus)
  33. Copy() GenericStore
  34. }
  35. // +kubebuilder:object:root:false
  36. // +kubebuilder:object:generate:false
  37. var _ GenericStore = &SecretStore{}
  38. func (c *SecretStore) GetObjectMeta() *metav1.ObjectMeta {
  39. return &c.ObjectMeta
  40. }
  41. func (c *SecretStore) GetTypeMeta() *metav1.TypeMeta {
  42. return &c.TypeMeta
  43. }
  44. func (c *SecretStore) GetSpec() *SecretStoreSpec {
  45. return &c.Spec
  46. }
  47. func (c *SecretStore) GetStatus() SecretStoreStatus {
  48. return c.Status
  49. }
  50. func (c *SecretStore) SetStatus(status SecretStoreStatus) {
  51. c.Status = status
  52. }
  53. func (c *SecretStore) GetNamespacedName() string {
  54. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  55. }
  56. func (c *SecretStore) Copy() GenericStore {
  57. return c.DeepCopy()
  58. }
  59. // +kubebuilder:object:root:false
  60. // +kubebuilder:object:generate:false
  61. var _ GenericStore = &ClusterSecretStore{}
  62. func (c *ClusterSecretStore) GetObjectMeta() *metav1.ObjectMeta {
  63. return &c.ObjectMeta
  64. }
  65. func (c *ClusterSecretStore) GetTypeMeta() *metav1.TypeMeta {
  66. return &c.TypeMeta
  67. }
  68. func (c *ClusterSecretStore) GetSpec() *SecretStoreSpec {
  69. return &c.Spec
  70. }
  71. func (c *ClusterSecretStore) Copy() GenericStore {
  72. return c.DeepCopy()
  73. }
  74. func (c *ClusterSecretStore) GetStatus() SecretStoreStatus {
  75. return c.Status
  76. }
  77. func (c *ClusterSecretStore) SetStatus(status SecretStoreStatus) {
  78. c.Status = status
  79. }
  80. func (c *ClusterSecretStore) GetNamespacedName() string {
  81. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  82. }