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