deployment.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 v1beta2
  15. import (
  16. appsv1beta2 "k8s.io/api/apps/v1beta2"
  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. // DeploymentApplyConfiguration represents an declarative configuration of the Deployment type for use
  24. // with apply.
  25. type DeploymentApplyConfiguration struct {
  26. v1.TypeMetaApplyConfiguration `json:",inline"`
  27. *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
  28. Spec *DeploymentSpecApplyConfiguration `json:"spec,omitempty"`
  29. Status *DeploymentStatusApplyConfiguration `json:"status,omitempty"`
  30. }
  31. // Deployment constructs an declarative configuration of the Deployment type for use with
  32. // apply.
  33. func Deployment(name, namespace string) *DeploymentApplyConfiguration {
  34. b := &DeploymentApplyConfiguration{}
  35. b.WithName(name)
  36. b.WithNamespace(namespace)
  37. b.WithKind("Deployment")
  38. b.WithAPIVersion("apps/v1beta2")
  39. return b
  40. }
  41. // ExtractDeployment extracts the applied configuration owned by fieldManager from
  42. // deployment. If no managedFields are found in deployment for fieldManager, a
  43. // DeploymentApplyConfiguration 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. // deployment must be a unmodified Deployment API object that was retrieved from the Kubernetes API.
  48. // ExtractDeployment 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 ExtractDeployment(deployment *appsv1beta2.Deployment, fieldManager string) (*DeploymentApplyConfiguration, error) {
  53. b := &DeploymentApplyConfiguration{}
  54. err := managedfields.ExtractInto(deployment, internal.Parser().Type("io.k8s.api.apps.v1beta2.Deployment"), fieldManager, b)
  55. if err != nil {
  56. return nil, err
  57. }
  58. b.WithName(deployment.Name)
  59. b.WithNamespace(deployment.Namespace)
  60. b.WithKind("Deployment")
  61. b.WithAPIVersion("apps/v1beta2")
  62. return b, nil
  63. }
  64. // WithKind sets the Kind field in the declarative configuration to the given value
  65. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  66. // If called multiple times, the Kind field is set to the value of the last call.
  67. func (b *DeploymentApplyConfiguration) WithKind(value string) *DeploymentApplyConfiguration {
  68. b.Kind = &value
  69. return b
  70. }
  71. // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
  72. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  73. // If called multiple times, the APIVersion field is set to the value of the last call.
  74. func (b *DeploymentApplyConfiguration) WithAPIVersion(value string) *DeploymentApplyConfiguration {
  75. b.APIVersion = &value
  76. return b
  77. }
  78. // WithName sets the Name field in the declarative configuration to the given value
  79. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  80. // If called multiple times, the Name field is set to the value of the last call.
  81. func (b *DeploymentApplyConfiguration) WithName(value string) *DeploymentApplyConfiguration {
  82. b.ensureObjectMetaApplyConfigurationExists()
  83. b.Name = &value
  84. return b
  85. }
  86. // WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
  89. func (b *DeploymentApplyConfiguration) WithGenerateName(value string) *DeploymentApplyConfiguration {
  90. b.ensureObjectMetaApplyConfigurationExists()
  91. b.GenerateName = &value
  92. return b
  93. }
  94. // WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
  97. func (b *DeploymentApplyConfiguration) WithNamespace(value string) *DeploymentApplyConfiguration {
  98. b.ensureObjectMetaApplyConfigurationExists()
  99. b.Namespace = &value
  100. return b
  101. }
  102. // WithSelfLink sets the SelfLink 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 SelfLink field is set to the value of the last call.
  105. func (b *DeploymentApplyConfiguration) WithSelfLink(value string) *DeploymentApplyConfiguration {
  106. b.ensureObjectMetaApplyConfigurationExists()
  107. b.SelfLink = &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 *DeploymentApplyConfiguration) WithUID(value types.UID) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithResourceVersion(value string) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithGeneration(value int64) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithCreationTimestamp(value metav1.Time) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithLabels(entries map[string]string) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithAnnotations(entries map[string]string) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *DeploymentApplyConfiguration {
  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 *DeploymentApplyConfiguration) WithFinalizers(values ...string) *DeploymentApplyConfiguration {
  203. b.ensureObjectMetaApplyConfigurationExists()
  204. for i := range values {
  205. b.Finalizers = append(b.Finalizers, values[i])
  206. }
  207. return b
  208. }
  209. // WithClusterName sets the ClusterName field in the declarative configuration to the given value
  210. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  211. // If called multiple times, the ClusterName field is set to the value of the last call.
  212. func (b *DeploymentApplyConfiguration) WithClusterName(value string) *DeploymentApplyConfiguration {
  213. b.ensureObjectMetaApplyConfigurationExists()
  214. b.ClusterName = &value
  215. return b
  216. }
  217. func (b *DeploymentApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
  218. if b.ObjectMetaApplyConfiguration == nil {
  219. b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
  220. }
  221. }
  222. // WithSpec sets the Spec field in the declarative configuration to the given value
  223. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  224. // If called multiple times, the Spec field is set to the value of the last call.
  225. func (b *DeploymentApplyConfiguration) WithSpec(value *DeploymentSpecApplyConfiguration) *DeploymentApplyConfiguration {
  226. b.Spec = value
  227. return b
  228. }
  229. // WithStatus sets the Status field in the declarative configuration to the given value
  230. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
  231. // If called multiple times, the Status field is set to the value of the last call.
  232. func (b *DeploymentApplyConfiguration) WithStatus(value *DeploymentStatusApplyConfiguration) *DeploymentApplyConfiguration {
  233. b.Status = value
  234. return b
  235. }