feat: add support for running CoreDNS as a Windows service (#7962)

* feat: add support for running CoreDNS as a Windows service

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* Use non-deprecated service check function.

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* refactor: remove deprecated build tags and clean up imports in service files

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* ci: add Windows test workflow and fix log field access in service_windows.go

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* test: implement cross-platform file permission restriction for Windows compatibility in run_test.go

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* refactor: remove Windows-specific icacls test logic and restrict unreadable file test to non-Windows platforms

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

* docs: add documentation for -windows-service flag in man page

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>

---------

Signed-off-by: John-Michael Mulesa <jmulesa@gmail.com>
This commit is contained in:
John-Michael Mulesa
2026-03-26 15:10:53 -04:00
committed by GitHub
parent 12131b7455
commit 1c15569168
6 changed files with 117 additions and 15 deletions

View File

@@ -149,21 +149,23 @@ func TestDefaultLoader(t *testing.T) {
}
}
// Create a file but make it unreadable
tmpFile := filepath.Join(tmpDir, "Corefile")
if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil {
t.Fatalf("Failed to create test file: %v", err)
}
if err := os.Chmod(tmpFile, 0000); err != nil {
t.Fatalf("Failed to change permissions: %v", err)
}
if runtime.GOOS != "windows" {
// Create a file but make it unreadable
tmpFile := filepath.Join(tmpDir, "Corefile")
if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil {
t.Fatalf("Failed to create test file: %v", err)
}
if err := os.Chmod(tmpFile, 0000); err != nil {
t.Fatalf("Failed to change permissions: %v", err)
}
input, err = defaultLoader("dns")
if err == nil {
t.Error("Expected error for unreadable Corefile but got none")
}
if input != nil {
t.Error("Expected nil input for unreadable Corefile")
input, err = defaultLoader("dns")
if err == nil {
t.Error("Expected error for unreadable Corefile but got none")
}
if input != nil {
t.Error("Expected nil input for unreadable Corefile")
}
}
}