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:
Yuriy Tseretyan
2022-06-30 11:46:26 -04:00
committed by GitHub
parent 0e7a495829
commit 8b3b667a47
13 changed files with 104 additions and 35 deletions
+2 -1
View File
@@ -87,9 +87,10 @@ func getBody(t *testing.T, body io.ReadCloser) string {
func alertRuleGen() func() apimodels.PostableExtendedRuleNode {
return func() apimodels.PostableExtendedRuleNode {
forDuration := model.Duration(10 * time.Second)
return apimodels.PostableExtendedRuleNode{
ApiRuleNode: &apimodels.ApiRuleNode{
For: model.Duration(10 * time.Second),
For: &forDuration,
Labels: map[string]string{"label1": "val1"},
Annotations: map[string]string{"annotation1": "val1"},
},