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