diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-05 10:48:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-05 10:48:52 +0300 |
| commit | 1b97ed3ca759a530585a520c8edd01e26bdee582 (patch) | |
| tree | 02cc4abd4374a515a2ac9df592144839bbc148b4 /internal/resource/link/link.go | |
| parent | 7fdcb5ed7639508e05c9a3851704cf1de9f4476a (diff) | |
initial work for a central applier algo
Diffstat (limited to 'internal/resource/link/link.go')
| -rw-r--r-- | internal/resource/link/link.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/resource/link/link.go b/internal/resource/link/link.go index f9c6c8d..5f8e345 100644 --- a/internal/resource/link/link.go +++ b/internal/resource/link/link.go @@ -18,10 +18,11 @@ const ( ) type Link struct { - path string - target string - kind kind - absent bool + resource resource.Resource + path string + target string + kind kind + absent bool } // SetSymlink implements opt.Linkable. @@ -87,13 +88,14 @@ func Ensure(path string, opts ...opt.Option) error { func Have(path string, opts ...opt.Option) resource.Resource { l := build(path, opts...) - res := resource.Register(l.resourceType(), l.path) + l.resource = resource.Register(l.resourceType(), l.path, + resource.ApplierFunc(func() error { return l.apply() })) if err := l.apply(); err != nil { log.Fatalf("failed to apply link resource %s: %v", path, err) } - return res + return l.resource } func Absent(path string, opts ...opt.Option) resource.Resource { |
