Generalize distributor report path rendering
This commit is contained in:
@@ -123,26 +123,8 @@ func traverseReportDistributorPathOverrides(cfg Config) (map[report.ID][]string,
|
||||
|
||||
func validateReportDistributorPathTemplates(reportKey string, templates []string) error {
|
||||
name := fmt.Sprintf("reports.%s.distributor.path_templates", reportKey)
|
||||
if len(templates) == 0 {
|
||||
return fmt.Errorf("%s must contain at least one entry", name)
|
||||
}
|
||||
values := sampleDistributorTemplateValues()
|
||||
seen := map[string]struct{}{}
|
||||
for i, template := range templates {
|
||||
itemName := fmt.Sprintf("%s[%d]", name, i)
|
||||
rendered, err := renderDistributorTemplate(itemName, template, values, distributorTemplateVariables)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ValidateDistributorReportPath(itemName, rendered); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := seen[rendered]; ok {
|
||||
return fmt.Errorf("%s renders duplicate path %q", name, rendered)
|
||||
}
|
||||
seen[rendered] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
_, err := RenderDistributorReportPaths(name, templates, sampleDistributorTemplateValues())
|
||||
return err
|
||||
}
|
||||
|
||||
func sampleDistributorTemplateValues() DistributorTemplateValues {
|
||||
@@ -158,6 +140,7 @@ func sampleDistributorTemplateValues() DistributorTemplateValues {
|
||||
ValidEndTime: "0000",
|
||||
ValidStartStamp: "2026-05-29T0000",
|
||||
ValidEndStamp: "2026-05-30T0000",
|
||||
StormID: "2026-05-29T0000-2026-05-30T0000",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user