added validation for headless templates (#2423)

* added validation for headless templates

* minor update in log msg
dev
Sami 2022-08-17 08:10:27 -05:00 committed by GitHub
parent 9e531727a7
commit d14c00fc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -267,8 +267,12 @@ func (store *Store) LoadTemplates(templatesList []string) []*templates.Template
stats.Increment(parsers.RuntimeWarningsStats)
gologger.Warning().Msgf("Could not parse template %s: %s\n", templatePath, err)
} else if parsed != nil {
if len(parsed.RequestsHeadless) > 0 && !store.config.ExecutorOptions.Options.Headless {
gologger.Warning().Msgf("Headless flag is required for headless template %s\n", templatePath)
} else {
loadedTemplates = append(loadedTemplates, parsed)
}
}
} else if err != nil {
gologger.Warning().Msgf("Could not load template %s: %s\n", templatePath, err)
}
@ -314,8 +318,12 @@ func (store *Store) LoadTemplatesWithTags(templatesList, tags []string) []*templ
stats.Increment(parsers.RuntimeWarningsStats)
gologger.Warning().Msgf("Could not parse template %s: %s\n", templatePath, err)
} else if parsed != nil {
if len(parsed.RequestsHeadless) > 0 && !store.config.ExecutorOptions.Options.Headless {
gologger.Warning().Msgf("Headless flag is required for headless template %s\n", templatePath)
} else {
loadedTemplates = append(loadedTemplates, parsed)
}
}
} else if err != nil {
gologger.Warning().Msgf("Could not load template %s: %s\n", templatePath, err)
}