-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Notifications CRD * feat: update notification spec * feat: refactor notification spec * chore: use getters from duty for person & team
- Loading branch information
1 parent
98d9197
commit 7dd89ba
Showing
18 changed files
with
499 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 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,80 @@ | ||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type NotificationRecipientSpec struct { | ||
// ID or email of the person | ||
Person string `json:"person,omitempty" yaml:"person,omitempty"` | ||
|
||
// name or ID of the recipient team | ||
Team string `json:"team,omitempty" yaml:"team,omitempty"` | ||
|
||
// Email of the recipient | ||
Email string `json:"email,omitempty" yaml:"email,omitempty"` | ||
|
||
// Specify connection string for an external service. | ||
// Should be in the format of connection://<type>/name | ||
// or the id of the connection. | ||
Connection string `json:"connection,omitempty" yaml:"connection,omitempty"` | ||
|
||
// Specify shoutrrr URL | ||
URL string `json:"url,omitempty" yaml:"url,omitempty"` | ||
|
||
// Properties for Shoutrrr | ||
Properties map[string]string `json:"properties,omitempty" yaml:"properties,omitempty"` | ||
} | ||
|
||
// Empty returns true if none of the receivers are set | ||
func (t *NotificationRecipientSpec) Empty() bool { | ||
return t.Person == "" && t.Team == "" && t.Email == "" && t.Connection == "" && t.URL == "" | ||
} | ||
|
||
// +kubebuilder:object:generate=true | ||
type NotificationSpec struct { | ||
// List of events that can trigger this notification | ||
Events []string `json:"events" yaml:"events"` | ||
|
||
// The title for the notification | ||
Title string `json:"title,omitempty" yaml:"title,omitempty"` | ||
|
||
// Template is the notification body in markdown | ||
Template string `json:"template,omitempty" yaml:"template,omitempty"` | ||
|
||
// Cel-expression used to decide whether this notification client should send the notification | ||
Filter string `json:"filter,omitempty" yaml:"filter,omitempty"` | ||
|
||
// Specify the recipient | ||
To NotificationRecipientSpec `json:"to" yaml:"to"` | ||
} | ||
|
||
// NotificationStatus defines the observed state of Notification | ||
type NotificationStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// Notification is the Schema for the Notification API | ||
type Notification struct { | ||
metav1.TypeMeta `json:",inline" yaml:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` | ||
|
||
Spec NotificationSpec `json:"spec,omitempty" yaml:"spec,omitempty"` | ||
Status NotificationStatus `json:"status,omitempty" yaml:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// NotificationList contains a list of Notification | ||
type NotificationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Notification `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Notification{}, &NotificationList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
89 changes: 89 additions & 0 deletions
89
config/crds/mission-control.flanksource.com_notifications.yaml
This file contains 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,89 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.11.1 | ||
creationTimestamp: null | ||
name: notifications.mission-control.flanksource.com | ||
spec: | ||
group: mission-control.flanksource.com | ||
names: | ||
kind: Notification | ||
listKind: NotificationList | ||
plural: notifications | ||
singular: notification | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
description: Notification is the Schema for the Notification API | ||
properties: | ||
apiVersion: | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
type: string | ||
kind: | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
properties: | ||
events: | ||
description: List of events that can trigger this notification | ||
items: | ||
type: string | ||
type: array | ||
filter: | ||
description: Cel-expression used to decide whether this notification | ||
client should send the notification | ||
type: string | ||
template: | ||
description: Template is the notification body in markdown | ||
type: string | ||
title: | ||
description: The title for the notification | ||
type: string | ||
to: | ||
description: Specify the recipient | ||
properties: | ||
connection: | ||
description: Specify connection string for an external service. | ||
Should be in the format of connection://<type>/name or the id | ||
of the connection. | ||
type: string | ||
email: | ||
description: Email of the recipient | ||
type: string | ||
person: | ||
description: ID or email of the person | ||
type: string | ||
properties: | ||
additionalProperties: | ||
type: string | ||
description: Properties for Shoutrrr | ||
type: object | ||
team: | ||
description: name or ID of the recipient team | ||
type: string | ||
url: | ||
description: Specify shoutrrr URL | ||
type: string | ||
type: object | ||
required: | ||
- events | ||
- to | ||
type: object | ||
status: | ||
description: NotificationStatus defines the observed state of Notification | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
This file contains 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 @@ | ||
{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Notification","definitions":{"FieldsV1":{"properties":{},"additionalProperties":false,"type":"object"},"ManagedFieldsEntry":{"properties":{"manager":{"type":"string"},"operation":{"type":"string"},"apiVersion":{"type":"string"},"time":{"$ref":"#/definitions/Time"},"fieldsType":{"type":"string"},"fieldsV1":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/FieldsV1"},"subresource":{"type":"string"}},"additionalProperties":false,"type":"object"},"Notification":{"properties":{"kind":{"type":"string"},"apiVersion":{"type":"string"},"metadata":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ObjectMeta"},"spec":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/NotificationSpec"},"status":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/NotificationStatus"}},"additionalProperties":false,"type":"object"},"NotificationRecipientSpec":{"properties":{"person":{"type":"string"},"team":{"type":"string"},"email":{"type":"string"},"connection":{"type":"string"},"url":{"type":"string"},"properties":{"patternProperties":{".*":{"type":"string"}},"type":"object"}},"additionalProperties":false,"type":"object"},"NotificationSpec":{"required":["events","to"],"properties":{"events":{"items":{"type":"string"},"type":"array"},"title":{"type":"string"},"template":{"type":"string"},"filter":{"type":"string"},"to":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/NotificationRecipientSpec"}},"additionalProperties":false,"type":"object"},"NotificationStatus":{"properties":{},"additionalProperties":false,"type":"object"},"ObjectMeta":{"properties":{"name":{"type":"string"},"generateName":{"type":"string"},"namespace":{"type":"string"},"selfLink":{"type":"string"},"uid":{"type":"string"},"resourceVersion":{"type":"string"},"generation":{"type":"integer"},"creationTimestamp":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/Time"},"deletionTimestamp":{"$ref":"#/definitions/Time"},"deletionGracePeriodSeconds":{"type":"integer"},"labels":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"annotations":{"patternProperties":{".*":{"type":"string"}},"type":"object"},"ownerReferences":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/OwnerReference"},"type":"array"},"finalizers":{"items":{"type":"string"},"type":"array"},"managedFields":{"items":{"$schema":"http://json-schema.org/draft-04/schema#","$ref":"#/definitions/ManagedFieldsEntry"},"type":"array"}},"additionalProperties":false,"type":"object"},"OwnerReference":{"required":["apiVersion","kind","name","uid"],"properties":{"apiVersion":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"uid":{"type":"string"},"controller":{"type":"boolean"},"blockOwnerDeletion":{"type":"boolean"}},"additionalProperties":false,"type":"object"},"Time":{"properties":{},"additionalProperties":false,"type":"object"}}} |
Oops, something went wrong.