Skip to content
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

feat: add discord alert #28

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions api/v1alpha1/alert_config_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type (
AlertConfigSpec struct {
// +kubebuilder:validation:Optional
Discord *AlertDiscordSpec `json:"discord,omitempty"`
}

// AlertDiscordSpec defines the desired state of AlertDiscord
AlertDiscordSpec struct {
// +kubebuilder:validation:Required
WebhookURL ValueOrValueFrom `json:"webhookURL"`

// +kubebuilder:validation:Optional
// +kubebuilder:description:List of users or roles to notify.
Mentions []string `json:"mentions,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:description:Timeout specifies a time limit for the request to be made.
// +kubebuilder:default:10s
Timeout string `json:"timeout,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Schemaless
// +kubebuilder:validation:Type=string
TemplateBody string `json:"templateBody,omitempty"`
}

// AlertDiscordStatus defines the observed state of AlertDiscord
AlertConfigStatus struct{}
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=alertconfig,scope=Cluster

type AlertConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AlertConfigSpec `json:"spec,omitempty"`
Status AlertConfigStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

type AlertConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AlertConfig `json:"items"`
}

func init() {
SchemeBuilder.Register(&AlertConfig{}, &AlertConfigList{})
}
50 changes: 0 additions & 50 deletions api/v1alpha1/alert_discord_types.go

This file was deleted.

9 changes: 4 additions & 5 deletions api/v1alpha1/image_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/orange-cloudavenue/kube-image-updater/internal/actions"
"github.com/orange-cloudavenue/kube-image-updater/internal/rules"
"github.com/orange-cloudavenue/kube-image-updater/internal/triggers"
)
Expand Down Expand Up @@ -77,7 +76,7 @@ type (
Name string `json:"name"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=semver-major;semver-minor;semver-patch;regex
// +kubebuilder:validation:Enum=semver-major;semver-minor;semver-patch;regex;always
Type rules.Name `json:"type"`

// +kubebuilder:validation:Optional
Expand All @@ -91,11 +90,11 @@ type (
// ImageAction
ImageAction struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=apply;request-approval;notify
Type actions.Name `json:"type"`
// +kubebuilder:validation:Enum=apply;request-approval;alert-discord
Type string `json:"type"`

// +kubebuilder:validation:Optional
Value string `json:"value,omitempty"`
Data ValueOrValueFrom `json:"data,omitempty"`
}

// ImageStatus defines the observed state of Image
Expand Down
78 changes: 0 additions & 78 deletions api/v1alpha1/value_or_valueFrom.go

This file was deleted.

33 changes: 33 additions & 0 deletions api/v1alpha1/value_or_valueFrom_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
)

type (
ValueOrValueFrom struct {
// Value is a string value to assign to the key.
// if ValueFrom is specified, this value is ignored.
// +optional
Value string `json:"value,omitempty"`

// ValueFrom is a reference to a field in a secret or config map.
// +optional
ValueFrom *ValueFromSource `json:"valueFrom,omitempty"`
}

// ValueFromSource is a reference to a field in a secret or config map.
ValueFromSource struct {
// SecretKeyRef is a reference to a field in a secret.
// +optional
SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef,omitempty"`

// ConfigMapKeyRef is a reference to a field in a config map.
// +optional
ConfigMapKeyRef *corev1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`

// AlertConfigRef is a reference to a field in an alert configuration.
// +optional
AlertConfigRef *corev1.LocalObjectReference `json:"alertConfigRef,omitempty"`
}
)
Loading
Loading