summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/api.go15
-rw-r--r--api/options/option.go (renamed from api/option/option.go)2
-rw-r--r--api/resource.go17
3 files changed, 25 insertions, 9 deletions
diff --git a/api/api.go b/api/api.go
index f4ec70e..ea30363 100644
--- a/api/api.go
+++ b/api/api.go
@@ -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()
+}