fix(auto): resolve symlinked directory before walk (#8032)

This commit is contained in:
Ville Vesilehto
2026-04-09 00:38:01 +03:00
committed by GitHub
parent 489a4f8703
commit 4c71636a71
3 changed files with 51 additions and 1 deletions

View File

@@ -45,6 +45,41 @@ func TestWalk(t *testing.T) {
}
}
func TestWalkSymlinkedDirectory(t *testing.T) {
t.Parallel()
tempdir, err := createFiles(t)
if err != nil {
t.Fatal(err)
}
// Create a symlink to the directory containing zone files,
// simulating a Kubernetes ConfigMap mount where the directory
// itself is a symlink.
symlinkDir := filepath.Join(t.TempDir(), "zones")
if err := os.Symlink(tempdir, symlinkDir); err != nil {
t.Fatal(err)
}
ldr := loader{
directory: symlinkDir,
re: regexp.MustCompile(`db\.(.*)`),
template: `${1}`,
}
a := Auto{
loader: ldr,
Zones: &Zones{},
}
a.Walk()
for _, name := range []string{"example.com.", "example.org."} {
if _, ok := a.Z[name]; !ok {
t.Errorf("%s should have been added when directory is a symlink", name)
}
}
}
func TestWalkNonExistent(t *testing.T) {
t.Parallel()
nonExistingDir := "highly_unlikely_to_exist_dir"