generic_store.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. Copyright © The ESO Authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v1
  14. import (
  15. "fmt"
  16. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  17. "k8s.io/apimachinery/pkg/runtime"
  18. )
  19. // +kubebuilder:object:root=false
  20. // +kubebuilder:object:generate:false
  21. // +k8s:deepcopy-gen:interfaces=nil
  22. // +k8s:deepcopy-gen=nil
  23. // GenericStore is a common interface for interacting with ClusterSecretStore
  24. // or a namespaced SecretStore.
  25. type GenericStore interface {
  26. runtime.Object
  27. metav1.Object
  28. GetObjectMeta() *metav1.ObjectMeta
  29. GetTypeMeta() *metav1.TypeMeta
  30. GetKind() string
  31. GetSpec() *SecretStoreSpec
  32. GetNamespacedName() string
  33. GetStatus() SecretStoreStatus
  34. SetStatus(status SecretStoreStatus)
  35. Copy() GenericStore
  36. }
  37. // +kubebuilder:object:root:false
  38. // +kubebuilder:object:generate:false
  39. var _ GenericStore = &SecretStore{}
  40. // GetObjectMeta returns the ObjectMeta of the SecretStore.
  41. func (c *SecretStore) GetObjectMeta() *metav1.ObjectMeta {
  42. return &c.ObjectMeta
  43. }
  44. // GetTypeMeta returns the TypeMeta of the SecretStore.
  45. func (c *SecretStore) GetTypeMeta() *metav1.TypeMeta {
  46. return &c.TypeMeta
  47. }
  48. // GetSpec returns the Spec of the SecretStore.
  49. func (c *SecretStore) GetSpec() *SecretStoreSpec {
  50. return &c.Spec
  51. }
  52. // GetStatus returns the Status of the SecretStore.
  53. func (c *SecretStore) GetStatus() SecretStoreStatus {
  54. return c.Status
  55. }
  56. // SetStatus sets the Status of the SecretStore.
  57. func (c *SecretStore) SetStatus(status SecretStoreStatus) {
  58. c.Status = status
  59. }
  60. // GetNamespacedName returns the namespaced name of the SecretStore in the format "namespace/name".
  61. func (c *SecretStore) GetNamespacedName() string {
  62. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  63. }
  64. // GetKind returns the kind of the SecretStore.
  65. func (c *SecretStore) GetKind() string {
  66. return SecretStoreKind
  67. }
  68. // Copy returns a deep copy of the SecretStore.
  69. func (c *SecretStore) Copy() GenericStore {
  70. return c.DeepCopy()
  71. }
  72. // +kubebuilder:object:root:false
  73. // +kubebuilder:object:generate:false
  74. var _ GenericStore = &ClusterSecretStore{}
  75. // GetObjectMeta returns the ObjectMeta of the ClusterSecretStore.
  76. func (c *ClusterSecretStore) GetObjectMeta() *metav1.ObjectMeta {
  77. return &c.ObjectMeta
  78. }
  79. // GetTypeMeta returns the TypeMeta of the ClusterSecretStore.
  80. func (c *ClusterSecretStore) GetTypeMeta() *metav1.TypeMeta {
  81. return &c.TypeMeta
  82. }
  83. // GetSpec returns the Spec of the ClusterSecretStore.
  84. func (c *ClusterSecretStore) GetSpec() *SecretStoreSpec {
  85. return &c.Spec
  86. }
  87. // Copy returns a deep copy of the ClusterSecretStore.
  88. func (c *ClusterSecretStore) Copy() GenericStore {
  89. return c.DeepCopy()
  90. }
  91. // GetStatus returns the Status of the ClusterSecretStore.
  92. func (c *ClusterSecretStore) GetStatus() SecretStoreStatus {
  93. return c.Status
  94. }
  95. // SetStatus sets the Status of the ClusterSecretStore.
  96. func (c *ClusterSecretStore) SetStatus(status SecretStoreStatus) {
  97. c.Status = status
  98. }
  99. // GetNamespacedName returns the namespaced name of the ClusterSecretStore in the format "namespace/name".
  100. func (c *ClusterSecretStore) GetNamespacedName() string {
  101. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  102. }
  103. // GetKind returns the kind of the ClusterSecretStore.
  104. func (c *ClusterSecretStore) GetKind() string {
  105. return ClusterSecretStoreKind
  106. }