generic_store.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. Copyright © 2025 ESO Maintainer Team
  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. func (c *SecretStore) GetObjectMeta() *metav1.ObjectMeta {
  41. return &c.ObjectMeta
  42. }
  43. func (c *SecretStore) GetTypeMeta() *metav1.TypeMeta {
  44. return &c.TypeMeta
  45. }
  46. func (c *SecretStore) GetSpec() *SecretStoreSpec {
  47. return &c.Spec
  48. }
  49. func (c *SecretStore) GetStatus() SecretStoreStatus {
  50. return c.Status
  51. }
  52. func (c *SecretStore) SetStatus(status SecretStoreStatus) {
  53. c.Status = status
  54. }
  55. func (c *SecretStore) GetNamespacedName() string {
  56. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  57. }
  58. func (c *SecretStore) GetKind() string {
  59. return SecretStoreKind
  60. }
  61. func (c *SecretStore) Copy() GenericStore {
  62. return c.DeepCopy()
  63. }
  64. // +kubebuilder:object:root:false
  65. // +kubebuilder:object:generate:false
  66. var _ GenericStore = &ClusterSecretStore{}
  67. func (c *ClusterSecretStore) GetObjectMeta() *metav1.ObjectMeta {
  68. return &c.ObjectMeta
  69. }
  70. func (c *ClusterSecretStore) GetTypeMeta() *metav1.TypeMeta {
  71. return &c.TypeMeta
  72. }
  73. func (c *ClusterSecretStore) GetSpec() *SecretStoreSpec {
  74. return &c.Spec
  75. }
  76. func (c *ClusterSecretStore) Copy() GenericStore {
  77. return c.DeepCopy()
  78. }
  79. func (c *ClusterSecretStore) GetStatus() SecretStoreStatus {
  80. return c.Status
  81. }
  82. func (c *ClusterSecretStore) SetStatus(status SecretStoreStatus) {
  83. c.Status = status
  84. }
  85. func (c *ClusterSecretStore) GetNamespacedName() string {
  86. return fmt.Sprintf("%s/%s", c.Namespace, c.Name)
  87. }
  88. func (c *ClusterSecretStore) GetKind() string {
  89. return ClusterSecretStoreKind
  90. }