diff --git a/engine/resources/file.go b/engine/resources/file.go index 47d3304c..f704517c 100644 --- a/engine/resources/file.go +++ b/engine/resources/file.go @@ -130,6 +130,10 @@ func (obj *FileRes) Validate() error { return fmt.Errorf("the State is invalid") } + if obj.State == FileStateAbsent && obj.Content != nil { + return fmt.Errorf("can't specify content for an absent file") + } + if obj.Mode != "" { if _, err := obj.mode(); err != nil { return err diff --git a/test/shell/t2.yaml b/test/shell/t2.yaml index 09bfcca8..98be0930 100644 --- a/test/shell/t2.yaml +++ b/test/shell/t2.yaml @@ -21,8 +21,6 @@ resources: state: exists - name: file4 path: "/tmp/mgmt/f4" - content: | - i am f4 and i should not be here state: absent - name: dir1 path: "/tmp/mgmt/dir1/" diff --git a/test/shell/t6.yaml b/test/shell/t6.yaml index f69394ee..295dc5c1 100644 --- a/test/shell/t6.yaml +++ b/test/shell/t6.yaml @@ -21,8 +21,6 @@ resources: state: exists - name: file4 path: "/tmp/mgmt/f4" - content: | - i am f4 and i should not be here state: absent edges: - name: e1