-
Notifications
You must be signed in to change notification settings - Fork 163
Refactor events and introduce v1beta3 API for Alert and Provider #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4bf469e
Add Alert and Provider v1beta3 API
darkowlzz 36bc652
Remove Alert and Provider reconcilers
darkowlzz 80f7237
Refactor event handler
darkowlzz 19a60e9
event handler: Add k8s events for Alerts
darkowlzz 84e1d74
Add alert and provider reconcilers for migration
darkowlzz b99de58
workflows/e2e: Update status-defaults & smoke test
darkowlzz b2e533a
Add v1beta3 spec docs
darkowlzz 9a5debd
Deprecate v1beta1 & v1beta2 Alert & Provider APIs
darkowlzz 6df2c74
event_handler: Use proper ctx for post fail log
darkowlzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| Copyright 2023 The Flux authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1beta3 | ||
|
|
||
| import ( | ||
| "github.com/fluxcd/pkg/apis/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| v1 "github.com/fluxcd/notification-controller/api/v1" | ||
| ) | ||
|
|
||
| const ( | ||
| AlertKind string = "Alert" | ||
| ) | ||
|
|
||
| // AlertSpec defines an alerting rule for events involving a list of objects. | ||
| type AlertSpec struct { | ||
| // ProviderRef specifies which Provider this Alert should use. | ||
| // +required | ||
| ProviderRef meta.LocalObjectReference `json:"providerRef"` | ||
|
|
||
| // EventSeverity specifies how to filter events based on severity. | ||
| // If set to 'info' no events will be filtered. | ||
| // +kubebuilder:validation:Enum=info;error | ||
| // +kubebuilder:default:=info | ||
| // +optional | ||
| EventSeverity string `json:"eventSeverity,omitempty"` | ||
|
|
||
| // EventSources specifies how to filter events based | ||
| // on the involved object kind, name and namespace. | ||
| // +required | ||
| EventSources []v1.CrossNamespaceObjectReference `json:"eventSources"` | ||
|
|
||
| // InclusionList specifies a list of Golang regular expressions | ||
| // to be used for including messages. | ||
| // +optional | ||
| InclusionList []string `json:"inclusionList,omitempty"` | ||
|
|
||
| // EventMetadata is an optional field for adding metadata to events dispatched by the | ||
| // controller. This can be used for enhancing the context of the event. If a field | ||
| // would override one already present on the original event as generated by the emitter, | ||
| // then the override doesn't happen, i.e. the original value is preserved, and an info | ||
| // log is printed. | ||
| // +optional | ||
| EventMetadata map[string]string `json:"eventMetadata,omitempty"` | ||
|
|
||
| // ExclusionList specifies a list of Golang regular expressions | ||
| // to be used for excluding messages. | ||
| // +optional | ||
| ExclusionList []string `json:"exclusionList,omitempty"` | ||
|
|
||
| // Summary holds a short description of the impact and affected cluster. | ||
| // +kubebuilder:validation:MaxLength:=255 | ||
| // +optional | ||
| Summary string `json:"summary,omitempty"` | ||
|
|
||
| // Suspend tells the controller to suspend subsequent | ||
| // events handling for this Alert. | ||
| // +optional | ||
| Suspend bool `json:"suspend,omitempty"` | ||
| } | ||
|
|
||
| // +genclient | ||
| // +genclient:Namespaced | ||
| // +kubebuilder:storageversion | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" | ||
|
|
||
| // Alert is the Schema for the alerts API | ||
| type Alert struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec AlertSpec `json:"spec,omitempty"` | ||
| } | ||
|
|
||
| //+kubebuilder:object:root=true | ||
|
|
||
| // AlertList contains a list of Alert | ||
| type AlertList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []Alert `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&Alert{}, &AlertList{}) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| Copyright 2023 The Flux authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| // Package v1beta3 contains API Schema definitions for the notification v1beta3 API group. | ||
| // +kubebuilder:object:generate=true | ||
| // +groupName=notification.toolkit.fluxcd.io | ||
| package v1beta3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| Copyright 2023 The Flux authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1beta3 | ||
|
|
||
| import ( | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| "sigs.k8s.io/controller-runtime/pkg/scheme" | ||
| ) | ||
|
|
||
| var ( | ||
| // GroupVersion is group version used to register these objects | ||
| GroupVersion = schema.GroupVersion{Group: "notification.toolkit.fluxcd.io", Version: "v1beta3"} | ||
|
|
||
| // SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
| SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
|
||
| // AddToScheme adds the types in this group-version to the given scheme. | ||
| AddToScheme = SchemeBuilder.AddToScheme | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.