Skip to content

Commit

Permalink
docs: further specify uid requirements (#1835)
Browse files Browse the repository at this point in the history
  • Loading branch information
theSuess authored Jan 23, 2025
1 parent 8bdd140 commit 0d53646
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 28 deletions.
2 changes: 2 additions & 0 deletions api/v1beta1/grafanaalertrulegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type AlertRule struct {
// +kubebuilder:example="Always firing"
Title string `json:"title"`

// UID of the alert rule. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
UID string `json:"uid"`
}
Expand Down
4 changes: 3 additions & 1 deletion api/v1beta1/grafanacontactpoint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import (
type GrafanaContactPointSpec struct {
GrafanaCommonSpec `json:",inline"`

// Manually specify the UID the Contact Point is created with
// Manually specify the UID the Contact Point is created with. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec.uid is immutable"
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
CustomUID string `json:"uid,omitempty"`

// +optional
Expand Down
6 changes: 5 additions & 1 deletion api/v1beta1/grafanadashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ type GrafanaDashboardUrlAuthorization struct {
type GrafanaDashboardSpec struct {
GrafanaCommonSpec `json:",inline"`

// Manually specify the uid for the dashboard, overwrites uids already present in the json model
// Manually specify the uid for the dashboard, overwrites uids already present
// in the json model. Can be any string consisting of alphanumeric characters,
// - and _ with a maximum length of 40
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec.uid is immutable"
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
CustomUID string `json:"uid,omitempty"`

// dashboard json
Expand Down
7 changes: 5 additions & 2 deletions api/v1beta1/grafanadatasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ type GrafanaDatasourceInternal struct {
type GrafanaDatasourceSpec struct {
GrafanaCommonSpec `json:",inline"`

// The UID, for the datasource, fallback to the deprecated spec.datasource.uid and metadata.uid
// +optional
// The UID, for the datasource, fallback to the deprecated spec.datasource.uid
// and metadata.uid. Can be any string consisting of alphanumeric characters,
// - and _ with a maximum length of 40 +optional
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec.uid is immutable"
CustomUID string `json:"uid,omitempty"`

Expand Down
4 changes: 3 additions & 1 deletion api/v1beta1/grafanafolder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ import (
type GrafanaFolderSpec struct {
GrafanaCommonSpec `json:",inline"`

// Manually specify the UID the Folder is created with
// Manually specify the UID the Folder is created with. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec.uid is immutable"
// +kubebuilder:validation:MaxLength=40
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
CustomUID string `json:"uid,omitempty"`

// Display name of the folder in Grafana
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ spec:
minLength: 1
type: string
uid:
description: UID of the alert rule. Can be any string consisting
of alphanumeric characters, - and _ with a maximum length
of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ spec:
type: string
uid:
description: Manually specify the UID the Contact Point is created
with
with. Can be any string consisting of alphanumeric characters, -
and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: Manually specify the uid for the dashboard, overwrites
uids already present in the json model
description: |-
Manually specify the uid for the dashboard, overwrites uids already present
in the json model. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: The UID, for the datasource, fallback to the deprecated
spec.datasource.uid and metadata.uid
description: |-
The UID, for the datasource, fallback to the deprecated spec.datasource.uid
and metadata.uid. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40 +optional
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/grafana.integreatly.org_grafanafolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ spec:
description: Display name of the folder in Grafana
type: string
uid:
description: Manually specify the UID the Folder is created with
description: Manually specify the UID the Folder is created with.
Can be any string consisting of alphanumeric characters, - and _
with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ spec:
minLength: 1
type: string
uid:
description: UID of the alert rule. Can be any string consisting
of alphanumeric characters, - and _ with a maximum length
of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ spec:
type: string
uid:
description: Manually specify the UID the Contact Point is created
with
with. Can be any string consisting of alphanumeric characters, -
and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: Manually specify the uid for the dashboard, overwrites
uids already present in the json model
description: |-
Manually specify the uid for the dashboard, overwrites uids already present
in the json model. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: The UID, for the datasource, fallback to the deprecated
spec.datasource.uid and metadata.uid
description: |-
The UID, for the datasource, fallback to the deprecated spec.datasource.uid
and metadata.uid. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40 +optional
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ spec:
description: Display name of the folder in Grafana
type: string
uid:
description: Manually specify the UID the Folder is created with
description: Manually specify the UID the Folder is created with.
Can be any string consisting of alphanumeric characters, - and _
with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
31 changes: 25 additions & 6 deletions deploy/kustomize/base/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ spec:
minLength: 1
type: string
uid:
description: UID of the alert rule. Can be any string consisting
of alphanumeric characters, - and _ with a maximum length
of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
required:
Expand Down Expand Up @@ -476,7 +480,10 @@ spec:
type: string
uid:
description: Manually specify the UID the Contact Point is created
with
with. Can be any string consisting of alphanumeric characters, -
and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down Expand Up @@ -962,8 +969,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: Manually specify the uid for the dashboard, overwrites
uids already present in the json model
description: |-
Manually specify the uid for the dashboard, overwrites uids already present
in the json model. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down Expand Up @@ -1299,8 +1310,12 @@ spec:
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
type: string
uid:
description: The UID, for the datasource, fallback to the deprecated
spec.datasource.uid and metadata.uid
description: |-
The UID, for the datasource, fallback to the deprecated spec.datasource.uid
and metadata.uid. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40 +optional
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down Expand Up @@ -1595,7 +1610,11 @@ spec:
description: Display name of the folder in Grafana
type: string
uid:
description: Manually specify the UID the Folder is created with
description: Manually specify the UID the Folder is created with.
Can be any string consisting of alphanumeric characters, - and _
with a maximum length of 40
maxLength: 40
pattern: ^[a-zA-Z0-9-_]+$
type: string
x-kubernetes-validations:
- message: spec.uid is immutable
Expand Down
14 changes: 9 additions & 5 deletions docs/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ AlertRule defines a specific rule to be evaluated. It is based on the upstream m
<td><b>uid</b></td>
<td>string</td>
<td>
<br/>
UID of the alert rule. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40<br/>
</td>
<td>true</td>
</tr><tr>
Expand Down Expand Up @@ -768,7 +768,7 @@ GrafanaContactPointSpec defines the desired state of GrafanaContactPoint
<td><b>uid</b></td>
<td>string</td>
<td>
Manually specify the UID the Contact Point is created with<br/>
Manually specify the UID the Contact Point is created with. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40<br/>
<br/>
<i>Validations</i>:<li>self == oldSelf: spec.uid is immutable</li>
</td>
Expand Down Expand Up @@ -1346,7 +1346,9 @@ GrafanaDashboardSpec defines the desired state of GrafanaDashboard
<td><b>uid</b></td>
<td>string</td>
<td>
Manually specify the uid for the dashboard, overwrites uids already present in the json model<br/>
Manually specify the uid for the dashboard, overwrites uids already present
in the json model. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40<br/>
<br/>
<i>Validations</i>:<li>self == oldSelf: spec.uid is immutable</li>
</td>
Expand Down Expand Up @@ -2371,7 +2373,9 @@ GrafanaDatasourceSpec defines the desired state of GrafanaDatasource
<td><b>uid</b></td>
<td>string</td>
<td>
The UID, for the datasource, fallback to the deprecated spec.datasource.uid and metadata.uid<br/>
The UID, for the datasource, fallback to the deprecated spec.datasource.uid
and metadata.uid. Can be any string consisting of alphanumeric characters,
- and _ with a maximum length of 40 +optional<br/>
<br/>
<i>Validations</i>:<li>self == oldSelf: spec.uid is immutable</li>
</td>
Expand Down Expand Up @@ -3059,7 +3063,7 @@ GrafanaFolderSpec defines the desired state of GrafanaFolder
<td><b>uid</b></td>
<td>string</td>
<td>
Manually specify the UID the Folder is created with<br/>
Manually specify the UID the Folder is created with. Can be any string consisting of alphanumeric characters, - and _ with a maximum length of 40<br/>
<br/>
<i>Validations</i>:<li>self == oldSelf: spec.uid is immutable</li>
</td>
Expand Down

0 comments on commit 0d53646

Please sign in to comment.