From 5058f286c6509784b893900b2c457cb13f6eb77e Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Wed, 23 Aug 2023 19:14:56 +0000 Subject: [PATCH] zones: switch to using hackpadfs/os.FS as the standard os.FS is incomplete Signed-off-by: Alejandro Mery --- go.mod | 1 + go.sum | 2 ++ pkg/zones/zones.go | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 49ad042..99d727f 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( darvaza.org/sidecar v0.0.0-20230721122716-b9c54b8adbaf darvaza.org/slog v0.5.2 github.com/burntSushi/toml v0.3.1 + github.com/hack-pad/hackpadfs v0.2.1 github.com/mgechev/revive v1.3.2 github.com/spf13/cobra v1.7.0 golang.org/x/crypto v0.12.0 diff --git a/go.sum b/go.sum index 8808128..dca0c91 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,8 @@ github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBD github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/hack-pad/hackpadfs v0.2.1 h1:FelFhIhv26gyjujoA/yeFO+6YGlqzmc9la/6iKMIxMw= +github.com/hack-pad/hackpadfs v0.2.1/go.mod h1:khQBuCEwGXWakkmq8ZiFUvUZz84ZkJ2KNwKvChs4OrU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= diff --git a/pkg/zones/zones.go b/pkg/zones/zones.go index 30bee91..817fd97 100644 --- a/pkg/zones/zones.go +++ b/pkg/zones/zones.go @@ -3,7 +3,8 @@ package zones import ( "io/fs" - "os" + + "github.com/hack-pad/hackpadfs/os" "darvaza.org/resolver" ) @@ -104,5 +105,10 @@ func NewFS(dir fs.FS, domain string) (*Zones, error) { // New builds a [Zones] tree using the given directory func New(dir, domain string) (*Zones, error) { - return NewFS(os.DirFS(dir), domain) + base, err := os.NewFS().Sub(dir) + if err != nil { + return nil, err + } + + return NewFS(base, domain) }