github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/alertexception.go (about) 1 // Copyright (c) 2022 Tigera, Inc. All rights reserved. 2 3 package v3 4 5 import ( 6 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 7 ) 8 9 const ( 10 KindAlertException = "AlertException" 11 KindAlertExceptionList = "AlertExceptionList" 12 ) 13 14 // +genclient 15 // +genclient:nonNamespaced 16 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 17 18 // AlertException defines exceptions for alert events. 19 type AlertException struct { 20 metav1.TypeMeta `json:",inline"` 21 metav1.ObjectMeta `json:"metadata,omitempty"` 22 23 Spec AlertExceptionSpec `json:"spec,omitempty"` 24 Status AlertExceptionStatus `json:"status,omitempty"` 25 } 26 27 // AlertExceptionSpec contains the specification for an alert exception resource. 28 type AlertExceptionSpec struct { 29 // The description is displayed by the UI. 30 Description string `json:"description" validate:"required"` 31 32 // Selector defines a query string for alert events to be excluded from UI search results. 33 Selector string `json:"selector" validate:"required"` 34 35 // StartTime defines the start time from which this alert exception will take effect. 36 // If the value is in the past, matched alerts will be filtered immediately. 37 // If the value is changed to a future time, alert exceptions will restart at that time. 38 // +kubebuilder:validation:Format="date-time" 39 StartTime metav1.Time `json:"startTime" validate:"required"` 40 41 // EndTime defines the end time at which this alert exception will expire. 42 // If omitted the alert exception filtering will continue indefinitely. 43 // +optional 44 //+kubebuilder:validation:Format="date-time" 45 EndTime *metav1.Time `json:"endTime,omitempty" validate:"omitempty"` 46 } 47 48 // AlertExceptionStatus contains the status of an alert exception. 49 type AlertExceptionStatus struct { 50 } 51 52 // +genclient:nonNamespaced 53 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 54 55 // AlertExceptionList contains a list of AlertException resources. 56 type AlertExceptionList struct { 57 metav1.TypeMeta `json:",inline"` 58 metav1.ListMeta `json:"metadata"` 59 Items []AlertException `json:"items"` 60 } 61 62 func NewAlertException() *AlertException { 63 return &AlertException{ 64 TypeMeta: metav1.TypeMeta{ 65 Kind: KindAlertException, 66 APIVersion: GroupVersionCurrent, 67 }, 68 } 69 } 70 71 func NewAlertExceptionList() *AlertExceptionList { 72 return &AlertExceptionList{ 73 TypeMeta: metav1.TypeMeta{ 74 Kind: KindAlertExceptionList, 75 APIVersion: GroupVersionCurrent, 76 }, 77 } 78 }