runtimeclass.go 14 KB

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