From 1b97ed3ca759a530585a520c8edd01e26bdee582 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 5 Jul 2026 10:48:52 +0300 Subject: initial work for a central applier algo --- internal/resource/file/file.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'internal/resource/file/file.go') diff --git a/internal/resource/file/file.go b/internal/resource/file/file.go index 6395403..5a2453e 100644 --- a/internal/resource/file/file.go +++ b/internal/resource/file/file.go @@ -15,13 +15,14 @@ import ( ) type File struct { - path string - content string - source string // bare path, no "source://" prefix - user string - group string - mode os.FileMode - absent bool + resource resource.Resource + path string + content string + source string // bare path, no "source://" prefix + user string + group string + mode os.FileMode + absent bool } // SetContent implements opt.Contented. Setting literal content clears any @@ -223,13 +224,14 @@ func Have(path string, opts ...opt.Option) resource.Resource { log.Fatalf("failed to apply file resource %s: %v", path, err) } - res := resource.Register("File", f.targetPath()) + f.resource = resource.Register("File", f.targetPath(), + resource.ApplierFunc(func() error { return f.apply() })) if err := f.apply(); err != nil { log.Fatalf("failed to apply file resource %s: %v", path, err) } - return res + return f.resource } func Absent(path string, opts ...opt.Option) resource.Resource { -- cgit v1.2.3