AlertingNG: Enforce unique alert definition title (non empty)/UID per organisation (#30380)

* Enforce unique alert definition title/uid per org

* Remove print statement from test

* Do not allow empty alert definition titles

* update error message on dup title

* also add title error to update

* CamelCase json properties

* Add test for title unique enforcement in updates

Co-authored-by: kyle <kyle@grafana.com>
This commit is contained in:
Sofia Papagiannaki
2021-01-19 19:11:11 +02:00
committed by GitHub
co-authored by kyle
parent 2a55e00c78
commit b1debc9c46
8 changed files with 146 additions and 29 deletions
+8 -8
View File
@@ -63,14 +63,14 @@ type listAlertInstancesQuery struct {
// listAlertInstancesQueryResult represents the result of listAlertInstancesQuery.
type listAlertInstancesQueryResult struct {
DefinitionOrgID int64 `xorm:"def_org_id"`
DefinitionUID string `xorm:"def_uid"`
DefinitionTitle string `xorm:"def_title"`
Labels InstanceLabels
LabelsHash string
CurrentState InstanceStateType
CurrentStateSince time.Time
LastEvalTime time.Time
DefinitionOrgID int64 `xorm:"def_org_id" json:"definitionOrgId"`
DefinitionUID string `xorm:"def_uid" json:"definitionUid"`
DefinitionTitle string `xorm:"def_title" json:"definitionTitle"`
Labels InstanceLabels `json:"labels"`
LabelsHash string `json:"labeHash"`
CurrentState InstanceStateType `json:"currentState"`
CurrentStateSince time.Time `json:"currentStateSince"`
LastEvalTime time.Time `json:"lastEvalTime"`
}
// validateAlertInstance validates that the alert instance contains an alert definition id,