diff --git a/pkg/grizzly/embed/templates/proxy/index.html.tmpl b/pkg/grizzly/embed/templates/proxy/index.html.tmpl index c83a6e75..641e48a7 100644 --- a/pkg/grizzly/embed/templates/proxy/index.html.tmpl +++ b/pkg/grizzly/embed/templates/proxy/index.html.tmpl @@ -8,16 +8,17 @@ {{ template "proxy/header.html.tmpl" . }} -
{{ if ne (len .ParseErrors) 0 }}

Errors

{{ range .ParseErrors }} + {{ if not (IsWarning .) }}
  • {{ . }}
  • + {{ end }} {{ end }} {{ end }}

    Available dashboards

    diff --git a/pkg/grizzly/errors.go b/pkg/grizzly/errors.go index bed533ff..ba2d3c4d 100644 --- a/pkg/grizzly/errors.go +++ b/pkg/grizzly/errors.go @@ -39,3 +39,20 @@ func NewUnrecognisedFormatError(file string) UnrecognisedFormatError { File: file, } } + +type Warning struct { + Err error +} + +func NewWarning(err error) Warning { + return Warning{err} +} + +func (w Warning) Error() string { + return w.Err.Error() +} + +func IsWarning(err any) bool { + _, ok := err.(Warning) + return ok +} diff --git a/pkg/grizzly/parsing.go b/pkg/grizzly/parsing.go index 2def807d..4b172501 100644 --- a/pkg/grizzly/parsing.go +++ b/pkg/grizzly/parsing.go @@ -161,7 +161,7 @@ func (parser *ChainParser) parseFile(file string, options ParserOptions) (Resour return resources, nil } - return Resources{}, NewUnrecognisedFormatError(file) + return Resources{}, NewWarning(NewUnrecognisedFormatError(file)) } func parseAny(registry Registry, data any, resourceKind, folderUID string, source Source) (Resources, error) { diff --git a/pkg/grizzly/tmpl.go b/pkg/grizzly/tmpl.go index e0722101..b29ac838 100644 --- a/pkg/grizzly/tmpl.go +++ b/pkg/grizzly/tmpl.go @@ -44,7 +44,11 @@ func findAndParseTemplates(vfs fs.FS, rootTmpl *template.Template, rootDir strin } templateName := strings.TrimPrefix(strings.TrimPrefix(path, rootDir), "/") - t := rootTmpl.New(templateName) + t := rootTmpl.New(templateName).Funcs( + template.FuncMap{ + "IsWarning": IsWarning, + }, + ) _, err = t.Parse(string(contents)) return err