Skip to content

Commit 5dc6124

Browse files
authored
Merge pull request #435 from fluxcd/api-v1beta2
Refactor reconcilers and introduce v1beta2 API
2 parents 188aad7 + 16012ce commit 5dc6124

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5695
-697
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
IMG ?= fluxcd/notification-controller:latest
33
# Produce CRDs that work back to Kubernetes 1.16
44
CRD_OPTIONS ?= crd:crdVersions=v1
5-
SOURCE_VER ?= v0.24.0
5+
SOURCE_VER ?= v0.31.0
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))
@@ -76,7 +76,7 @@ manifests: controller-gen
7676

7777
# Generate API reference documentation
7878
api-docs: gen-crd-api-reference-docs
79-
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/notification.md
79+
$(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/notification.md
8080

8181
# Run go mod tidy
8282
tidy:

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,13 @@ resources:
1010
- group: notification
1111
kind: Receiver
1212
version: v1beta1
13+
- group: notification
14+
kind: Provider
15+
version: v1beta2
16+
- group: notification
17+
kind: Alert
18+
version: v1beta2
19+
- group: notification
20+
kind: Receiver
21+
version: v1beta2
1322
version: "2"

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/alert_types.go

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
Copyright 2022 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 v1beta2
18+
19+
import (
20+
"github.com/fluxcd/pkg/apis/meta"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
const (
25+
AlertKind string = "Alert"
26+
)
27+
28+
// AlertSpec defines an alerting rule for events involving a list of objects.
29+
type AlertSpec struct {
30+
// ProviderRef specifies which Provider this Alert should use.
31+
// +required
32+
ProviderRef meta.LocalObjectReference `json:"providerRef"`
33+
34+
// EventSeverity specifies how to filter events based on severity.
35+
// If set to 'info' no events will be filtered.
36+
// +kubebuilder:validation:Enum=info;error
37+
// +kubebuilder:default:=info
38+
// +optional
39+
EventSeverity string `json:"eventSeverity,omitempty"`
40+
41+
// EventSources specifies how to filter events based
42+
// on the involved object kind, name and namespace.
43+
// +required
44+
EventSources []CrossNamespaceObjectReference `json:"eventSources"`
45+
46+
// ExclusionList specifies a list of Golang regular expressions
47+
// to be used for excluding messages.
48+
// +optional
49+
ExclusionList []string `json:"exclusionList,omitempty"`
50+
51+
// Summary holds a short description of the impact and affected cluster.
52+
// +kubebuilder:validation:MaxLength:=255
53+
// +optional
54+
Summary string `json:"summary,omitempty"`
55+
56+
// Suspend tells the controller to suspend subsequent
57+
// events handling for this Alert.
58+
// +optional
59+
Suspend bool `json:"suspend,omitempty"`
60+
}
61+
62+
// AlertStatus defines the observed state of the Alert.
63+
type AlertStatus struct {
64+
meta.ReconcileRequestStatus `json:",inline"`
65+
66+
// Conditions holds the conditions for the Alert.
67+
// +optional
68+
Conditions []metav1.Condition `json:"conditions,omitempty"`
69+
70+
// ObservedGeneration is the last observed generation.
71+
// +optional
72+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
73+
}
74+
75+
// +genclient
76+
// +genclient:Namespaced
77+
// +kubebuilder:storageversion
78+
// +kubebuilder:object:root=true
79+
// +kubebuilder:subresource:status
80+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
81+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
82+
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
83+
84+
// Alert is the Schema for the alerts API
85+
type Alert struct {
86+
metav1.TypeMeta `json:",inline"`
87+
metav1.ObjectMeta `json:"metadata,omitempty"`
88+
89+
Spec AlertSpec `json:"spec,omitempty"`
90+
// +kubebuilder:default:={"observedGeneration":-1}
91+
Status AlertStatus `json:"status,omitempty"`
92+
}
93+
94+
// GetConditions returns the status conditions of the object.
95+
func (in *Alert) GetConditions() []metav1.Condition {
96+
return in.Status.Conditions
97+
}
98+
99+
// SetConditions sets the status conditions on the object.
100+
func (in *Alert) SetConditions(conditions []metav1.Condition) {
101+
in.Status.Conditions = conditions
102+
}
103+
104+
// +kubebuilder:object:root=true
105+
106+
// AlertList contains a list of Alerts.
107+
type AlertList struct {
108+
metav1.TypeMeta `json:",inline"`
109+
metav1.ListMeta `json:"metadata,omitempty"`
110+
Items []Alert `json:"items"`
111+
}
112+
113+
func init() {
114+
SchemeBuilder.Register(&Alert{}, &AlertList{})
115+
}

api/v1beta2/condition_types.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright 2022 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 v1beta2
18+
19+
const NotificationFinalizer = "finalizers.fluxcd.io"
20+
21+
const (
22+
// InitializedReason represents the fact that a given resource has been initialized.
23+
InitializedReason string = "Initialized"
24+
25+
// ValidationFailedReason represents the fact that some part of the spec of a given resource
26+
// couldn't be validated.
27+
ValidationFailedReason string = "ValidationFailed"
28+
29+
// TokenNotFoundReason represents the fact that receiver token can't be found.
30+
TokenNotFoundReason string = "TokenNotFound"
31+
)

api/v1beta2/doc.go

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

api/v1beta2/groupversion_info.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2022 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 v1beta2
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: "v1beta2"}
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)