From 49c93333592fa09d472edbcc847f28dad04cc682 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 8 Nov 2025 13:08:48 -0500 Subject: [PATCH] fix(data): add services folder to embedded filesystem (#1259) * fix(data): add services folder to embedded filesystem Also includes a regression test to ensure this does not happen again. Assisted-By: GLM 4.6 via Claude Code * docs: update CHANGELOG Signed-off-by: Xe Iaso --------- Signed-off-by: Xe Iaso --- data/embed.go | 2 +- data/embed_test.go | 38 ++++++++++++++++++++++++++++++++++++++ docs/docs/CHANGELOG.md | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 data/embed_test.go diff --git a/data/embed.go b/data/embed.go index bef617a1..f75646ee 100644 --- a/data/embed.go +++ b/data/embed.go @@ -3,6 +3,6 @@ package data import "embed" var ( - //go:embed botPolicies.yaml all:apps all:bots all:clients all:common all:crawlers all:meta + //go:embed botPolicies.yaml all:apps all:bots all:clients all:common all:crawlers all:meta all:services BotPolicies embed.FS ) diff --git a/data/embed_test.go b/data/embed_test.go new file mode 100644 index 00000000..346ff659 --- /dev/null +++ b/data/embed_test.go @@ -0,0 +1,38 @@ +package data + +import ( + "path/filepath" + "strings" + "testing" +) + +// TestBotPoliciesEmbed ensures all YAML files in the directory tree +// are accessible in the embedded BotPolicies filesystem. +func TestBotPoliciesEmbed(t *testing.T) { + yamlFiles, err := filepath.Glob("./**/*.yaml") + if err != nil { + t.Fatalf("Failed to glob YAML files: %v", err) + } + + if len(yamlFiles) == 0 { + t.Fatal("No YAML files found in directory tree") + } + + t.Logf("Found %d YAML files to verify", len(yamlFiles)) + + for _, filePath := range yamlFiles { + embeddedPath := strings.TrimPrefix(filePath, "./") + + t.Run(embeddedPath, func(t *testing.T) { + content, err := BotPolicies.ReadFile(embeddedPath) + if err != nil { + t.Errorf("Failed to read %s from embedded filesystem: %v", embeddedPath, err) + return + } + + if len(content) == 0 { + t.Errorf("File %s exists in embedded filesystem but is empty", embeddedPath) + } + }) + } +} diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 8188da88..52c4c09b 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Allow more OCI registry clients [based on feedback](https://github.com/TecharoHQ/anubis/pull/1253#issuecomment-3506744184). +- Expose services directory in the embedded `(data)` filesystem. ## v1.23.1: Lyse Hext - Echo 1