mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix rule API to accept 0 duration of field For (#50992)
* make 'for' pointer to distinguish between missing field and 0 * set 'for' to -1 if the value is missing but not allow negative in the request + path -1 with the value from original rule * update store validation to not allow negative 'for' * update usages to use pointer
This commit is contained in:
@@ -388,7 +388,7 @@ func PatchPartialAlertRule(existingRule *AlertRule, ruleToPatch *AlertRule) {
|
||||
if ruleToPatch.NoDataState == "" {
|
||||
ruleToPatch.NoDataState = existingRule.NoDataState
|
||||
}
|
||||
if ruleToPatch.For == 0 {
|
||||
if ruleToPatch.For == -1 {
|
||||
ruleToPatch.For = existingRule.For
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +113,9 @@ func TestPatchPartialAlertRule(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "For is 0",
|
||||
name: "For is -1",
|
||||
mutator: func(r *AlertRule) {
|
||||
r.For = 0
|
||||
r.For = -1
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user