summaryrefslogtreecommitdiff
path: root/internal/resource/file
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-05 10:48:52 +0300
committerPaul Buetow <paul@buetow.org>2026-07-05 10:48:52 +0300
commit1b97ed3ca759a530585a520c8edd01e26bdee582 (patch)
tree02cc4abd4374a515a2ac9df592144839bbc148b4 /internal/resource/file
parent7fdcb5ed7639508e05c9a3851704cf1de9f4476a (diff)
initial work for a central applier algo
Diffstat (limited to 'internal/resource/file')
-rw-r--r--internal/resource/file/file.go20
1 files changed, 11 insertions, 9 deletions
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 {