Alerting: Export rule validation logic and make it portable (#83555)

* ValidateInterval doesn't need the entire config

* Validation no longer depends on entire folder now that we've dropped foldertitle from api

* Don't depend on entire config struct

* Export validate group
This commit is contained in:
Alexander Weaver
2024-02-28 14:40:13 -06:00
committed by GitHub
parent af528d2f66
commit a862a4264d
5 changed files with 46 additions and 33 deletions
+3 -3
View File
@@ -66,8 +66,8 @@ func (srv TestingApiSrv) RouteTestGrafanaRuleConfig(c *contextmodel.ReqContext,
body.RuleGroup,
srv.cfg.BaseInterval,
c.SignedInUser.GetOrgID(),
folder,
srv.cfg,
folder.UID,
RuleLimitsFromConfig(srv.cfg),
)
if err != nil {
return ErrResp(http.StatusBadRequest, err, "")
@@ -238,7 +238,7 @@ func (srv TestingApiSrv) BacktestAlertRule(c *contextmodel.ReqContext, cmd apimo
return ErrResp(400, nil, "Bad For interval")
}
intervalSeconds, err := validateInterval(srv.cfg, time.Duration(cmd.Interval))
intervalSeconds, err := validateInterval(time.Duration(cmd.Interval), srv.cfg.BaseInterval)
if err != nil {
return ErrResp(400, err, "")
}