engine: resources: Add another validation check

This simple check should prevent some silly mistakes and make the logic
easier for other parts of the code that won't have to worry about this
pattern.
This commit is contained in:
James Shubin
2019-09-08 04:43:56 -04:00
parent 0c9e8cc50e
commit 9788411995
3 changed files with 4 additions and 4 deletions

View File

@@ -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