Skip to content

Commit 40ece10

Browse files
committed
Add shareable providers
1 parent bd242e0 commit 40ece10

26 files changed

+1670
-109
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ manifests: controller-gen
8989
api-docs: gen-crd-api-reference-docs
9090
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta2/notification.md
9191
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta3 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta3/notification.md
92+
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta4 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta4/notification.md
9293
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1/notification.md
9394

9495
# Run go mod tidy

api/v1beta1/alert_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type AlertStatus struct {
7070
// +genclient:Namespaced
7171
// +kubebuilder:object:root=true
7272
// +kubebuilder:subresource:status
73-
// +kubebuilder:deprecatedversion:warning="v1beta1 Alert is deprecated, upgrade to v1beta3"
73+
// +kubebuilder:deprecatedversion:warning="v1beta1 Alert is deprecated, upgrade to v1beta4"
7474
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
7575
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
7676
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""

api/v1beta1/provider_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type ProviderStatus struct {
113113
// +genclient:Namespaced
114114
// +kubebuilder:object:root=true
115115
// +kubebuilder:subresource:status
116-
// +kubebuilder:deprecatedversion:warning="v1beta1 Provider is deprecated, upgrade to v1beta3"
116+
// +kubebuilder:deprecatedversion:warning="v1beta1 Provider is deprecated, upgrade to v1beta4"
117117
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
118118
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
119119
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""

api/v1beta2/alert_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type AlertStatus struct {
9191
// +genclient:Namespaced
9292
// +kubebuilder:object:root=true
9393
// +kubebuilder:subresource:status
94-
// +kubebuilder:deprecatedversion:warning="v1beta2 Alert is deprecated, upgrade to v1beta3"
94+
// +kubebuilder:deprecatedversion:warning="v1beta2 Alert is deprecated, upgrade to v1beta4"
9595
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
9696
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
9797
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""

api/v1beta2/provider_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ type ProviderStatus struct {
134134
// +genclient:Namespaced
135135
// +kubebuilder:object:root=true
136136
// +kubebuilder:subresource:status
137-
// +kubebuilder:deprecatedversion:warning="v1beta2 Provider is deprecated, upgrade to v1beta3"
137+
// +kubebuilder:deprecatedversion:warning="v1beta2 Provider is deprecated, upgrade to v1beta4"
138138
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
139139
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
140140
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""

api/v1beta3/alert_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ type AlertSpec struct {
7676

7777
// +genclient
7878
// +genclient:Namespaced
79-
// +kubebuilder:storageversion
8079
// +kubebuilder:object:root=true
80+
// +kubebuilder:subresource:status
81+
// +kubebuilder:deprecatedversion:warning="v1beta3 Alert is deprecated, upgrade to v1beta4"
8182
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
8283

8384
// Alert is the Schema for the alerts API

api/v1beta3/provider_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ type ProviderSpec struct {
123123

124124
// +genclient
125125
// +genclient:Namespaced
126-
// +kubebuilder:storageversion
127126
// +kubebuilder:object:root=true
127+
// +kubebuilder:subresource:status
128+
// +kubebuilder:deprecatedversion:warning="v1beta3 Provider is deprecated, upgrade to v1beta4"
128129
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
129130

130131
// Provider is the Schema for the providers API

api/v1beta4/alert_types.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
Copyright 2023 The Flux 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+
package v1beta4
18+
19+
import (
20+
"github.com/fluxcd/pkg/apis/meta"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
23+
v1 "github.com/fluxcd/notification-controller/api/v1"
24+
)
25+
26+
const (
27+
AlertKind string = "Alert"
28+
)
29+
30+
// AlertSpec defines an alerting rule for events involving a list of objects.
31+
type AlertSpec struct {
32+
// ProviderRef specifies which Provider this Alert should use.
33+
// +required
34+
ProviderRef meta.NamespacedObjectReference `json:"providerRef"`
35+
36+
// EventSeverity specifies how to filter events based on severity.
37+
// If set to 'info' no events will be filtered.
38+
// +kubebuilder:validation:Enum=info;error
39+
// +kubebuilder:default:=info
40+
// +optional
41+
EventSeverity string `json:"eventSeverity,omitempty"`
42+
43+
// EventSources specifies how to filter events based
44+
// on the involved object kind, name and namespace.
45+
// +required
46+
EventSources []v1.CrossNamespaceObjectReference `json:"eventSources"`
47+
48+
// InclusionList specifies a list of Golang regular expressions
49+
// to be used for including messages.
50+
// +optional
51+
InclusionList []string `json:"inclusionList,omitempty"`
52+
53+
// EventMetadata is an optional field for adding metadata to events dispatched by the
54+
// controller. This can be used for enhancing the context of the event. If a field
55+
// would override one already present on the original event as generated by the emitter,
56+
// then the override doesn't happen, i.e. the original value is preserved, and an info
57+
// log is printed.
58+
// +optional
59+
EventMetadata map[string]string `json:"eventMetadata,omitempty"`
60+
61+
// ExclusionList specifies a list of Golang regular expressions
62+
// to be used for excluding messages.
63+
// +optional
64+
ExclusionList []string `json:"exclusionList,omitempty"`
65+
66+
// Summary holds a short description of the impact and affected cluster.
67+
// +kubebuilder:validation:MaxLength:=255
68+
// +optional
69+
Summary string `json:"summary,omitempty"`
70+
71+
// Suspend tells the controller to suspend subsequent
72+
// events handling for this Alert.
73+
// +optional
74+
Suspend bool `json:"suspend,omitempty"`
75+
76+
// Channel specifies the destination channel where events should be posted.
77+
// This will override any default channel that might be set in the provider
78+
// +kubebuilder:validation:MaxLength:=2048
79+
// +optional
80+
Channel string `json:"channel,omitempty"`
81+
}
82+
83+
// +genclient
84+
// +genclient:Namespaced
85+
// +kubebuilder:storageversion
86+
// +kubebuilder:object:root=true
87+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
88+
89+
// Alert is the Schema for the alerts API
90+
type Alert struct {
91+
metav1.TypeMeta `json:",inline"`
92+
metav1.ObjectMeta `json:"metadata,omitempty"`
93+
94+
Spec AlertSpec `json:"spec,omitempty"`
95+
}
96+
97+
//+kubebuilder:object:root=true
98+
99+
// AlertList contains a list of Alert
100+
type AlertList struct {
101+
metav1.TypeMeta `json:",inline"`
102+
metav1.ListMeta `json:"metadata,omitempty"`
103+
Items []Alert `json:"items"`
104+
}
105+
106+
func init() {
107+
SchemeBuilder.Register(&Alert{}, &AlertList{})
108+
}

api/v1beta4/doc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2023 The Flux 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+
// Package v1beta4 contains API Schema definitions for the notification v1beta4 API group.
18+
// +kubebuilder:object:generate=true
19+
// +groupName=notification.toolkit.fluxcd.io
20+
package v1beta4

api/v1beta4/groupversion_info.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2023 The Flux 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+
package v1beta4
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime/schema"
21+
"sigs.k8s.io/controller-runtime/pkg/scheme"
22+
)
23+
24+
var (
25+
// GroupVersion is group version used to register these objects
26+
GroupVersion = schema.GroupVersion{Group: "notification.toolkit.fluxcd.io", Version: "v1beta4"}
27+
28+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
29+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
30+
31+
// AddToScheme adds the types in this group-version to the given scheme.
32+
AddToScheme = SchemeBuilder.AddToScheme
33+
)

0 commit comments

Comments
 (0)