generic_store.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 v2alpha1
  14. import (
  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 ProviderStore
  23. // or ClusterProviderStore resources.
  24. type GenericStore interface {
  25. runtime.Object
  26. metav1.Object
  27. GetKind() string
  28. GetRuntimeRef() StoreRuntimeRef
  29. GetBackendRef() BackendObjectReference
  30. GetConditions() []StoreNamespaceCondition
  31. GetStoreStatus() ProviderStoreStatus
  32. SetStoreStatus(ProviderStoreStatus)
  33. Copy() GenericStore
  34. }
  35. // +kubebuilder:object:root=false
  36. // +kubebuilder:object:generate:false
  37. var _ GenericStore = &ProviderStore{}
  38. // GetKind returns the resource kind for this ProviderStore.
  39. func (s *ProviderStore) GetKind() string {
  40. return ProviderStoreKindStr
  41. }
  42. // GetRuntimeRef returns the runtime reference configured for this ProviderStore.
  43. func (s *ProviderStore) GetRuntimeRef() StoreRuntimeRef {
  44. return s.Spec.RuntimeRef
  45. }
  46. // GetBackendRef returns the backend reference configured for this ProviderStore.
  47. func (s *ProviderStore) GetBackendRef() BackendObjectReference {
  48. return s.Spec.BackendRef
  49. }
  50. // GetConditions returns namespace conditions for this store.
  51. func (s *ProviderStore) GetConditions() []StoreNamespaceCondition {
  52. return nil
  53. }
  54. // GetStoreStatus returns the current status for this ProviderStore.
  55. func (s *ProviderStore) GetStoreStatus() ProviderStoreStatus {
  56. return s.Status
  57. }
  58. // SetStoreStatus updates the current status for this ProviderStore.
  59. func (s *ProviderStore) SetStoreStatus(status ProviderStoreStatus) {
  60. s.Status = status
  61. }
  62. // Copy returns a deep-copied GenericStore instance for this ProviderStore.
  63. func (s *ProviderStore) Copy() GenericStore {
  64. return s.DeepCopy()
  65. }
  66. // +kubebuilder:object:root=false
  67. // +kubebuilder:object:generate:false
  68. var _ GenericStore = &ClusterProviderStore{}
  69. // GetKind returns the resource kind for this ClusterProviderStore.
  70. func (s *ClusterProviderStore) GetKind() string {
  71. return ClusterProviderStoreKindStr
  72. }
  73. // GetRuntimeRef returns the runtime reference configured for this ClusterProviderStore.
  74. func (s *ClusterProviderStore) GetRuntimeRef() StoreRuntimeRef {
  75. return s.Spec.RuntimeRef
  76. }
  77. // GetBackendRef returns the backend reference configured for this ClusterProviderStore.
  78. func (s *ClusterProviderStore) GetBackendRef() BackendObjectReference {
  79. return s.Spec.BackendRef
  80. }
  81. // GetConditions returns namespace conditions for this store.
  82. func (s *ClusterProviderStore) GetConditions() []StoreNamespaceCondition {
  83. return s.Spec.Conditions
  84. }
  85. // GetStoreStatus returns the current status for this ClusterProviderStore.
  86. func (s *ClusterProviderStore) GetStoreStatus() ProviderStoreStatus {
  87. return s.Status
  88. }
  89. // SetStoreStatus updates the current status for this ClusterProviderStore.
  90. func (s *ClusterProviderStore) SetStoreStatus(status ProviderStoreStatus) {
  91. s.Status = status
  92. }
  93. // Copy returns a deep-copied GenericStore instance for this ClusterProviderStore.
  94. func (s *ClusterProviderStore) Copy() GenericStore {
  95. return s.DeepCopy()
  96. }