diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-06 23:05:48 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-06 23:05:48 +0300 |
| commit | 5600bedb927e291e2e78e6140de256e1a1d4475c (patch) | |
| tree | af19c6b484135afed332a8e3fcda7e8ded5ac4b8 /api | |
| parent | f7498c9ae626b9ab654fe6eb736e19c62cf5d38d (diff) | |
refactor
Diffstat (limited to 'api')
| -rw-r--r-- | api/api.go | 15 | ||||
| -rw-r--r-- | api/options/option.go (renamed from api/option/option.go) | 2 | ||||
| -rw-r--r-- | api/resource.go | 17 |
3 files changed, 25 insertions, 9 deletions
@@ -1,39 +1,38 @@ package api import ( - "codeberg.org/snonux/gonf/api/option" - "codeberg.org/snonux/gonf/internal/resource" + "codeberg.org/snonux/gonf/api/options" "codeberg.org/snonux/gonf/internal/resource/dir" "codeberg.org/snonux/gonf/internal/resource/file" "codeberg.org/snonux/gonf/internal/resource/link" ) // File creates a file resource. -func File(path string, opts ...option.Option) resource.Resource { +func File(path string, opts ...options.Option) Resource { return file.Present(path, opts...) } // NoFile creates a file resource that is ensured to be absent. -func NoFile(path string, opts ...option.Option) resource.Resource { +func NoFile(path string, opts ...options.Option) Resource { return file.Absent(path, opts...) } // Dir creates a directory resource. -func Dir(path string, opts ...option.Option) resource.Resource { +func Dir(path string, opts ...options.Option) Resource { return dir.Present(path, opts...) } // NoDir creates a directory resource that is ensured to be absent. -func NoDir(path string, opts ...option.Option) resource.Resource { +func NoDir(path string, opts ...options.Option) Resource { return dir.Absent(path, opts...) } // Link creates a link resource (symbolic or hard). -func Link(path string, opts ...option.Option) resource.Resource { +func Link(path string, opts ...options.Option) Resource { return link.Present(path, opts...) } // NoLink creates a link resource that is ensured to be absent. -func NoLink(path string, opts ...option.Option) resource.Resource { +func NoLink(path string, opts ...options.Option) Resource { return link.Absent(path, opts...) } diff --git a/api/option/option.go b/api/options/option.go index b5d2531..1c757c4 100644 --- a/api/option/option.go +++ b/api/options/option.go @@ -1,6 +1,6 @@ // Package option provides interface-based, resource-agnostic configuration // options shared by the file, dir, and link resource packages. -package option +package options import ( "log" diff --git a/api/resource.go b/api/resource.go new file mode 100644 index 0000000..e254e1b --- /dev/null +++ b/api/resource.go @@ -0,0 +1,17 @@ +package api + +import ( + internal "codeberg.org/snonux/gonf/internal/resource" +) + +// Resource represents a system resource managed by gonfs. +// It is an interface to hide the internal implementation details +// of the resource registry. +type Resource interface { + ID() string + String() string +} + +func Apply() error { + return internal.Apply() +} |
