@@ -2,6 +2,7 @@ package observe
22
33import (
44 "bytes"
5+ "embed"
56 "fmt"
67 "net/http"
78 "os"
@@ -21,11 +22,13 @@ import (
2122 "github.com/kalverra/octometrics/gather"
2223)
2324
25+ //go:embed templates/*.html templates/*.md
26+ var templateFS embed.FS
27+
2428const (
2529 OutputDir = "observe_output"
2630 htmlOutputDir = "observe_output/html"
2731 markdownOutputDir = "observe_output/md"
28- templatesDir = "observe/templates"
2932)
3033
3134var (
@@ -41,15 +44,15 @@ func init() {
4144 htmlTemplate , err = template .New ("observation_html" ).Funcs (template.FuncMap {
4245 "sanitizeMermaidName" : sanitizeMermaidName ,
4346 "commitRunLink" : commitRunLink ,
44- }).ParseGlob ( filepath . Join ( templatesDir , "*.html" ) )
47+ }).ParseFS ( templateFS , "templates/ *.html" )
4548 if err != nil {
4649 panic (fmt .Errorf ("failed to parse HTML templates: %w" , err ))
4750 }
4851
4952 // Initialize Markdown template
5053 mdTemplate , err = template .New ("observation_md" ).Funcs (template.FuncMap {
5154 "sanitizeMermaidName" : sanitizeMermaidName ,
52- }).ParseGlob ( filepath . Join ( templatesDir , "*.md" ) )
55+ }).ParseFS ( templateFS , "templates/ *.md" )
5356 if err != nil {
5457 panic (fmt .Errorf ("failed to parse Markdown templates: %w" , err ))
5558 }
0 commit comments