k8s.io/client-go@v0.22.2/applyconfigurations/events/v1/event.go (about) 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 apieventsv1 "k8s.io/api/events/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 corev1 "k8s.io/client-go/applyconfigurations/core/v1" 27 internal "k8s.io/client-go/applyconfigurations/internal" 28 v1 "k8s.io/client-go/applyconfigurations/meta/v1" 29 ) 30 31 // EventApplyConfiguration represents an declarative configuration of the Event type for use 32 // with apply. 33 type EventApplyConfiguration struct { 34 v1.TypeMetaApplyConfiguration `json:",inline"` 35 *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` 36 EventTime *metav1.MicroTime `json:"eventTime,omitempty"` 37 Series *EventSeriesApplyConfiguration `json:"series,omitempty"` 38 ReportingController *string `json:"reportingController,omitempty"` 39 ReportingInstance *string `json:"reportingInstance,omitempty"` 40 Action *string `json:"action,omitempty"` 41 Reason *string `json:"reason,omitempty"` 42 Regarding *corev1.ObjectReferenceApplyConfiguration `json:"regarding,omitempty"` 43 Related *corev1.ObjectReferenceApplyConfiguration `json:"related,omitempty"` 44 Note *string `json:"note,omitempty"` 45 Type *string `json:"type,omitempty"` 46 DeprecatedSource *corev1.EventSourceApplyConfiguration `json:"deprecatedSource,omitempty"` 47 DeprecatedFirstTimestamp *metav1.Time `json:"deprecatedFirstTimestamp,omitempty"` 48 DeprecatedLastTimestamp *metav1.Time `json:"deprecatedLastTimestamp,omitempty"` 49 DeprecatedCount *int32 `json:"deprecatedCount,omitempty"` 50 } 51 52 // Event constructs an declarative configuration of the Event type for use with 53 // apply. 54 func Event(name, namespace string) *EventApplyConfiguration { 55 b := &EventApplyConfiguration{} 56 b.WithName(name) 57 b.WithNamespace(namespace) 58 b.WithKind("Event") 59 b.WithAPIVersion("events.k8s.io/v1") 60 return b 61 } 62 63 // ExtractEvent extracts the applied configuration owned by fieldManager from 64 // event. If no managedFields are found in event for fieldManager, a 65 // EventApplyConfiguration is returned with only the Name, Namespace (if applicable), 66 // APIVersion and Kind populated. It is possible that no managed fields were found for because other 67 // field managers have taken ownership of all the fields previously owned by fieldManager, or because 68 // the fieldManager never owned fields any fields. 69 // event must be a unmodified Event API object that was retrieved from the Kubernetes API. 70 // ExtractEvent provides a way to perform a extract/modify-in-place/apply workflow. 71 // Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously 72 // applied if another fieldManager has updated or force applied any of the previously applied fields. 73 // Experimental! 74 func ExtractEvent(event *apieventsv1.Event, fieldManager string) (*EventApplyConfiguration, error) { 75 return extractEvent(event, fieldManager, "") 76 } 77 78 // ExtractEventStatus is the same as ExtractEvent except 79 // that it extracts the status subresource applied configuration. 80 // Experimental! 81 func ExtractEventStatus(event *apieventsv1.Event, fieldManager string) (*EventApplyConfiguration, error) { 82 return extractEvent(event, fieldManager, "status") 83 } 84 85 func extractEvent(event *apieventsv1.Event, fieldManager string, subresource string) (*EventApplyConfiguration, error) { 86 b := &EventApplyConfiguration{} 87 err := managedfields.ExtractInto(event, internal.Parser().Type("io.k8s.api.events.v1.Event"), fieldManager, b, subresource) 88 if err != nil { 89 return nil, err 90 } 91 b.WithName(event.Name) 92 b.WithNamespace(event.Namespace) 93 94 b.WithKind("Event") 95 b.WithAPIVersion("events.k8s.io/v1") 96 return b, nil 97 } 98 99 // WithKind sets the Kind field in the declarative configuration to the given value 100 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 101 // If called multiple times, the Kind field is set to the value of the last call. 102 func (b *EventApplyConfiguration) WithKind(value string) *EventApplyConfiguration { 103 b.Kind = &value 104 return b 105 } 106 107 // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value 108 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 109 // If called multiple times, the APIVersion field is set to the value of the last call. 110 func (b *EventApplyConfiguration) WithAPIVersion(value string) *EventApplyConfiguration { 111 b.APIVersion = &value 112 return b 113 } 114 115 // WithName sets the Name field in the declarative configuration to the given value 116 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 117 // If called multiple times, the Name field is set to the value of the last call. 118 func (b *EventApplyConfiguration) WithName(value string) *EventApplyConfiguration { 119 b.ensureObjectMetaApplyConfigurationExists() 120 b.Name = &value 121 return b 122 } 123 124 // WithGenerateName sets the GenerateName field in the declarative configuration to the given value 125 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 126 // If called multiple times, the GenerateName field is set to the value of the last call. 127 func (b *EventApplyConfiguration) WithGenerateName(value string) *EventApplyConfiguration { 128 b.ensureObjectMetaApplyConfigurationExists() 129 b.GenerateName = &value 130 return b 131 } 132 133 // WithNamespace sets the Namespace field in the declarative configuration to the given value 134 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 135 // If called multiple times, the Namespace field is set to the value of the last call. 136 func (b *EventApplyConfiguration) WithNamespace(value string) *EventApplyConfiguration { 137 b.ensureObjectMetaApplyConfigurationExists() 138 b.Namespace = &value 139 return b 140 } 141 142 // WithSelfLink sets the SelfLink field in the declarative configuration to the given value 143 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 144 // If called multiple times, the SelfLink field is set to the value of the last call. 145 func (b *EventApplyConfiguration) WithSelfLink(value string) *EventApplyConfiguration { 146 b.ensureObjectMetaApplyConfigurationExists() 147 b.SelfLink = &value 148 return b 149 } 150 151 // WithUID sets the UID field in the declarative configuration to the given value 152 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 153 // If called multiple times, the UID field is set to the value of the last call. 154 func (b *EventApplyConfiguration) WithUID(value types.UID) *EventApplyConfiguration { 155 b.ensureObjectMetaApplyConfigurationExists() 156 b.UID = &value 157 return b 158 } 159 160 // WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value 161 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 162 // If called multiple times, the ResourceVersion field is set to the value of the last call. 163 func (b *EventApplyConfiguration) WithResourceVersion(value string) *EventApplyConfiguration { 164 b.ensureObjectMetaApplyConfigurationExists() 165 b.ResourceVersion = &value 166 return b 167 } 168 169 // WithGeneration sets the Generation field in the declarative configuration to the given value 170 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 171 // If called multiple times, the Generation field is set to the value of the last call. 172 func (b *EventApplyConfiguration) WithGeneration(value int64) *EventApplyConfiguration { 173 b.ensureObjectMetaApplyConfigurationExists() 174 b.Generation = &value 175 return b 176 } 177 178 // WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value 179 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 180 // If called multiple times, the CreationTimestamp field is set to the value of the last call. 181 func (b *EventApplyConfiguration) WithCreationTimestamp(value metav1.Time) *EventApplyConfiguration { 182 b.ensureObjectMetaApplyConfigurationExists() 183 b.CreationTimestamp = &value 184 return b 185 } 186 187 // WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value 188 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 189 // If called multiple times, the DeletionTimestamp field is set to the value of the last call. 190 func (b *EventApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *EventApplyConfiguration { 191 b.ensureObjectMetaApplyConfigurationExists() 192 b.DeletionTimestamp = &value 193 return b 194 } 195 196 // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 197 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 198 // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 199 func (b *EventApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *EventApplyConfiguration { 200 b.ensureObjectMetaApplyConfigurationExists() 201 b.DeletionGracePeriodSeconds = &value 202 return b 203 } 204 205 // WithLabels puts the entries into the Labels field in the declarative configuration 206 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 207 // If called multiple times, the entries provided by each call will be put on the Labels field, 208 // overwriting an existing map entries in Labels field with the same key. 209 func (b *EventApplyConfiguration) WithLabels(entries map[string]string) *EventApplyConfiguration { 210 b.ensureObjectMetaApplyConfigurationExists() 211 if b.Labels == nil && len(entries) > 0 { 212 b.Labels = make(map[string]string, len(entries)) 213 } 214 for k, v := range entries { 215 b.Labels[k] = v 216 } 217 return b 218 } 219 220 // WithAnnotations puts the entries into the Annotations field in the declarative configuration 221 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 222 // If called multiple times, the entries provided by each call will be put on the Annotations field, 223 // overwriting an existing map entries in Annotations field with the same key. 224 func (b *EventApplyConfiguration) WithAnnotations(entries map[string]string) *EventApplyConfiguration { 225 b.ensureObjectMetaApplyConfigurationExists() 226 if b.Annotations == nil && len(entries) > 0 { 227 b.Annotations = make(map[string]string, len(entries)) 228 } 229 for k, v := range entries { 230 b.Annotations[k] = v 231 } 232 return b 233 } 234 235 // WithOwnerReferences adds the given value to the OwnerReferences 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 OwnerReferences field. 238 func (b *EventApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *EventApplyConfiguration { 239 b.ensureObjectMetaApplyConfigurationExists() 240 for i := range values { 241 if values[i] == nil { 242 panic("nil value passed to WithOwnerReferences") 243 } 244 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 245 } 246 return b 247 } 248 249 // WithFinalizers adds the given value to the Finalizers field in the declarative configuration 250 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 251 // If called multiple times, values provided by each call will be appended to the Finalizers field. 252 func (b *EventApplyConfiguration) WithFinalizers(values ...string) *EventApplyConfiguration { 253 b.ensureObjectMetaApplyConfigurationExists() 254 for i := range values { 255 b.Finalizers = append(b.Finalizers, values[i]) 256 } 257 return b 258 } 259 260 // WithClusterName sets the ClusterName 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 ClusterName field is set to the value of the last call. 263 func (b *EventApplyConfiguration) WithClusterName(value string) *EventApplyConfiguration { 264 b.ensureObjectMetaApplyConfigurationExists() 265 b.ClusterName = &value 266 return b 267 } 268 269 func (b *EventApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 270 if b.ObjectMetaApplyConfiguration == nil { 271 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 272 } 273 } 274 275 // WithEventTime sets the EventTime field in the declarative configuration to the given value 276 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 277 // If called multiple times, the EventTime field is set to the value of the last call. 278 func (b *EventApplyConfiguration) WithEventTime(value metav1.MicroTime) *EventApplyConfiguration { 279 b.EventTime = &value 280 return b 281 } 282 283 // WithSeries sets the Series field in the declarative configuration to the given value 284 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 285 // If called multiple times, the Series field is set to the value of the last call. 286 func (b *EventApplyConfiguration) WithSeries(value *EventSeriesApplyConfiguration) *EventApplyConfiguration { 287 b.Series = value 288 return b 289 } 290 291 // WithReportingController sets the ReportingController field in the declarative configuration to the given value 292 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 293 // If called multiple times, the ReportingController field is set to the value of the last call. 294 func (b *EventApplyConfiguration) WithReportingController(value string) *EventApplyConfiguration { 295 b.ReportingController = &value 296 return b 297 } 298 299 // WithReportingInstance sets the ReportingInstance field in the declarative configuration to the given value 300 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 301 // If called multiple times, the ReportingInstance field is set to the value of the last call. 302 func (b *EventApplyConfiguration) WithReportingInstance(value string) *EventApplyConfiguration { 303 b.ReportingInstance = &value 304 return b 305 } 306 307 // WithAction sets the Action field in the declarative configuration to the given value 308 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 309 // If called multiple times, the Action field is set to the value of the last call. 310 func (b *EventApplyConfiguration) WithAction(value string) *EventApplyConfiguration { 311 b.Action = &value 312 return b 313 } 314 315 // WithReason sets the Reason field in the declarative configuration to the given value 316 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 317 // If called multiple times, the Reason field is set to the value of the last call. 318 func (b *EventApplyConfiguration) WithReason(value string) *EventApplyConfiguration { 319 b.Reason = &value 320 return b 321 } 322 323 // WithRegarding sets the Regarding field in the declarative configuration to the given value 324 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 325 // If called multiple times, the Regarding field is set to the value of the last call. 326 func (b *EventApplyConfiguration) WithRegarding(value *corev1.ObjectReferenceApplyConfiguration) *EventApplyConfiguration { 327 b.Regarding = value 328 return b 329 } 330 331 // WithRelated sets the Related field in the declarative configuration to the given value 332 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 333 // If called multiple times, the Related field is set to the value of the last call. 334 func (b *EventApplyConfiguration) WithRelated(value *corev1.ObjectReferenceApplyConfiguration) *EventApplyConfiguration { 335 b.Related = value 336 return b 337 } 338 339 // WithNote sets the Note field in the declarative configuration to the given value 340 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 341 // If called multiple times, the Note field is set to the value of the last call. 342 func (b *EventApplyConfiguration) WithNote(value string) *EventApplyConfiguration { 343 b.Note = &value 344 return b 345 } 346 347 // WithType sets the Type field in the declarative configuration to the given value 348 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 349 // If called multiple times, the Type field is set to the value of the last call. 350 func (b *EventApplyConfiguration) WithType(value string) *EventApplyConfiguration { 351 b.Type = &value 352 return b 353 } 354 355 // WithDeprecatedSource sets the DeprecatedSource field in the declarative configuration to the given value 356 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 357 // If called multiple times, the DeprecatedSource field is set to the value of the last call. 358 func (b *EventApplyConfiguration) WithDeprecatedSource(value *corev1.EventSourceApplyConfiguration) *EventApplyConfiguration { 359 b.DeprecatedSource = value 360 return b 361 } 362 363 // WithDeprecatedFirstTimestamp sets the DeprecatedFirstTimestamp field in the declarative configuration to the given value 364 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 365 // If called multiple times, the DeprecatedFirstTimestamp field is set to the value of the last call. 366 func (b *EventApplyConfiguration) WithDeprecatedFirstTimestamp(value metav1.Time) *EventApplyConfiguration { 367 b.DeprecatedFirstTimestamp = &value 368 return b 369 } 370 371 // WithDeprecatedLastTimestamp sets the DeprecatedLastTimestamp field in the declarative configuration to the given value 372 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 373 // If called multiple times, the DeprecatedLastTimestamp field is set to the value of the last call. 374 func (b *EventApplyConfiguration) WithDeprecatedLastTimestamp(value metav1.Time) *EventApplyConfiguration { 375 b.DeprecatedLastTimestamp = &value 376 return b 377 } 378 379 // WithDeprecatedCount sets the DeprecatedCount field in the declarative configuration to the given value 380 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 381 // If called multiple times, the DeprecatedCount field is set to the value of the last call. 382 func (b *EventApplyConfiguration) WithDeprecatedCount(value int32) *EventApplyConfiguration { 383 b.DeprecatedCount = &value 384 return b 385 }