diff options
| -rw-r--r-- | internal/resource/dir/dir.go | 11 | ||||
| -rw-r--r-- | internal/resource/file/file.go | 11 | ||||
| -rw-r--r-- | internal/resource/link/link.go | 7 |
3 files changed, 6 insertions, 23 deletions
diff --git a/internal/resource/dir/dir.go b/internal/resource/dir/dir.go index 047a591..1934272 100644 --- a/internal/resource/dir/dir.go +++ b/internal/resource/dir/dir.go @@ -180,11 +180,8 @@ func applyAttributesTo(path string, mode os.FileMode, usr, group string) error { // Ensure builds and applies the directory resource described by opts, // without registering it. func Ensure(path string, opts ...opt.Option) error { - d, err := build(path, opts...) - if err != nil { - return err - } - return d.apply() + _, err := build(path, opts...) + return err } func Have(path string, opts ...opt.Option) resource.Resource { @@ -196,10 +193,6 @@ func Have(path string, opts ...opt.Option) resource.Resource { d.resource = resource.Register("Directory", d.path, resource.ApplierFunc(func() error { return d.apply() })) - if err := d.apply(); err != nil { - log.Fatalf("failed to apply directory resource %s: %v", path, err) - } - return d.resource } diff --git a/internal/resource/file/file.go b/internal/resource/file/file.go index 5a2453e..ea443a9 100644 --- a/internal/resource/file/file.go +++ b/internal/resource/file/file.go @@ -211,11 +211,8 @@ func ensureAbsent(path string) error { // registering it. Used by other resource packages (e.g. dir) to write an // individual file without it becoming its own top-level resource. func Ensure(path string, opts ...opt.Option) error { - f, err := build(path, opts...) - if err != nil { - return err - } - return f.apply() + _, err := build(path, opts...) + return err } func Have(path string, opts ...opt.Option) resource.Resource { @@ -227,10 +224,6 @@ func Have(path string, opts ...opt.Option) resource.Resource { 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 f.resource } diff --git a/internal/resource/link/link.go b/internal/resource/link/link.go index 5f8e345..8600166 100644 --- a/internal/resource/link/link.go +++ b/internal/resource/link/link.go @@ -83,7 +83,8 @@ func (l *Link) resourceType() string { // registering it. Used by other resource packages (e.g. dir) to recreate an // individual symlink without it becoming its own top-level resource. func Ensure(path string, opts ...opt.Option) error { - return build(path, opts...).apply() + build(path, opts...) + return nil } func Have(path string, opts ...opt.Option) resource.Resource { @@ -91,10 +92,6 @@ func Have(path string, opts ...opt.Option) resource.Resource { 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 l.resource } |
