runtimeclass.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 v1alpha1
  15. import (
  16. nodev1alpha1 "k8s.io/api/node/v1alpha1"
  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. // RuntimeClassApplyConfiguration represents an declarative configuration of the RuntimeClass type for use
  24. // with apply.
  25. type RuntimeClassApplyConfiguration struct {
  26. v1.TypeMetaApplyConfiguration `json:",inline"`
  27. *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
  28. Spec *RuntimeClassSpecApplyConfiguration `json:"spec,omitempty"`
  29. }
  30. // RuntimeClass constructs an declarative configuration of the RuntimeClass type for use with
  31. // apply.
  32. func RuntimeClass(name string) *RuntimeClassApplyConfiguration {
  33. b := &RuntimeClassApplyConfiguration{}
  34. b.WithName(name)
  35. b.WithKind("RuntimeClass")
  36. b.WithAPIVersion("node.k8s.io/v1alpha1")
  37. return b
  38. }
  39. // ExtractRuntimeClass extracts the applied configuration owned by fieldManager from
  40. // runtimeClass. If no managedFields are found in runtimeClass for fieldManager, a
  41. // RuntimeClassApplyConfiguration is returned with only the Name, Namespace (if applicable),
  42. // APIVersion and Kind populated. Is 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. // runtimeClass must be a unmodified RuntimeClass API object that was retrieved from the Kubernetes API.
  46. // ExtractRuntimeClass 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 ExtractRuntimeClass(runtimeClass *nodev1alpha1.RuntimeClass, fieldManager string) (*RuntimeClassApplyConfiguration, error) {
  51. b := &RuntimeClassApplyConfiguration{}
  52. err := managedfields.ExtractInto(runtimeClass, internal.Parser().Type("io.k8s.api.node.v1alpha1.RuntimeClass"), fieldManager, b)
  53. if err != nil {
  54. return nil, err
  55. }
  56. b.WithName(runtimeClass.Name)
  57. b.WithKind("RuntimeClass")
  58. b.WithAPIVersion("node.k8s.io/v1alpha1")
  59. return b, nil
  60. }
  61. // WithKind sets the Kind field in the declarative configuration to the given value
  62. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  63. // If called multiple times, the Kind field is set to the value of the last call.
  64. func (b *RuntimeClassApplyConfiguration) WithKind(value string) *RuntimeClassApplyConfiguration {
  65. b.Kind = &value
  66. return b
  67. }
  68. // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
  69. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  70. // If called multiple times, the APIVersion field is set to the value of the last call.
  71. func (b *RuntimeClassApplyConfiguration) WithAPIVersion(value string) *RuntimeClassApplyConfiguration {
  72. b.APIVersion = &value
  73. return b
  74. }
  75. // WithName sets the Name field in the declarative configuration to the given value
  76. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  77. // If called multiple times, the Name field is set to the value of the last call.
  78. func (b *RuntimeClassApplyConfiguration) WithName(value string) *RuntimeClassApplyConfiguration {
  79. b.ensureObjectMetaApplyConfigurationExists()
  80. b.Name = &value
  81. return b
  82. }
  83. // WithGenerateName sets the GenerateName field in the declarative configuration to the given value
  84. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  85. // If called multiple times, the GenerateName field is set to the value of the last call.
  86. func (b *RuntimeClassApplyConfiguration) WithGenerateName(value string) *RuntimeClassApplyConfiguration {
  87. b.ensureObjectMetaApplyConfigurationExists()
  88. b.GenerateName = &value
  89. return b
  90. }
  91. // WithNamespace sets the Namespace field in the declarative configuration to the given value
  92. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  93. // If called multiple times, the Namespace field is set to the value of the last call.
  94. func (b *RuntimeClassApplyConfiguration) WithNamespace(value string) *RuntimeClassApplyConfiguration {
  95. b.ensureObjectMetaApplyConfigurationExists()
  96. b.Namespace = &value
  97. return b
  98. }
  99. // WithSelfLink sets the SelfLink field in the declarative configuration to the given value
  100. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  101. // If called multiple times, the SelfLink field is set to the value of the last call.
  102. func (b *RuntimeClassApplyConfiguration) WithSelfLink(value string) *RuntimeClassApplyConfiguration {
  103. b.ensureObjectMetaApplyConfigurationExists()
  104. b.SelfLink = &value
  105. return b
  106. }
  107. // WithUID sets the UID field in the declarative configuration to the given value
  108. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  109. // If called multiple times, the UID field is set to the value of the last call.
  110. func (b *RuntimeClassApplyConfiguration) WithUID(value types.UID) *RuntimeClassApplyConfiguration {
  111. b.ensureObjectMetaApplyConfigurationExists()
  112. b.UID = &value
  113. return b
  114. }
  115. // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
  116. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  117. // If called multiple times, the ResourceVersion field is set to the value of the last call.
  118. func (b *RuntimeClassApplyConfiguration) WithResourceVersion(value string) *RuntimeClassApplyConfiguration {
  119. b.ensureObjectMetaApplyConfigurationExists()
  120. b.ResourceVersion = &value
  121. return b
  122. }
  123. // WithGeneration sets the Generation field in the declarative configuration to the given value
  124. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  125. // If called multiple times, the Generation field is set to the value of the last call.
  126. func (b *RuntimeClassApplyConfiguration) WithGeneration(value int64) *RuntimeClassApplyConfiguration {
  127. b.ensureObjectMetaApplyConfigurationExists()
  128. b.Generation = &value
  129. return b
  130. }
  131. // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
  132. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  133. // If called multiple times, the CreationTimestamp field is set to the value of the last call.
  134. func (b *RuntimeClassApplyConfiguration) WithCreationTimestamp(value metav1.Time) *RuntimeClassApplyConfiguration {
  135. b.ensureObjectMetaApplyConfigurationExists()
  136. b.CreationTimestamp = &value
  137. return b
  138. }
  139. // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
  140. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  141. // If called multiple times, the DeletionTimestamp field is set to the value of the last call.
  142. func (b *RuntimeClassApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *RuntimeClassApplyConfiguration {
  143. b.ensureObjectMetaApplyConfigurationExists()
  144. b.DeletionTimestamp = &value
  145. return b
  146. }
  147. // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
  148. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  149. // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
  150. func (b *RuntimeClassApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *RuntimeClassApplyConfiguration {
  151. b.ensureObjectMetaApplyConfigurationExists()
  152. b.DeletionGracePeriodSeconds = &value
  153. return b
  154. }
  155. // WithLabels puts the entries into the Labels field in the declarative configuration
  156. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  157. // If called multiple times, the entries provided by each call will be put on the Labels field,
  158. // overwriting an existing map entries in Labels field with the same key.
  159. func (b *RuntimeClassApplyConfiguration) WithLabels(entries map[string]string) *RuntimeClassApplyConfiguration {
  160. b.ensureObjectMetaApplyConfigurationExists()
  161. if b.Labels == nil && len(entries) > 0 {
  162. b.Labels = make(map[string]string, len(entries))
  163. }
  164. for k, v := range entries {
  165. b.Labels[k] = v
  166. }
  167. return b
  168. }
  169. // WithAnnotations puts the entries into the Annotations field in the declarative configuration
  170. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  171. // If called multiple times, the entries provided by each call will be put on the Annotations field,
  172. // overwriting an existing map entries in Annotations field with the same key.
  173. func (b *RuntimeClassApplyConfiguration) WithAnnotations(entries map[string]string) *RuntimeClassApplyConfiguration {
  174. b.ensureObjectMetaApplyConfigurationExists()
  175. if b.Annotations == nil && len(entries) > 0 {
  176. b.Annotations = make(map[string]string, len(entries))
  177. }
  178. for k, v := range entries {
  179. b.Annotations[k] = v
  180. }
  181. return b
  182. }
  183. // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
  184. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  185. // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
  186. func (b *RuntimeClassApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *RuntimeClassApplyConfiguration {
  187. b.ensureObjectMetaApplyConfigurationExists()
  188. for i := range values {
  189. if values[i] == nil {
  190. panic("nil value passed to WithOwnerReferences")
  191. }
  192. b.OwnerReferences = append(b.OwnerReferences, *values[i])
  193. }
  194. return b
  195. }
  196. // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
  197. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  198. // If called multiple times, values provided by each call will be appended to the Finalizers field.
  199. func (b *RuntimeClassApplyConfiguration) WithFinalizers(values ...string) *RuntimeClassApplyConfiguration {
  200. b.ensureObjectMetaApplyConfigurationExists()
  201. for i := range values {
  202. b.Finalizers = append(b.Finalizers, values[i])
  203. }
  204. return b
  205. }
  206. // WithClusterName sets the ClusterName field in the declarative configuration to the given value
  207. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  208. // If called multiple times, the ClusterName field is set to the value of the last call.
  209. func (b *RuntimeClassApplyConfiguration) WithClusterName(value string) *RuntimeClassApplyConfiguration {
  210. b.ensureObjectMetaApplyConfigurationExists()
  211. b.ClusterName = &value
  212. return b
  213. }
  214. func (b *RuntimeClassApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
  215. if b.ObjectMetaApplyConfiguration == nil {
  216. b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
  217. }
  218. }
  219. // WithSpec sets the Spec field in the declarative configuration to the given value
  220. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  221. // If called multiple times, the Spec field is set to the value of the last call.
  222. func (b *RuntimeClassApplyConfiguration) WithSpec(value *RuntimeClassSpecApplyConfiguration) *RuntimeClassApplyConfiguration {
  223. b.Spec = value
  224. return b
  225. }