-
Notifications
You must be signed in to change notification settings - Fork 152
Refactor reconcilers and introduce v1beta2 API #435
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
Changes from all commits
974a77d
9f2d0e1
8dadcac
a9ac01a
ab92536
ab5cdc8
613111c
5fd17e6
2b35ef5
ae65712
ee2600a
caec764
012faa2
70c678f
1a4a4a8
c9a774f
d16588a
5a0d6dd
4aad301
831785a
04f5288
78fe519
20fa1a0
ef94247
b0c02d7
16012ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,13 @@ resources: | |
| - group: notification | ||
| kind: Receiver | ||
| version: v1beta1 | ||
| - group: notification | ||
| kind: Provider | ||
| version: v1beta2 | ||
| - group: notification | ||
| kind: Alert | ||
| version: v1beta2 | ||
| - group: notification | ||
| kind: Receiver | ||
| version: v1beta2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also add or update the sample CRDs in config/samples for these new APIs. They are useful for quickly referring to samples. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left them on v1beta1 to test the API upgrade hooks, I'll update them to v1beta2 once we're close to the finish line with this PR. |
||
| version: "2" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| Copyright 2022 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 v1beta2 | ||
|
|
||
| import ( | ||
| "github.com/fluxcd/pkg/apis/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/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 []CrossNamespaceObjectReference `json:"eventSources"` | ||
|
|
||
| // 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"` | ||
| } | ||
|
|
||
| // AlertStatus defines the observed state of the Alert. | ||
| type AlertStatus struct { | ||
| meta.ReconcileRequestStatus `json:",inline"` | ||
|
|
||
| // Conditions holds the conditions for the Alert. | ||
| // +optional | ||
| Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
|
|
||
| // ObservedGeneration is the last observed generation. | ||
| // +optional | ||
| ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
| } | ||
|
|
||
| // +genclient | ||
| // +genclient:Namespaced | ||
| // +kubebuilder:storageversion | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" | ||
| // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="" | ||
| // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",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:default:={"observedGeneration":-1} | ||
| Status AlertStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // GetConditions returns the status conditions of the object. | ||
| func (in *Alert) GetConditions() []metav1.Condition { | ||
| return in.Status.Conditions | ||
| } | ||
|
|
||
| // SetConditions sets the status conditions on the object. | ||
| func (in *Alert) SetConditions(conditions []metav1.Condition) { | ||
| in.Status.Conditions = conditions | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // AlertList contains a list of Alerts. | ||
| type AlertList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []Alert `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&Alert{}, &AlertList{}) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| Copyright 2022 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 v1beta2 | ||
|
|
||
| const NotificationFinalizer = "finalizers.fluxcd.io" | ||
|
|
||
| const ( | ||
| // InitializedReason represents the fact that a given resource has been initialized. | ||
| InitializedReason string = "Initialized" | ||
|
|
||
| // ValidationFailedReason represents the fact that some part of the spec of a given resource | ||
| // couldn't be validated. | ||
| ValidationFailedReason string = "ValidationFailed" | ||
|
|
||
| // TokenNotFoundReason represents the fact that receiver token can't be found. | ||
| TokenNotFoundReason string = "TokenNotFound" | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| Copyright 2022 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 v1beta2 contains API Schema definitions for the notification v1beta2 API group. | ||
| // +kubebuilder:object:generate=true | ||
| // +groupName=notification.toolkit.fluxcd.io | ||
| package v1beta2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| Copyright 2022 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 v1beta2 | ||
|
|
||
| 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: "v1beta2"} | ||
|
|
||
| // 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 | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.