runtimeclass.go 13 KB

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