generic_store.go 2.7 KB

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