Skip to content

Commit ac5ef72

Browse files
committed
Embed templates
1 parent 5df75dd commit ac5ef72

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.github/workflows/lint-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
test:
14-
name: Run Tests
14+
name: Test
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout code

observe/observe.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package observe
22

33
import (
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+
2428
const (
2529
OutputDir = "observe_output"
2630
htmlOutputDir = "observe_output/html"
2731
markdownOutputDir = "observe_output/md"
28-
templatesDir = "observe/templates"
2932
)
3033

3134
var (
@@ -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

Comments
 (0)