endpointslice.go 13 KB

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