Skip to content

Commit

Permalink
Add URL prefix validation to CRDs
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Oct 17, 2020
1 parent 1f5d108 commit 46666da
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
8 changes: 6 additions & 2 deletions api/v1beta1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ type ProviderSpec struct {
// +optional
Username string `json:"username,omitempty"`

// HTTP(S) webhook address of this provider
// HTTP/S webhook address of this provider
// +kubebuilder:validation:Pattern="^(http|https)://"
// +kubebuilder:validation:Optional
// +optional
Address string `json:"address,omitempty"`

// HTTP(S) address of the proxy
// HTTP/S address of the proxy
// +kubebuilder:validation:Pattern="^(http|https)://"
// +kubebuilder:validation:Optional
// +optional
Proxy string `json:"proxy,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/reference_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ type CrossNamespaceObjectReference struct {
Kind string `json:"kind,omitempty"`

// Name of the referent
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=53
// +required
Name string `json:"name"`

// Namespace of the referent
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=53
// +kubebuilder:validation:Optional
// +optional
Namespace string `json:"namespace,omitempty"`
}
4 changes: 4 additions & 0 deletions config/crd/bases/notification.toolkit.fluxcd.io_alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ spec:
type: string
name:
description: Name of the referent
maxLength: 53
minLength: 1
type: string
namespace:
description: Namespace of the referent
maxLength: 53
minLength: 1
type: string
required:
- name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ spec:
description: ProviderSpec defines the desired state of Provider
properties:
address:
description: HTTP(S) webhook address of this provider
description: HTTP/S webhook address of this provider
pattern: ^(http|https)://
type: string
channel:
description: Alert channel for this provider
type: string
proxy:
description: HTTP(S) address of the proxy
description: HTTP/S address of the proxy
pattern: ^(http|https)://
type: string
secretRef:
description: Secret reference containing the provider webhook URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ spec:
type: string
name:
description: Name of the referent
maxLength: 53
minLength: 1
type: string
namespace:
description: Namespace of the referent
maxLength: 53
minLength: 1
type: string
required:
- name
Expand Down
8 changes: 4 additions & 4 deletions docs/api/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>HTTP(S) webhook address of this provider</p>
<p>HTTP/S webhook address of this provider</p>
</td>
</tr>
<tr>
Expand All @@ -256,7 +256,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>HTTP(S) address of the proxy</p>
<p>HTTP/S address of the proxy</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -670,7 +670,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>HTTP(S) webhook address of this provider</p>
<p>HTTP/S webhook address of this provider</p>
</td>
</tr>
<tr>
Expand All @@ -682,7 +682,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>HTTP(S) address of the proxy</p>
<p>HTTP/S address of the proxy</p>
</td>
</tr>
<tr>
Expand Down
6 changes: 4 additions & 2 deletions docs/spec/v1beta1/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ type ProviderSpec struct {
// +optional
Username string `json:"username,omitempty"`

// HTTP(S) webhook address of this provider
// HTTP/S webhook address of this provider
// +kubebuilder:validation:Pattern="^(http|https)://"
// +optional
Address string `json:"address,omitempty"`

// HTTP(S) address of the proxy
// HTTP/S address of the proxy
// +kubebuilder:validation:Pattern="^(http|https)://"
// +optional
Proxy string `json:"proxy,omitempty"`

Expand Down

0 comments on commit 46666da

Please sign in to comment.