summaryrefslogtreecommitdiff
path: root/internal/resource/link/link.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-09 00:14:33 +0300
committerPaul Buetow <paul@buetow.org>2026-07-09 00:14:33 +0300
commit756ae621bd97a8b776fefb15e5e7e2292f98ee45 (patch)
treeb454f958e6aef70bf7ca40dcbc106323cee2a42f /internal/resource/link/link.go
parent3f8b79f2b1384e3abc2b1bb2fe913688c7ec251c (diff)
dependencies
Diffstat (limited to 'internal/resource/link/link.go')
-rw-r--r--internal/resource/link/link.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/resource/link/link.go b/internal/resource/link/link.go
index b40ce65..836a925 100644
--- a/internal/resource/link/link.go
+++ b/internal/resource/link/link.go
@@ -7,6 +7,7 @@ import (
opt "codeberg.org/snonux/gonf/api/options"
"codeberg.org/snonux/gonf/internal/resource"
+ "codeberg.org/snonux/gonf/internal/resource/embed"
)
type kind int
@@ -18,11 +19,12 @@ const (
)
type Link struct {
+ embed.DependsOn
+ embed.Absence
resource resource.Resource
path string
target string
kind kind
- absent bool
}
// SetSymlink implements opt.Linkable.
@@ -37,9 +39,6 @@ func (l *Link) SetHardlink(target string) {
l.target = target
}
-// SetAbsent implements opt.Absentable.
-func (l *Link) SetAbsent() { l.absent = true }
-
func build(path string, opts ...opt.Option) *Link {
l := &Link{path: path}
for _, o := range opts {
@@ -54,7 +53,7 @@ func build(path string, opts ...opt.Option) *Link {
// was validated.
func (l *Link) apply() error {
switch {
- case l.absent:
+ case l.Absent:
return ensureAbsent(l.path)
case l.kind == symlinkKind:
return ensureSymlink(l)
@@ -89,7 +88,7 @@ func Ensure(path string, opts ...opt.Option) error {
func Present(path string, opts ...opt.Option) resource.Resource {
l := build(path, opts...)
l.resource = resource.Register(l.resourceType(), l.path,
- resource.ApplierFunc(func() error { return l.apply() }))
+ resource.ApplierFunc(func() error { return l.apply() }), l.DependsOn.IDs...)
return l.resource
}