k8s.io/client-go@v0.22.2/applyconfigurations/core/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 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 // EventApplyConfiguration represents an declarative configuration of the Event type for use 31 // with apply. 32 type EventApplyConfiguration struct { 33 v1.TypeMetaApplyConfiguration `json:",inline"` 34 *v1.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 *metav1.Time `json:"firstTimestamp,omitempty"` 40 LastTimestamp *metav1.Time `json:"lastTimestamp,omitempty"` 41 Count *int32 `json:"count,omitempty"` 42 Type *string `json:"type,omitempty"` 43 EventTime *metav1.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 an 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 *apicorev1.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 *apicorev1.Event, fieldManager string) (*EventApplyConfiguration, error) { 81 return extractEvent(event, fieldManager, "status") 82 } 83 84 func extractEvent(event *apicorev1.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.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.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.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.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.Namespace = &value 138 return b 139 } 140 141 // WithSelfLink sets the SelfLink 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 SelfLink field is set to the value of the last call. 144 func (b *EventApplyConfiguration) WithSelfLink(value string) *EventApplyConfiguration { 145 b.ensureObjectMetaApplyConfigurationExists() 146 b.SelfLink = &value 147 return b 148 } 149 150 // WithUID sets the UID 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 UID field is set to the value of the last call. 153 func (b *EventApplyConfiguration) WithUID(value types.UID) *EventApplyConfiguration { 154 b.ensureObjectMetaApplyConfigurationExists() 155 b.UID = &value 156 return b 157 } 158 159 // WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call. 162 func (b *EventApplyConfiguration) WithResourceVersion(value string) *EventApplyConfiguration { 163 b.ensureObjectMetaApplyConfigurationExists() 164 b.ResourceVersion = &value 165 return b 166 } 167 168 // WithGeneration sets the Generation 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 Generation field is set to the value of the last call. 171 func (b *EventApplyConfiguration) WithGeneration(value int64) *EventApplyConfiguration { 172 b.ensureObjectMetaApplyConfigurationExists() 173 b.Generation = &value 174 return b 175 } 176 177 // WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call. 180 func (b *EventApplyConfiguration) WithCreationTimestamp(value metav1.Time) *EventApplyConfiguration { 181 b.ensureObjectMetaApplyConfigurationExists() 182 b.CreationTimestamp = &value 183 return b 184 } 185 186 // WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call. 189 func (b *EventApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *EventApplyConfiguration { 190 b.ensureObjectMetaApplyConfigurationExists() 191 b.DeletionTimestamp = &value 192 return b 193 } 194 195 // WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value 196 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 197 // If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. 198 func (b *EventApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *EventApplyConfiguration { 199 b.ensureObjectMetaApplyConfigurationExists() 200 b.DeletionGracePeriodSeconds = &value 201 return b 202 } 203 204 // WithLabels puts the entries into the Labels field in the declarative configuration 205 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 206 // If called multiple times, the entries provided by each call will be put on the Labels field, 207 // overwriting an existing map entries in Labels field with the same key. 208 func (b *EventApplyConfiguration) WithLabels(entries map[string]string) *EventApplyConfiguration { 209 b.ensureObjectMetaApplyConfigurationExists() 210 if b.Labels == nil && len(entries) > 0 { 211 b.Labels = make(map[string]string, len(entries)) 212 } 213 for k, v := range entries { 214 b.Labels[k] = v 215 } 216 return b 217 } 218 219 // WithAnnotations puts the entries into the Annotations field in the declarative configuration 220 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 221 // If called multiple times, the entries provided by each call will be put on the Annotations field, 222 // overwriting an existing map entries in Annotations field with the same key. 223 func (b *EventApplyConfiguration) WithAnnotations(entries map[string]string) *EventApplyConfiguration { 224 b.ensureObjectMetaApplyConfigurationExists() 225 if b.Annotations == nil && len(entries) > 0 { 226 b.Annotations = make(map[string]string, len(entries)) 227 } 228 for k, v := range entries { 229 b.Annotations[k] = v 230 } 231 return b 232 } 233 234 // WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration 235 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 236 // If called multiple times, values provided by each call will be appended to the OwnerReferences field. 237 func (b *EventApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *EventApplyConfiguration { 238 b.ensureObjectMetaApplyConfigurationExists() 239 for i := range values { 240 if values[i] == nil { 241 panic("nil value passed to WithOwnerReferences") 242 } 243 b.OwnerReferences = append(b.OwnerReferences, *values[i]) 244 } 245 return b 246 } 247 248 // WithFinalizers adds the given value to the Finalizers field in the declarative configuration 249 // and returns the receiver, so that objects can be build by chaining "With" function invocations. 250 // If called multiple times, values provided by each call will be appended to the Finalizers field. 251 func (b *EventApplyConfiguration) WithFinalizers(values ...string) *EventApplyConfiguration { 252 b.ensureObjectMetaApplyConfigurationExists() 253 for i := range values { 254 b.Finalizers = append(b.Finalizers, values[i]) 255 } 256 return b 257 } 258 259 // WithClusterName sets the ClusterName field in the declarative configuration to the given value 260 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 261 // If called multiple times, the ClusterName field is set to the value of the last call. 262 func (b *EventApplyConfiguration) WithClusterName(value string) *EventApplyConfiguration { 263 b.ensureObjectMetaApplyConfigurationExists() 264 b.ClusterName = &value 265 return b 266 } 267 268 func (b *EventApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { 269 if b.ObjectMetaApplyConfiguration == nil { 270 b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} 271 } 272 } 273 274 // WithInvolvedObject sets the InvolvedObject field in the declarative configuration to the given value 275 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 276 // If called multiple times, the InvolvedObject field is set to the value of the last call. 277 func (b *EventApplyConfiguration) WithInvolvedObject(value *ObjectReferenceApplyConfiguration) *EventApplyConfiguration { 278 b.InvolvedObject = value 279 return b 280 } 281 282 // WithReason sets the Reason field in the declarative configuration to the given value 283 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 284 // If called multiple times, the Reason field is set to the value of the last call. 285 func (b *EventApplyConfiguration) WithReason(value string) *EventApplyConfiguration { 286 b.Reason = &value 287 return b 288 } 289 290 // WithMessage sets the Message field in the declarative configuration to the given value 291 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 292 // If called multiple times, the Message field is set to the value of the last call. 293 func (b *EventApplyConfiguration) WithMessage(value string) *EventApplyConfiguration { 294 b.Message = &value 295 return b 296 } 297 298 // WithSource sets the Source field in the declarative configuration to the given value 299 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 300 // If called multiple times, the Source field is set to the value of the last call. 301 func (b *EventApplyConfiguration) WithSource(value *EventSourceApplyConfiguration) *EventApplyConfiguration { 302 b.Source = value 303 return b 304 } 305 306 // WithFirstTimestamp sets the FirstTimestamp field in the declarative configuration to the given value 307 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 308 // If called multiple times, the FirstTimestamp field is set to the value of the last call. 309 func (b *EventApplyConfiguration) WithFirstTimestamp(value metav1.Time) *EventApplyConfiguration { 310 b.FirstTimestamp = &value 311 return b 312 } 313 314 // WithLastTimestamp sets the LastTimestamp field in the declarative configuration to the given value 315 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 316 // If called multiple times, the LastTimestamp field is set to the value of the last call. 317 func (b *EventApplyConfiguration) WithLastTimestamp(value metav1.Time) *EventApplyConfiguration { 318 b.LastTimestamp = &value 319 return b 320 } 321 322 // WithCount sets the Count field in the declarative configuration to the given value 323 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 324 // If called multiple times, the Count field is set to the value of the last call. 325 func (b *EventApplyConfiguration) WithCount(value int32) *EventApplyConfiguration { 326 b.Count = &value 327 return b 328 } 329 330 // WithType sets the Type field in the declarative configuration to the given value 331 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 332 // If called multiple times, the Type field is set to the value of the last call. 333 func (b *EventApplyConfiguration) WithType(value string) *EventApplyConfiguration { 334 b.Type = &value 335 return b 336 } 337 338 // WithEventTime sets the EventTime field in the declarative configuration to the given value 339 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 340 // If called multiple times, the EventTime field is set to the value of the last call. 341 func (b *EventApplyConfiguration) WithEventTime(value metav1.MicroTime) *EventApplyConfiguration { 342 b.EventTime = &value 343 return b 344 } 345 346 // WithSeries sets the Series field in the declarative configuration to the given value 347 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 348 // If called multiple times, the Series field is set to the value of the last call. 349 func (b *EventApplyConfiguration) WithSeries(value *EventSeriesApplyConfiguration) *EventApplyConfiguration { 350 b.Series = value 351 return b 352 } 353 354 // WithAction sets the Action field in the declarative configuration to the given value 355 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 356 // If called multiple times, the Action field is set to the value of the last call. 357 func (b *EventApplyConfiguration) WithAction(value string) *EventApplyConfiguration { 358 b.Action = &value 359 return b 360 } 361 362 // WithRelated sets the Related field in the declarative configuration to the given value 363 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 364 // If called multiple times, the Related field is set to the value of the last call. 365 func (b *EventApplyConfiguration) WithRelated(value *ObjectReferenceApplyConfiguration) *EventApplyConfiguration { 366 b.Related = value 367 return b 368 } 369 370 // WithReportingController sets the ReportingController field in the declarative configuration to the given value 371 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 372 // If called multiple times, the ReportingController field is set to the value of the last call. 373 func (b *EventApplyConfiguration) WithReportingController(value string) *EventApplyConfiguration { 374 b.ReportingController = &value 375 return b 376 } 377 378 // WithReportingInstance sets the ReportingInstance field in the declarative configuration to the given value 379 // and returns the receiver, so that objects can be built by chaining "With" function invocations. 380 // If called multiple times, the ReportingInstance field is set to the value of the last call. 381 func (b *EventApplyConfiguration) WithReportingInstance(value string) *EventApplyConfiguration { 382 b.ReportingInstance = &value 383 return b 384 }