validatingwebhookconfiguration.go 13 KB

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