summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-07 00:17:27 +0300
committerPaul Buetow <paul@buetow.org>2026-07-07 00:17:27 +0300
commitab6e1341dc5eb06b6573571f8c17e19d0c393418 (patch)
treef9aa00bf0cf3ab302ecb2d152f7e781793112ba5 /api
parent62ff4e782bc057d277a7c41fa35a665e2aeca045 (diff)
can manage dnf packages
Diffstat (limited to 'api')
-rw-r--r--api/api.go13
-rw-r--r--api/options/option.go12
2 files changed, 22 insertions, 3 deletions
diff --git a/api/api.go b/api/api.go
index 6e25151..043b693 100644
--- a/api/api.go
+++ b/api/api.go
@@ -5,6 +5,7 @@ import (
"codeberg.org/snonux/gonf/internal/resource/dir"
"codeberg.org/snonux/gonf/internal/resource/file"
"codeberg.org/snonux/gonf/internal/resource/link"
+ "codeberg.org/snonux/gonf/internal/resource/pkg"
)
// File creates a file resource.
@@ -37,6 +38,12 @@ func NoLink(path string, opts ...options.Option) Resource {
return link.Absent(path, opts...)
}
-// func Package(name string, ...options.Options) Resource {
-// return pkg.Present(name, opts...)
-// }
+// Package creates a package resource.
+func Package(name string, opts ...options.Option) Resource {
+ return pkg.Present(name, opts...)
+}
+
+// NoPackage creates a package resource that is ensured to be absent.
+func NoPackage(name string, opts ...options.Option) Resource {
+ return pkg.Absent(name, opts...)
+}
diff --git a/api/options/option.go b/api/options/option.go
index fcffccd..1d9b931 100644
--- a/api/options/option.go
+++ b/api/options/option.go
@@ -21,6 +21,7 @@ type (
FileModed interface{ SetFileMode(os.FileMode) }
Prunable interface{ SetPrune() }
Absentable interface{ SetAbsent() }
+ Latestable interface{ SetLatest() }
Linkable interface {
SetSymlink(target string)
SetHardlink(target string)
@@ -117,6 +118,17 @@ var IsAbsent = func(t any) {
func IsAbsentFunc() Option { return IsAbsent }
+// IsLatest marks the package resource to be updated to the latest version.
+var IsLatest = func(t any) {
+ r, ok := t.(Latestable)
+ if !ok {
+ log.Fatalf("%T does not support IsLatest", t)
+ }
+ r.SetLatest()
+}
+
+func IsLatestFunc() Option { return IsLatest }
+
// WithSymlink makes the resource a symbolic link pointing at target.
func WithSymlink(target string) Option {
return func(t any) {