csidriver.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. Copyright The Kubernetes 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. http://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. // Code generated by applyconfiguration-gen. DO NOT EDIT.
  14. package v1beta1
  15. import (
  16. storagev1beta1 "k8s.io/api/storage/v1beta1"
  17. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  18. types "k8s.io/apimachinery/pkg/types"
  19. managedfields "k8s.io/apimachinery/pkg/util/managedfields"
  20. internal "k8s.io/client-go/applyconfigurations/internal"
  21. v1 "k8s.io/client-go/applyconfigurations/meta/v1"
  22. )
  23. // CSIDriverApplyConfiguration represents an declarative configuration of the CSIDriver type for use
  24. // with apply.
  25. type CSIDriverApplyConfiguration struct {
  26. v1.TypeMetaApplyConfiguration `json:",inline"`
  27. *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
  28. Spec *CSIDriverSpecApplyConfiguration `json:"spec,omitempty"`
  29. }
  30. // CSIDriver constructs an declarative configuration of the CSIDriver type for use with
  31. // apply.
  32. func CSIDriver(name string) *CSIDriverApplyConfiguration {
  33. b := &CSIDriverApplyConfiguration{}
  34. b.WithName(name)
  35. b.WithKind("CSIDriver")
  36. b.WithAPIVersion("storage.k8s.io/v1beta1")
  37. return b
  38. }
  39. // ExtractCSIDriver extracts the applied configuration owned by fieldManager from
  40. // cSIDriver. If no managedFields are found in cSIDriver for fieldManager, a
  41. // CSIDriverApplyConfiguration is returned with only the Name, Namespace (if applicable),
  42. // APIVersion and Kind populated. It is possible that no managed fields were found for because other
  43. // field managers have taken ownership of all the fields previously owned by fieldManager, or because
  44. // the fieldManager never owned fields any fields.
  45. // cSIDriver must be a unmodified CSIDriver API object that was retrieved from the Kubernetes API.
  46. // ExtractCSIDriver provides a way to perform a extract/modify-in-place/apply workflow.
  47. // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
  48. // applied if another fieldManager has updated or force applied any of the previously applied fields.
  49. // Experimental!
  50. func ExtractCSIDriver(cSIDriver *storagev1beta1.CSIDriver, fieldManager string) (*CSIDriverApplyConfiguration, error) {
  51. return extractCSIDriver(cSIDriver, fieldManager, "")
  52. }
  53. // ExtractCSIDriverStatus is the same as ExtractCSIDriver except
  54. // that it extracts the status subresource applied configuration.
  55. // Experimental!
  56. func ExtractCSIDriverStatus(cSIDriver *storagev1beta1.CSIDriver, fieldManager string) (*CSIDriverApplyConfiguration, error) {
  57. return extractCSIDriver(cSIDriver, fieldManager, "status")
  58. }
  59. func extractCSIDriver(cSIDriver *storagev1beta1.CSIDriver, fieldManager string, subresource string) (*CSIDriverApplyConfiguration, error) {
  60. b := &CSIDriverApplyConfiguration{}
  61. err := managedfields.ExtractInto(cSIDriver, internal.Parser().Type("io.k8s.api.storage.v1beta1.CSIDriver"), fieldManager, b, subresource)
  62. if err != nil {
  63. return nil, err
  64. }
  65. b.WithName(cSIDriver.Name)
  66. b.WithKind("CSIDriver")
  67. b.WithAPIVersion("storage.k8s.io/v1beta1")
  68. return b, nil
  69. }
  70. // WithKind sets the Kind field in the declarative configuration to the given value
  71. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  72. // If called multiple times, the Kind field is set to the value of the last call.
  73. func (b *CSIDriverApplyConfiguration) WithKind(value string) *CSIDriverApplyConfiguration {
  74. b.Kind = &value
  75. return b
  76. }
  77. // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
  78. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  79. // If called multiple times, the APIVersion field is set to the value of the last call.
  80. func (b *CSIDriverApplyConfiguration) WithAPIVersion(value string) *CSIDriverApplyConfiguration {
  81. b.APIVersion = &value
  82. return b
  83. }
  84. // WithName sets the Name field in the declarative configuration to the given value
  85. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  86. // If called multiple times, the Name field is set to the value of the last call.
  87. func (b *CSIDriverApplyConfiguration) WithName(value string) *CSIDriverApplyConfiguration {
  88. b.ensureObjectMetaApplyConfigurationExists()
  89. b.Name = &value
  90. return b
  91. }
  92. // WithGenerateName sets the GenerateName field in the declarative configuration to the given value
  93. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  94. // If called multiple times, the GenerateName field is set to the value of the last call.
  95. func (b *CSIDriverApplyConfiguration) WithGenerateName(value string) *CSIDriverApplyConfiguration {
  96. b.ensureObjectMetaApplyConfigurationExists()
  97. b.GenerateName = &value
  98. return b
  99. }
  100. // WithNamespace sets the Namespace field in the declarative configuration to the given value
  101. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  102. // If called multiple times, the Namespace field is set to the value of the last call.
  103. func (b *CSIDriverApplyConfiguration) WithNamespace(value string) *CSIDriverApplyConfiguration {
  104. b.ensureObjectMetaApplyConfigurationExists()
  105. b.Namespace = &value
  106. return b
  107. }
  108. // WithUID sets the UID field in the declarative configuration to the given value
  109. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  110. // If called multiple times, the UID field is set to the value of the last call.
  111. func (b *CSIDriverApplyConfiguration) WithUID(value types.UID) *CSIDriverApplyConfiguration {
  112. b.ensureObjectMetaApplyConfigurationExists()
  113. b.UID = &value
  114. return b
  115. }
  116. // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
  117. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  118. // If called multiple times, the ResourceVersion field is set to the value of the last call.
  119. func (b *CSIDriverApplyConfiguration) WithResourceVersion(value string) *CSIDriverApplyConfiguration {
  120. b.ensureObjectMetaApplyConfigurationExists()
  121. b.ResourceVersion = &value
  122. return b
  123. }
  124. // WithGeneration sets the Generation field in the declarative configuration to the given value
  125. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  126. // If called multiple times, the Generation field is set to the value of the last call.
  127. func (b *CSIDriverApplyConfiguration) WithGeneration(value int64) *CSIDriverApplyConfiguration {
  128. b.ensureObjectMetaApplyConfigurationExists()
  129. b.Generation = &value
  130. return b
  131. }
  132. // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
  133. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  134. // If called multiple times, the CreationTimestamp field is set to the value of the last call.
  135. func (b *CSIDriverApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CSIDriverApplyConfiguration {
  136. b.ensureObjectMetaApplyConfigurationExists()
  137. b.CreationTimestamp = &value
  138. return b
  139. }
  140. // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
  141. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  142. // If called multiple times, the DeletionTimestamp field is set to the value of the last call.
  143. func (b *CSIDriverApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CSIDriverApplyConfiguration {
  144. b.ensureObjectMetaApplyConfigurationExists()
  145. b.DeletionTimestamp = &value
  146. return b
  147. }
  148. // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
  149. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  150. // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
  151. func (b *CSIDriverApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CSIDriverApplyConfiguration {
  152. b.ensureObjectMetaApplyConfigurationExists()
  153. b.DeletionGracePeriodSeconds = &value
  154. return b
  155. }
  156. // WithLabels puts the entries into the Labels field in the declarative configuration
  157. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  158. // If called multiple times, the entries provided by each call will be put on the Labels field,
  159. // overwriting an existing map entries in Labels field with the same key.
  160. func (b *CSIDriverApplyConfiguration) WithLabels(entries map[string]string) *CSIDriverApplyConfiguration {
  161. b.ensureObjectMetaApplyConfigurationExists()
  162. if b.Labels == nil && len(entries) > 0 {
  163. b.Labels = make(map[string]string, len(entries))
  164. }
  165. for k, v := range entries {
  166. b.Labels[k] = v
  167. }
  168. return b
  169. }
  170. // WithAnnotations puts the entries into the Annotations field in the declarative configuration
  171. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  172. // If called multiple times, the entries provided by each call will be put on the Annotations field,
  173. // overwriting an existing map entries in Annotations field with the same key.
  174. func (b *CSIDriverApplyConfiguration) WithAnnotations(entries map[string]string) *CSIDriverApplyConfiguration {
  175. b.ensureObjectMetaApplyConfigurationExists()
  176. if b.Annotations == nil && len(entries) > 0 {
  177. b.Annotations = make(map[string]string, len(entries))
  178. }
  179. for k, v := range entries {
  180. b.Annotations[k] = v
  181. }
  182. return b
  183. }
  184. // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
  185. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  186. // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
  187. func (b *CSIDriverApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CSIDriverApplyConfiguration {
  188. b.ensureObjectMetaApplyConfigurationExists()
  189. for i := range values {
  190. if values[i] == nil {
  191. panic("nil value passed to WithOwnerReferences")
  192. }
  193. b.OwnerReferences = append(b.OwnerReferences, *values[i])
  194. }
  195. return b
  196. }
  197. // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
  198. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  199. // If called multiple times, values provided by each call will be appended to the Finalizers field.
  200. func (b *CSIDriverApplyConfiguration) WithFinalizers(values ...string) *CSIDriverApplyConfiguration {
  201. b.ensureObjectMetaApplyConfigurationExists()
  202. for i := range values {
  203. b.Finalizers = append(b.Finalizers, values[i])
  204. }
  205. return b
  206. }
  207. func (b *CSIDriverApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
  208. if b.ObjectMetaApplyConfiguration == nil {
  209. b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
  210. }
  211. }
  212. // WithSpec sets the Spec field in the declarative configuration to the given value
  213. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  214. // If called multiple times, the Spec field is set to the value of the last call.
  215. func (b *CSIDriverApplyConfiguration) WithSpec(value *CSIDriverSpecApplyConfiguration) *CSIDriverApplyConfiguration {
  216. b.Spec = value
  217. return b
  218. }