Alerting: Update provisioning to validate user-defined UID on create (#73793)

* add ValidateUID to util
* provisioning to validate UID on rule creation

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
This commit is contained in:
Yuri Tseretyan
2023-09-08 15:09:35 -04:00
committed by GitHub
co-authored by brendamuir Alexander Weaver
parent 9c50296a07
commit 99fd7b8141
14 changed files with 161 additions and 24 deletions
@@ -2663,6 +2663,9 @@
"type": "string"
},
"uid": {
"maxLength": 40,
"minLength": 1,
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"updated": {
@@ -108,7 +108,11 @@ type AlertRuleHeaders struct {
type ProvisionedAlertRules []ProvisionedAlertRule
type ProvisionedAlertRule struct {
ID int64 `json:"id"`
ID int64 `json:"id"`
// required: false
// minLength: 1
// maxLength: 40
// pattern: ^[a-zA-Z0-9-_]+$
UID string `json:"uid"`
// required: true
OrgID int64 `json:"orgID"`
@@ -81,6 +81,10 @@ type ContactPoints []EmbeddedContactPoint
type EmbeddedContactPoint struct {
// UID is the unique identifier of the contact point. The UID can be
// set by the user.
// required: false
// minLength: 1
// maxLength: 40
// pattern: ^[a-zA-Z0-9\-\_]+$
// example: my_external_reference
UID string `json:"uid"`
// Name is used as grouping key in the UI. Contact points with the
@@ -764,6 +764,9 @@
"uid": {
"description": "UID is the unique identifier of the contact point. The UID can be\nset by the user.",
"example": "my_external_reference",
"maxLength": 40,
"minLength": 1,
"pattern": "^[a-zA-Z0-9\\-\\_]+$",
"type": "string"
}
},
@@ -2663,6 +2666,9 @@
"type": "string"
},
"uid": {
"maxLength": 40,
"minLength": 1,
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"updated": {
+7 -1
View File
@@ -3625,6 +3625,9 @@
"uid": {
"description": "UID is the unique identifier of the contact point. The UID can be\nset by the user.",
"type": "string",
"maxLength": 40,
"minLength": 1,
"pattern": "^[a-zA-Z0-9\\-\\_]+$",
"example": "my_external_reference"
}
}
@@ -5534,7 +5537,10 @@
"example": "Always firing"
},
"uid": {
"type": "string"
"type": "string",
"maxLength": 40,
"minLength": 1,
"pattern": "^[a-zA-Z0-9-_]+$"
},
"updated": {
"type": "string",