1/*
2Copyright The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17// Code generated by applyconfiguration-gen. DO NOT EDIT.
18
19package v1
20
21import (
22	apicorev1 "k8s.io/api/core/v1"
23	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24	types "k8s.io/apimachinery/pkg/types"
25	managedfields "k8s.io/apimachinery/pkg/util/managedfields"
26	internal "k8s.io/client-go/applyconfigurations/internal"
27	v1 "k8s.io/client-go/applyconfigurations/meta/v1"
28)
29
30// EndpointsApplyConfiguration represents an declarative configuration of the Endpoints type for use
31// with apply.
32type EndpointsApplyConfiguration struct {
33	v1.TypeMetaApplyConfiguration    `json:",inline"`
34	*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
35	Subsets                          []EndpointSubsetApplyConfiguration `json:"subsets,omitempty"`
36}
37
38// Endpoints constructs an declarative configuration of the Endpoints type for use with
39// apply.
40func Endpoints(name, namespace string) *EndpointsApplyConfiguration {
41	b := &EndpointsApplyConfiguration{}
42	b.WithName(name)
43	b.WithNamespace(namespace)
44	b.WithKind("Endpoints")
45	b.WithAPIVersion("v1")
46	return b
47}
48
49// ExtractEndpoints extracts the applied configuration owned by fieldManager from
50// endpoints. If no managedFields are found in endpoints for fieldManager, a
51// EndpointsApplyConfiguration is returned with only the Name, Namespace (if applicable),
52// APIVersion and Kind populated. It is possible that no managed fields were found for because other
53// field managers have taken ownership of all the fields previously owned by fieldManager, or because
54// the fieldManager never owned fields any fields.
55// endpoints must be a unmodified Endpoints API object that was retrieved from the Kubernetes API.
56// ExtractEndpoints provides a way to perform a extract/modify-in-place/apply workflow.
57// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
58// applied if another fieldManager has updated or force applied any of the previously applied fields.
59// Experimental!
60func ExtractEndpoints(endpoints *apicorev1.Endpoints, fieldManager string) (*EndpointsApplyConfiguration, error) {
61	return extractEndpoints(endpoints, fieldManager, "")
62}
63
64// ExtractEndpointsStatus is the same as ExtractEndpoints except
65// that it extracts the status subresource applied configuration.
66// Experimental!
67func ExtractEndpointsStatus(endpoints *apicorev1.Endpoints, fieldManager string) (*EndpointsApplyConfiguration, error) {
68	return extractEndpoints(endpoints, fieldManager, "status")
69}
70
71func extractEndpoints(endpoints *apicorev1.Endpoints, fieldManager string, subresource string) (*EndpointsApplyConfiguration, error) {
72	b := &EndpointsApplyConfiguration{}
73	err := managedfields.ExtractInto(endpoints, internal.Parser().Type("io.k8s.api.core.v1.Endpoints"), fieldManager, b, subresource)
74	if err != nil {
75		return nil, err
76	}
77	b.WithName(endpoints.Name)
78	b.WithNamespace(endpoints.Namespace)
79
80	b.WithKind("Endpoints")
81	b.WithAPIVersion("v1")
82	return b, nil
83}
84
85// WithKind sets the Kind field in the declarative configuration to the given value
86// and returns the receiver, so that objects can be built by chaining "With" function invocations.
87// If called multiple times, the Kind field is set to the value of the last call.
88func (b *EndpointsApplyConfiguration) WithKind(value string) *EndpointsApplyConfiguration {
89	b.Kind = &value
90	return b
91}
92
93// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
94// and returns the receiver, so that objects can be built by chaining "With" function invocations.
95// If called multiple times, the APIVersion field is set to the value of the last call.
96func (b *EndpointsApplyConfiguration) WithAPIVersion(value string) *EndpointsApplyConfiguration {
97	b.APIVersion = &value
98	return b
99}
100
101// WithName sets the Name field in the declarative configuration to the given value
102// and returns the receiver, so that objects can be built by chaining "With" function invocations.
103// If called multiple times, the Name field is set to the value of the last call.
104func (b *EndpointsApplyConfiguration) WithName(value string) *EndpointsApplyConfiguration {
105	b.ensureObjectMetaApplyConfigurationExists()
106	b.Name = &value
107	return b
108}
109
110// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
113func (b *EndpointsApplyConfiguration) WithGenerateName(value string) *EndpointsApplyConfiguration {
114	b.ensureObjectMetaApplyConfigurationExists()
115	b.GenerateName = &value
116	return b
117}
118
119// WithNamespace sets the Namespace field in the declarative configuration to the given value
120// and returns the receiver, so that objects can be built by chaining "With" function invocations.
121// If called multiple times, the Namespace field is set to the value of the last call.
122func (b *EndpointsApplyConfiguration) WithNamespace(value string) *EndpointsApplyConfiguration {
123	b.ensureObjectMetaApplyConfigurationExists()
124	b.Namespace = &value
125	return b
126}
127
128// WithSelfLink sets the SelfLink 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 SelfLink field is set to the value of the last call.
131func (b *EndpointsApplyConfiguration) WithSelfLink(value string) *EndpointsApplyConfiguration {
132	b.ensureObjectMetaApplyConfigurationExists()
133	b.SelfLink = &value
134	return b
135}
136
137// WithUID sets the UID field in the declarative configuration to the given value
138// and returns the receiver, so that objects can be built by chaining "With" function invocations.
139// If called multiple times, the UID field is set to the value of the last call.
140func (b *EndpointsApplyConfiguration) WithUID(value types.UID) *EndpointsApplyConfiguration {
141	b.ensureObjectMetaApplyConfigurationExists()
142	b.UID = &value
143	return b
144}
145
146// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
147// and returns the receiver, so that objects can be built by chaining "With" function invocations.
148// If called multiple times, the ResourceVersion field is set to the value of the last call.
149func (b *EndpointsApplyConfiguration) WithResourceVersion(value string) *EndpointsApplyConfiguration {
150	b.ensureObjectMetaApplyConfigurationExists()
151	b.ResourceVersion = &value
152	return b
153}
154
155// WithGeneration sets the Generation field in the declarative configuration to the given value
156// and returns the receiver, so that objects can be built by chaining "With" function invocations.
157// If called multiple times, the Generation field is set to the value of the last call.
158func (b *EndpointsApplyConfiguration) WithGeneration(value int64) *EndpointsApplyConfiguration {
159	b.ensureObjectMetaApplyConfigurationExists()
160	b.Generation = &value
161	return b
162}
163
164// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
165// and returns the receiver, so that objects can be built by chaining "With" function invocations.
166// If called multiple times, the CreationTimestamp field is set to the value of the last call.
167func (b *EndpointsApplyConfiguration) WithCreationTimestamp(value metav1.Time) *EndpointsApplyConfiguration {
168	b.ensureObjectMetaApplyConfigurationExists()
169	b.CreationTimestamp = &value
170	return b
171}
172
173// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
174// and returns the receiver, so that objects can be built by chaining "With" function invocations.
175// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
176func (b *EndpointsApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *EndpointsApplyConfiguration {
177	b.ensureObjectMetaApplyConfigurationExists()
178	b.DeletionTimestamp = &value
179	return b
180}
181
182// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
183// and returns the receiver, so that objects can be built by chaining "With" function invocations.
184// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
185func (b *EndpointsApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *EndpointsApplyConfiguration {
186	b.ensureObjectMetaApplyConfigurationExists()
187	b.DeletionGracePeriodSeconds = &value
188	return b
189}
190
191// WithLabels puts the entries into the Labels field in the declarative configuration
192// and returns the receiver, so that objects can be build by chaining "With" function invocations.
193// If called multiple times, the entries provided by each call will be put on the Labels field,
194// overwriting an existing map entries in Labels field with the same key.
195func (b *EndpointsApplyConfiguration) WithLabels(entries map[string]string) *EndpointsApplyConfiguration {
196	b.ensureObjectMetaApplyConfigurationExists()
197	if b.Labels == nil && len(entries) > 0 {
198		b.Labels = make(map[string]string, len(entries))
199	}
200	for k, v := range entries {
201		b.Labels[k] = v
202	}
203	return b
204}
205
206// WithAnnotations puts the entries into the Annotations field in the declarative configuration
207// and returns the receiver, so that objects can be build by chaining "With" function invocations.
208// If called multiple times, the entries provided by each call will be put on the Annotations field,
209// overwriting an existing map entries in Annotations field with the same key.
210func (b *EndpointsApplyConfiguration) WithAnnotations(entries map[string]string) *EndpointsApplyConfiguration {
211	b.ensureObjectMetaApplyConfigurationExists()
212	if b.Annotations == nil && len(entries) > 0 {
213		b.Annotations = make(map[string]string, len(entries))
214	}
215	for k, v := range entries {
216		b.Annotations[k] = v
217	}
218	return b
219}
220
221// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
222// and returns the receiver, so that objects can be build by chaining "With" function invocations.
223// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
224func (b *EndpointsApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *EndpointsApplyConfiguration {
225	b.ensureObjectMetaApplyConfigurationExists()
226	for i := range values {
227		if values[i] == nil {
228			panic("nil value passed to WithOwnerReferences")
229		}
230		b.OwnerReferences = append(b.OwnerReferences, *values[i])
231	}
232	return b
233}
234
235// WithFinalizers adds the given value to the Finalizers 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 Finalizers field.
238func (b *EndpointsApplyConfiguration) WithFinalizers(values ...string) *EndpointsApplyConfiguration {
239	b.ensureObjectMetaApplyConfigurationExists()
240	for i := range values {
241		b.Finalizers = append(b.Finalizers, values[i])
242	}
243	return b
244}
245
246// WithClusterName sets the ClusterName field in the declarative configuration to the given value
247// and returns the receiver, so that objects can be built by chaining "With" function invocations.
248// If called multiple times, the ClusterName field is set to the value of the last call.
249func (b *EndpointsApplyConfiguration) WithClusterName(value string) *EndpointsApplyConfiguration {
250	b.ensureObjectMetaApplyConfigurationExists()
251	b.ClusterName = &value
252	return b
253}
254
255func (b *EndpointsApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
256	if b.ObjectMetaApplyConfiguration == nil {
257		b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
258	}
259}
260
261// WithSubsets adds the given value to the Subsets field in the declarative configuration
262// and returns the receiver, so that objects can be build by chaining "With" function invocations.
263// If called multiple times, values provided by each call will be appended to the Subsets field.
264func (b *EndpointsApplyConfiguration) WithSubsets(values ...*EndpointSubsetApplyConfiguration) *EndpointsApplyConfiguration {
265	for i := range values {
266		if values[i] == nil {
267			panic("nil value passed to WithSubsets")
268		}
269		b.Subsets = append(b.Subsets, *values[i])
270	}
271	return b
272}
273