eviction.go 12 KB

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