From 13d3d8f9eebad6d894c05f69cdda477a755b2f91 Mon Sep 17 00:00:00 2001 From: Matheus Pimenta Date: Tue, 27 Jun 2023 19:34:17 +0100 Subject: [PATCH] Lift HTTP/S validation from Provider spec.address Signed-off-by: Matheus Pimenta --- api/v1beta2/provider_types.go | 6 ++++-- .../notification.toolkit.fluxcd.io_providers.yaml | 8 +++++--- docs/api/v1beta2/notification.md | 10 ++++++++-- docs/spec/v1beta2/providers.md | 5 ++++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/api/v1beta2/provider_types.go b/api/v1beta2/provider_types.go index fe5622e77..62ef05404 100644 --- a/api/v1beta2/provider_types.go +++ b/api/v1beta2/provider_types.go @@ -74,8 +74,10 @@ type ProviderSpec struct { // +optional Username string `json:"username,omitempty"` - // Address specifies the HTTP/S incoming webhook address of this Provider. - // +kubebuilder:validation:Pattern="^(http|https)://.*$" + // Address specifies the endpoint, in a generic sense, to where alerts are sent. + // What kind of endpoint depends on the specific Provider type being used. + // For the generic Provider, for example, this is an HTTP/S address. + // For other Provider types this could be a project ID or a namespace. // +kubebuilder:validation:MaxLength:=2048 // +kubebuilder:validation:Optional // +optional diff --git a/config/crd/bases/notification.toolkit.fluxcd.io_providers.yaml b/config/crd/bases/notification.toolkit.fluxcd.io_providers.yaml index 6086e1549..d2f26b390 100644 --- a/config/crd/bases/notification.toolkit.fluxcd.io_providers.yaml +++ b/config/crd/bases/notification.toolkit.fluxcd.io_providers.yaml @@ -228,10 +228,12 @@ spec: description: ProviderSpec defines the desired state of the Provider. properties: address: - description: Address specifies the HTTP/S incoming webhook address - of this Provider. + description: Address specifies the endpoint, in a generic sense, to + where alerts are sent. What kind of endpoint depends on the specific + Provider type being used. For the generic Provider, for example, + this is an HTTP/S address. For other Provider types this could be + a project ID or a namespace. maxLength: 2048 - pattern: ^(http|https)://.*$ type: string certSecretRef: description: CertSecretRef specifies the Secret containing a PEM-encoded diff --git a/docs/api/v1beta2/notification.md b/docs/api/v1beta2/notification.md index 66e135916..a47b9e719 100644 --- a/docs/api/v1beta2/notification.md +++ b/docs/api/v1beta2/notification.md @@ -313,7 +313,10 @@ string (Optional) -

Address specifies the HTTP/S incoming webhook address of this Provider.

+

Address specifies the endpoint, in a generic sense, to where alerts are sent. +What kind of endpoint depends on the specific Provider type being used. +For the generic Provider, for example, this is an HTTP/S address. +For other Provider types this could be a project ID or a namespace.

@@ -902,7 +905,10 @@ string (Optional) -

Address specifies the HTTP/S incoming webhook address of this Provider.

+

Address specifies the endpoint, in a generic sense, to where alerts are sent. +What kind of endpoint depends on the specific Provider type being used. +For the generic Provider, for example, this is an HTTP/S address. +For other Provider types this could be a project ID or a namespace.

diff --git a/docs/spec/v1beta2/providers.md b/docs/spec/v1beta2/providers.md index 27439403d..5670a1c2c 100644 --- a/docs/spec/v1beta2/providers.md +++ b/docs/spec/v1beta2/providers.md @@ -936,7 +936,10 @@ stringData: ### Address -`.spec.address` is an optional field that specifies the URL where the events are posted. +`.spec.address` is an optional field that specifies the endpoint where the events are posted. +The meaning of endpoint here depends on the specific Provider type being used. +For the `generic` Provider for example this is an HTTP/S address. +For other Provider types this could be a project ID or a namespace. If the address contains sensitive information such as tokens or passwords, it is recommended to store the address in the Kubernetes secret referenced by `.spec.secretRef.name`.