runtimeclass.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. nodev1 "k8s.io/api/node/v1"
  17. apismetav1 "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. metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
  22. )
  23. // RuntimeClassApplyConfiguration represents a declarative configuration of the RuntimeClass type for use
  24. // with apply.
  25. //
  26. // RuntimeClass defines a class of container runtime supported in the cluster.
  27. // The RuntimeClass is used to determine which container runtime is used to run
  28. // all containers in a pod. RuntimeClasses are manually defined by a
  29. // user or cluster provisioner, and referenced in the PodSpec. The Kubelet is
  30. // responsible for resolving the RuntimeClassName reference before running the
  31. // pod. For more details, see
  32. // https://kubernetes.io/docs/concepts/containers/runtime-class/
  33. type RuntimeClassApplyConfiguration struct {
  34. metav1.TypeMetaApplyConfiguration `json:",inline"`
  35. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
  36. *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
  37. // handler specifies the underlying runtime and configuration that the CRI
  38. // implementation will use to handle pods of this class. The possible values
  39. // are specific to the node & CRI configuration. It is assumed that all
  40. // handlers are available on every node, and handlers of the same name are
  41. // equivalent on every node.
  42. // For example, a handler called "runc" might specify that the runc OCI
  43. // runtime (using native Linux containers) will be used to run the containers
  44. // in a pod.
  45. // The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements,
  46. // and is immutable.
  47. Handler *string `json:"handler,omitempty"`
  48. // overhead represents the resource overhead associated with running a pod for a
  49. // given RuntimeClass. For more details, see
  50. // https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/
  51. Overhead *OverheadApplyConfiguration `json:"overhead,omitempty"`
  52. // scheduling holds the scheduling constraints to ensure that pods running
  53. // with this RuntimeClass are scheduled to nodes that support it.
  54. // If scheduling is nil, this RuntimeClass is assumed to be supported by all
  55. // nodes.
  56. Scheduling *SchedulingApplyConfiguration `json:"scheduling,omitempty"`
  57. }
  58. // RuntimeClass constructs a declarative configuration of the RuntimeClass type for use with
  59. // apply.
  60. func RuntimeClass(name string) *RuntimeClassApplyConfiguration {
  61. b := &RuntimeClassApplyConfiguration{}
  62. b.WithName(name)
  63. b.WithKind("RuntimeClass")
  64. b.WithAPIVersion("node.k8s.io/v1")
  65. return b
  66. }
  67. // ExtractRuntimeClassFrom extracts the applied configuration owned by fieldManager from
  68. // runtimeClass for the specified subresource. Pass an empty string for subresource to extract
  69. // the main resource. Common subresources include "status", "scale", etc.
  70. // runtimeClass must be a unmodified RuntimeClass API object that was retrieved from the Kubernetes API.
  71. // ExtractRuntimeClassFrom provides a way to perform a extract/modify-in-place/apply workflow.
  72. // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
  73. // applied if another fieldManager has updated or force applied any of the previously applied fields.
  74. func ExtractRuntimeClassFrom(runtimeClass *nodev1.RuntimeClass, fieldManager string, subresource string) (*RuntimeClassApplyConfiguration, error) {
  75. b := &RuntimeClassApplyConfiguration{}
  76. err := managedfields.ExtractInto(runtimeClass, internal.Parser().Type("io.k8s.api.node.v1.RuntimeClass"), fieldManager, b, subresource)
  77. if err != nil {
  78. return nil, err
  79. }
  80. b.WithName(runtimeClass.Name)
  81. b.WithKind("RuntimeClass")
  82. b.WithAPIVersion("node.k8s.io/v1")
  83. return b, nil
  84. }
  85. // ExtractRuntimeClass extracts the applied configuration owned by fieldManager from
  86. // runtimeClass. If no managedFields are found in runtimeClass for fieldManager, a
  87. // RuntimeClassApplyConfiguration is returned with only the Name, Namespace (if applicable),
  88. // APIVersion and Kind populated. It is possible that no managed fields were found for because other
  89. // field managers have taken ownership of all the fields previously owned by fieldManager, or because
  90. // the fieldManager never owned fields any fields.
  91. // runtimeClass must be a unmodified RuntimeClass API object that was retrieved from the Kubernetes API.
  92. // ExtractRuntimeClass provides a way to perform a extract/modify-in-place/apply workflow.
  93. // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
  94. // applied if another fieldManager has updated or force applied any of the previously applied fields.
  95. func ExtractRuntimeClass(runtimeClass *nodev1.RuntimeClass, fieldManager string) (*RuntimeClassApplyConfiguration, error) {
  96. return ExtractRuntimeClassFrom(runtimeClass, fieldManager, "")
  97. }
  98. func (b RuntimeClassApplyConfiguration) IsApplyConfiguration() {}
  99. // WithKind sets the Kind 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 Kind field is set to the value of the last call.
  102. func (b *RuntimeClassApplyConfiguration) WithKind(value string) *RuntimeClassApplyConfiguration {
  103. b.TypeMetaApplyConfiguration.Kind = &value
  104. return b
  105. }
  106. // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
  107. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  108. // If called multiple times, the APIVersion field is set to the value of the last call.
  109. func (b *RuntimeClassApplyConfiguration) WithAPIVersion(value string) *RuntimeClassApplyConfiguration {
  110. b.TypeMetaApplyConfiguration.APIVersion = &value
  111. return b
  112. }
  113. // WithName sets the Name field in the declarative configuration to the given value
  114. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  115. // If called multiple times, the Name field is set to the value of the last call.
  116. func (b *RuntimeClassApplyConfiguration) WithName(value string) *RuntimeClassApplyConfiguration {
  117. b.ensureObjectMetaApplyConfigurationExists()
  118. b.ObjectMetaApplyConfiguration.Name = &value
  119. return b
  120. }
  121. // WithGenerateName sets the GenerateName field in the declarative configuration to the given value
  122. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  123. // If called multiple times, the GenerateName field is set to the value of the last call.
  124. func (b *RuntimeClassApplyConfiguration) WithGenerateName(value string) *RuntimeClassApplyConfiguration {
  125. b.ensureObjectMetaApplyConfigurationExists()
  126. b.ObjectMetaApplyConfiguration.GenerateName = &value
  127. return b
  128. }
  129. // WithNamespace sets the Namespace field in the declarative configuration to the given value
  130. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  131. // If called multiple times, the Namespace field is set to the value of the last call.
  132. func (b *RuntimeClassApplyConfiguration) WithNamespace(value string) *RuntimeClassApplyConfiguration {
  133. b.ensureObjectMetaApplyConfigurationExists()
  134. b.ObjectMetaApplyConfiguration.Namespace = &value
  135. return b
  136. }
  137. // WithUID sets the UID field in the declarative configuration to the given value
  138. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  139. // If called multiple times, the UID field is set to the value of the last call.
  140. func (b *RuntimeClassApplyConfiguration) WithUID(value types.UID) *RuntimeClassApplyConfiguration {
  141. b.ensureObjectMetaApplyConfigurationExists()
  142. b.ObjectMetaApplyConfiguration.UID = &value
  143. return b
  144. }
  145. // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
  146. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  147. // If called multiple times, the ResourceVersion field is set to the value of the last call.
  148. func (b *RuntimeClassApplyConfiguration) WithResourceVersion(value string) *RuntimeClassApplyConfiguration {
  149. b.ensureObjectMetaApplyConfigurationExists()
  150. b.ObjectMetaApplyConfiguration.ResourceVersion = &value
  151. return b
  152. }
  153. // WithGeneration sets the Generation field in the declarative configuration to the given value
  154. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  155. // If called multiple times, the Generation field is set to the value of the last call.
  156. func (b *RuntimeClassApplyConfiguration) WithGeneration(value int64) *RuntimeClassApplyConfiguration {
  157. b.ensureObjectMetaApplyConfigurationExists()
  158. b.ObjectMetaApplyConfiguration.Generation = &value
  159. return b
  160. }
  161. // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
  162. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  163. // If called multiple times, the CreationTimestamp field is set to the value of the last call.
  164. func (b *RuntimeClassApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *RuntimeClassApplyConfiguration {
  165. b.ensureObjectMetaApplyConfigurationExists()
  166. b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
  167. return b
  168. }
  169. // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
  170. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  171. // If called multiple times, the DeletionTimestamp field is set to the value of the last call.
  172. func (b *RuntimeClassApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *RuntimeClassApplyConfiguration {
  173. b.ensureObjectMetaApplyConfigurationExists()
  174. b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
  175. return b
  176. }
  177. // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
  178. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  179. // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
  180. func (b *RuntimeClassApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *RuntimeClassApplyConfiguration {
  181. b.ensureObjectMetaApplyConfigurationExists()
  182. b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
  183. return b
  184. }
  185. // WithLabels puts the entries into the Labels 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, the entries provided by each call will be put on the Labels field,
  188. // overwriting an existing map entries in Labels field with the same key.
  189. func (b *RuntimeClassApplyConfiguration) WithLabels(entries map[string]string) *RuntimeClassApplyConfiguration {
  190. b.ensureObjectMetaApplyConfigurationExists()
  191. if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
  192. b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
  193. }
  194. for k, v := range entries {
  195. b.ObjectMetaApplyConfiguration.Labels[k] = v
  196. }
  197. return b
  198. }
  199. // WithAnnotations puts the entries into the Annotations field in the declarative configuration
  200. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  201. // If called multiple times, the entries provided by each call will be put on the Annotations field,
  202. // overwriting an existing map entries in Annotations field with the same key.
  203. func (b *RuntimeClassApplyConfiguration) WithAnnotations(entries map[string]string) *RuntimeClassApplyConfiguration {
  204. b.ensureObjectMetaApplyConfigurationExists()
  205. if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
  206. b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
  207. }
  208. for k, v := range entries {
  209. b.ObjectMetaApplyConfiguration.Annotations[k] = v
  210. }
  211. return b
  212. }
  213. // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
  214. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  215. // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
  216. func (b *RuntimeClassApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *RuntimeClassApplyConfiguration {
  217. b.ensureObjectMetaApplyConfigurationExists()
  218. for i := range values {
  219. if values[i] == nil {
  220. panic("nil value passed to WithOwnerReferences")
  221. }
  222. b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
  223. }
  224. return b
  225. }
  226. // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
  227. // and returns the receiver, so that objects can be build by chaining "With" function invocations.
  228. // If called multiple times, values provided by each call will be appended to the Finalizers field.
  229. func (b *RuntimeClassApplyConfiguration) WithFinalizers(values ...string) *RuntimeClassApplyConfiguration {
  230. b.ensureObjectMetaApplyConfigurationExists()
  231. for i := range values {
  232. b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
  233. }
  234. return b
  235. }
  236. func (b *RuntimeClassApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
  237. if b.ObjectMetaApplyConfiguration == nil {
  238. b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{}
  239. }
  240. }
  241. // WithHandler sets the Handler field in the declarative configuration to the given value
  242. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  243. // If called multiple times, the Handler field is set to the value of the last call.
  244. func (b *RuntimeClassApplyConfiguration) WithHandler(value string) *RuntimeClassApplyConfiguration {
  245. b.Handler = &value
  246. return b
  247. }
  248. // WithOverhead sets the Overhead field in the declarative configuration to the given value
  249. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  250. // If called multiple times, the Overhead field is set to the value of the last call.
  251. func (b *RuntimeClassApplyConfiguration) WithOverhead(value *OverheadApplyConfiguration) *RuntimeClassApplyConfiguration {
  252. b.Overhead = value
  253. return b
  254. }
  255. // WithScheduling sets the Scheduling field in the declarative configuration to the given value
  256. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  257. // If called multiple times, the Scheduling field is set to the value of the last call.
  258. func (b *RuntimeClassApplyConfiguration) WithScheduling(value *SchedulingApplyConfiguration) *RuntimeClassApplyConfiguration {
  259. b.Scheduling = value
  260. return b
  261. }
  262. // GetKind retrieves the value of the Kind field in the declarative configuration.
  263. func (b *RuntimeClassApplyConfiguration) GetKind() *string {
  264. return b.TypeMetaApplyConfiguration.Kind
  265. }
  266. // GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
  267. func (b *RuntimeClassApplyConfiguration) GetAPIVersion() *string {
  268. return b.TypeMetaApplyConfiguration.APIVersion
  269. }
  270. // GetName retrieves the value of the Name field in the declarative configuration.
  271. func (b *RuntimeClassApplyConfiguration) GetName() *string {
  272. b.ensureObjectMetaApplyConfigurationExists()
  273. return b.ObjectMetaApplyConfiguration.Name
  274. }
  275. // GetNamespace retrieves the value of the Namespace field in the declarative configuration.
  276. func (b *RuntimeClassApplyConfiguration) GetNamespace() *string {
  277. b.ensureObjectMetaApplyConfigurationExists()
  278. return b.ObjectMetaApplyConfiguration.Namespace
  279. }