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