Debian Codegraph @

applyconfigurations/core/v1/event.go

raw
1 /*
2 Copyright The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 // Code generated by applyconfiguration-gen. DO NOT EDIT.
18
19 package v1
20
21 import (
22 corev1 "k8s.io/api/core/v1"
23 apismetav1 "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 metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
28 )
29
30 // EventApplyConfiguration represents a declarative configuration of the Event type for use
31 // with apply.
32 type EventApplyConfiguration struct {
33 metav1.TypeMetaApplyConfiguration `json:",inline"`
34 *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
35 InvolvedObject *ObjectReferenceApplyConfiguration `json:"involvedObject,omitempty"`
36 Reason *string `json:"reason,omitempty"`
37 Message *string `json:"message,omitempty"`
38 Source *EventSourceApplyConfiguration `json:"source,omitempty"`
39 FirstTimestamp *apismetav1.Time `json:"firstTimestamp,omitempty"`
40 LastTimestamp *apismetav1.Time `json:"lastTimestamp,omitempty"`
41 Count *int32 `json:"count,omitempty"`
42 Type *string `json:"type,omitempty"`
43 EventTime *apismetav1.MicroTime `json:"eventTime,omitempty"`
44 Series *EventSeriesApplyConfiguration `json:"series,omitempty"`
45 Action *string `json:"action,omitempty"`
46 Related *ObjectReferenceApplyConfiguration `json:"related,omitempty"`
47 ReportingController *string `json:"reportingComponent,omitempty"`
48 ReportingInstance *string `json:"reportingInstance,omitempty"`
49 }
50
51 // Event constructs a declarative configuration of the Event type for use with
52 // apply.
53 func Event(name, namespace string) *EventApplyConfiguration {
54 b := &EventApplyConfiguration{}
55 b.WithName(name)
56 b.WithNamespace(namespace)
57 b.WithKind("Event")
58 b.WithAPIVersion("v1")
59 return b
60 }
61
62 // ExtractEvent extracts the applied configuration owned by fieldManager from
63 // event. If no managedFields are found in event for fieldManager, a
64 // EventApplyConfiguration is returned with only the Name, Namespace (if applicable),
65 // APIVersion and Kind populated. It is possible that no managed fields were found for because other
66 // field managers have taken ownership of all the fields previously owned by fieldManager, or because
67 // the fieldManager never owned fields any fields.
68 // event must be a unmodified Event API object that was retrieved from the Kubernetes API.
69 // ExtractEvent provides a way to perform a extract/modify-in-place/apply workflow.
70 // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
71 // applied if another fieldManager has updated or force applied any of the previously applied fields.
72 // Experimental!
73 func ExtractEvent(event *corev1.Event, fieldManager string) (*EventApplyConfiguration, error) {
74 return extractEvent(event, fieldManager, "")
75 }
76
77 // ExtractEventStatus is the same as ExtractEvent except
78 // that it extracts the status subresource applied configuration.
79 // Experimental!
80 func ExtractEventStatus(event *corev1.Event, fieldManager string) (*EventApplyConfiguration, error) {
81 return extractEvent(event, fieldManager, "status")
82 }
83
84 func extractEvent(event *corev1.Event, fieldManager string, subresource string) (*EventApplyConfiguration, error) {
85 b := &EventApplyConfiguration{}
86 err := managedfields.ExtractInto(event, internal.Parser().Type("io.k8s.api.core.v1.Event"), fieldManager, b, subresource)
87 if err != nil {
88 return nil, err
89 }
90 b.WithName(event.Name)
91 b.WithNamespace(event.Namespace)
92
93 b.WithKind("Event")
94 b.WithAPIVersion("v1")
95 return b, nil
96 }
97
98 // WithKind sets the Kind field in the declarative configuration to the given value
99 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
100 // If called multiple times, the Kind field is set to the value of the last call.
101 func (b *EventApplyConfiguration) WithKind(value string) *EventApplyConfiguration {
102 b.TypeMetaApplyConfiguration.Kind = &value
103 return b
104 }
105
106 // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
107 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
108 // If called multiple times, the APIVersion field is set to the value of the last call.
109 func (b *EventApplyConfiguration) WithAPIVersion(value string) *EventApplyConfiguration {
110 b.TypeMetaApplyConfiguration.APIVersion = &value
111 return b
112 }
113
114 // WithName sets the Name field in the declarative configuration to the given value
115 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
116 // If called multiple times, the Name field is set to the value of the last call.
117 func (b *EventApplyConfiguration) WithName(value string) *EventApplyConfiguration {
118 b.ensureObjectMetaApplyConfigurationExists()
119 b.ObjectMetaApplyConfiguration.Name = &value
120 return b
121 }
122
123 // WithGenerateName sets the GenerateName field in the declarative configuration to the given value
124 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
125 // If called multiple times, the GenerateName field is set to the value of the last call.
126 func (b *EventApplyConfiguration) WithGenerateName(value string) *EventApplyConfiguration {
127 b.ensureObjectMetaApplyConfigurationExists()
128 b.ObjectMetaApplyConfiguration.GenerateName = &value
129 return b
130 }
131
132 // WithNamespace sets the Namespace field in the declarative configuration to the given value
133 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
134 // If called multiple times, the Namespace field is set to the value of the last call.
135 func (b *EventApplyConfiguration) WithNamespace(value string) *EventApplyConfiguration {
136 b.ensureObjectMetaApplyConfigurationExists()
137 b.ObjectMetaApplyConfiguration.Namespace = &value
138 return b
139 }
140
141 // WithUID sets the UID field in the declarative configuration to the given value
142 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
143 // If called multiple times, the UID field is set to the value of the last call.
144 func (b *EventApplyConfiguration) WithUID(value types.UID) *EventApplyConfiguration {
145 b.ensureObjectMetaApplyConfigurationExists()
146 b.ObjectMetaApplyConfiguration.UID = &value
147 return b
148 }
149
150 // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
151 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
152 // If called multiple times, the ResourceVersion field is set to the value of the last call.
153 func (b *EventApplyConfiguration) WithResourceVersion(value string) *EventApplyConfiguration {
154 b.ensureObjectMetaApplyConfigurationExists()
155 b.ObjectMetaApplyConfiguration.ResourceVersion = &value
156 return b
157 }
158
159 // WithGeneration sets the Generation field in the declarative configuration to the given value
160 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
161 // If called multiple times, the Generation field is set to the value of the last call.
162 func (b *EventApplyConfiguration) WithGeneration(value int64) *EventApplyConfiguration {
163 b.ensureObjectMetaApplyConfigurationExists()
164 b.ObjectMetaApplyConfiguration.Generation = &value
165 return b
166 }
167
168 // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
169 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
170 // If called multiple times, the CreationTimestamp field is set to the value of the last call.
171 func (b *EventApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *EventApplyConfiguration {
172 b.ensureObjectMetaApplyConfigurationExists()
173 b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
174 return b
175 }
176
177 // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
178 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
179 // If called multiple times, the DeletionTimestamp field is set to the value of the last call.
180 func (b *EventApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *EventApplyConfiguration {
181 b.ensureObjectMetaApplyConfigurationExists()
182 b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
183 return b
184 }
185
186 // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
187 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
188 // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
189 func (b *EventApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *EventApplyConfiguration {
190 b.ensureObjectMetaApplyConfigurationExists()
191 b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
192 return b
193 }
194
195 // WithLabels puts the entries into the Labels field in the declarative configuration
196 // and returns the receiver, so that objects can be build by chaining "With" function invocations.
197 // If called multiple times, the entries provided by each call will be put on the Labels field,
198 // overwriting an existing map entries in Labels field with the same key.
199 func (b *EventApplyConfiguration) WithLabels(entries map[string]string) *EventApplyConfiguration {
200 b.ensureObjectMetaApplyConfigurationExists()
201 if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
202 b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
203 }
204 for k, v := range entries {
205 b.ObjectMetaApplyConfiguration.Labels[k] = v
206 }
207 return b
208 }
209
210 // WithAnnotations puts the entries into the Annotations field in the declarative configuration
211 // and returns the receiver, so that objects can be build by chaining "With" function invocations.
212 // If called multiple times, the entries provided by each call will be put on the Annotations field,
213 // overwriting an existing map entries in Annotations field with the same key.
214 func (b *EventApplyConfiguration) WithAnnotations(entries map[string]string) *EventApplyConfiguration {
215 b.ensureObjectMetaApplyConfigurationExists()
216 if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
217 b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
218 }
219 for k, v := range entries {
220 b.ObjectMetaApplyConfiguration.Annotations[k] = v
221 }
222 return b
223 }
224
225 // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
226 // and returns the receiver, so that objects can be build by chaining "With" function invocations.
227 // If called multiple times, values provided by each call will be appended to the OwnerReferences field.
228 func (b *EventApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *EventApplyConfiguration {
229 b.ensureObjectMetaApplyConfigurationExists()
230 for i := range values {
231 if values[i] == nil {
232 panic("nil value passed to WithOwnerReferences")
233 }
234 b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
235 }
236 return b
237 }
238
239 // WithFinalizers adds the given value to the Finalizers field in the declarative configuration
240 // and returns the receiver, so that objects can be build by chaining "With" function invocations.
241 // If called multiple times, values provided by each call will be appended to the Finalizers field.
242 func (b *EventApplyConfiguration) WithFinalizers(values ...string) *EventApplyConfiguration {
243 b.ensureObjectMetaApplyConfigurationExists()
244 for i := range values {
245 b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
246 }
247 return b
248 }
249
250 func (b *EventApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
251 if b.ObjectMetaApplyConfiguration == nil {
252 b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{}
253 }
254 }
255
256 // WithInvolvedObject sets the InvolvedObject field in the declarative configuration to the given value
257 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
258 // If called multiple times, the InvolvedObject field is set to the value of the last call.
259 func (b *EventApplyConfiguration) WithInvolvedObject(value *ObjectReferenceApplyConfiguration) *EventApplyConfiguration {
260 b.InvolvedObject = value
261 return b
262 }
263
264 // WithReason sets the Reason field in the declarative configuration to the given value
265 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
266 // If called multiple times, the Reason field is set to the value of the last call.
267 func (b *EventApplyConfiguration) WithReason(value string) *EventApplyConfiguration {
268 b.Reason = &value
269 return b
270 }
271
272 // WithMessage sets the Message field in the declarative configuration to the given value
273 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
274 // If called multiple times, the Message field is set to the value of the last call.
275 func (b *EventApplyConfiguration) WithMessage(value string) *EventApplyConfiguration {
276 b.Message = &value
277 return b
278 }
279
280 // WithSource sets the Source field in the declarative configuration to the given value
281 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
282 // If called multiple times, the Source field is set to the value of the last call.
283 func (b *EventApplyConfiguration) WithSource(value *EventSourceApplyConfiguration) *EventApplyConfiguration {
284 b.Source = value
285 return b
286 }
287
288 // WithFirstTimestamp sets the FirstTimestamp field in the declarative configuration to the given value
289 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
290 // If called multiple times, the FirstTimestamp field is set to the value of the last call.
291 func (b *EventApplyConfiguration) WithFirstTimestamp(value apismetav1.Time) *EventApplyConfiguration {
292 b.FirstTimestamp = &value
293 return b
294 }
295
296 // WithLastTimestamp sets the LastTimestamp field in the declarative configuration to the given value
297 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
298 // If called multiple times, the LastTimestamp field is set to the value of the last call.
299 func (b *EventApplyConfiguration) WithLastTimestamp(value apismetav1.Time) *EventApplyConfiguration {
300 b.LastTimestamp = &value
301 return b
302 }
303
304 // WithCount sets the Count field in the declarative configuration to the given value
305 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
306 // If called multiple times, the Count field is set to the value of the last call.
307 func (b *EventApplyConfiguration) WithCount(value int32) *EventApplyConfiguration {
308 b.Count = &value
309 return b
310 }
311
312 // WithType sets the Type field in the declarative configuration to the given value
313 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
314 // If called multiple times, the Type field is set to the value of the last call.
315 func (b *EventApplyConfiguration) WithType(value string) *EventApplyConfiguration {
316 b.Type = &value
317 return b
318 }
319
320 // WithEventTime sets the EventTime field in the declarative configuration to the given value
321 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
322 // If called multiple times, the EventTime field is set to the value of the last call.
323 func (b *EventApplyConfiguration) WithEventTime(value apismetav1.MicroTime) *EventApplyConfiguration {
324 b.EventTime = &value
325 return b
326 }
327
328 // WithSeries sets the Series field in the declarative configuration to the given value
329 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
330 // If called multiple times, the Series field is set to the value of the last call.
331 func (b *EventApplyConfiguration) WithSeries(value *EventSeriesApplyConfiguration) *EventApplyConfiguration {
332 b.Series = value
333 return b
334 }
335
336 // WithAction sets the Action field in the declarative configuration to the given value
337 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
338 // If called multiple times, the Action field is set to the value of the last call.
339 func (b *EventApplyConfiguration) WithAction(value string) *EventApplyConfiguration {
340 b.Action = &value
341 return b
342 }
343
344 // WithRelated sets the Related field in the declarative configuration to the given value
345 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
346 // If called multiple times, the Related field is set to the value of the last call.
347 func (b *EventApplyConfiguration) WithRelated(value *ObjectReferenceApplyConfiguration) *EventApplyConfiguration {
348 b.Related = value
349 return b
350 }
351
352 // WithReportingController sets the ReportingController field in the declarative configuration to the given value
353 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
354 // If called multiple times, the ReportingController field is set to the value of the last call.
355 func (b *EventApplyConfiguration) WithReportingController(value string) *EventApplyConfiguration {
356 b.ReportingController = &value
357 return b
358 }
359
360 // WithReportingInstance sets the ReportingInstance field in the declarative configuration to the given value
361 // and returns the receiver, so that objects can be built by chaining "With" function invocations.
362 // If called multiple times, the ReportingInstance field is set to the value of the last call.
363 func (b *EventApplyConfiguration) WithReportingInstance(value string) *EventApplyConfiguration {
364 b.ReportingInstance = &value
365 return b
366 }
367
368 // GetName retrieves the value of the Name field in the declarative configuration.
369 func (b *EventApplyConfiguration) GetName() *string {
370 b.ensureObjectMetaApplyConfigurationExists()
371 return b.ObjectMetaApplyConfiguration.Name
372 }