From d14c00fc6f277477792a28b01520c001990aa5ce Mon Sep 17 00:00:00 2001 From: Sami <85764322+LuitelSamikshya@users.noreply.github.com> Date: Wed, 17 Aug 2022 08:10:27 -0500 Subject: [PATCH] added validation for headless templates (#2423) * added validation for headless templates * minor update in log msg --- v2/pkg/catalog/loader/loader.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/v2/pkg/catalog/loader/loader.go b/v2/pkg/catalog/loader/loader.go index a1679cbd..87b54c25 100644 --- a/v2/pkg/catalog/loader/loader.go +++ b/v2/pkg/catalog/loader/loader.go @@ -267,7 +267,11 @@ 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 { - loadedTemplates = append(loadedTemplates, parsed) + 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,7 +318,11 @@ 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 { - loadedTemplates = append(loadedTemplates, parsed) + 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)