diff --git a/base/v0_6_exp/validate.go b/base/v0_6_exp/validate.go index 70874df5..715043a9 100644 --- a/base/v0_6_exp/validate.go +++ b/base/v0_6_exp/validate.go @@ -27,37 +27,33 @@ import ( func (rs Resource) Validate(c path.ContextPath) (r report.Report) { var field string sources := 0 - if rs.Local != nil { + var config string + switch { + case rs.Local != nil: sources++ field = "local" - config := *rs.Local - _, report, err := exp.Parse([]byte(config)) - if err != nil { - r.Merge(report) - } else { - r.AddOnError(c.Append("ignition", "config", "merge", "local"), common.ErrEmptyReport) - } - } - if rs.Inline != nil { + config = *rs.Local + case rs.Inline != nil: sources++ field = "inline" - config := *rs.Inline - _, report, err := exp.Parse([]byte(config)) - if err != nil { - r.Merge(report) - } else { - r.AddOnError(c.Append("ignition", "config", "merge", "local"), common.ErrEmptyReport) - } - } - if rs.Source != nil { + config = *rs.Inline + case rs.Source != nil: sources++ field = "source" } if sources > 1 { r.AddOnError(c.Append(field), common.ErrTooManyResourceSources) + } else { + if field == "local" || field == "inline" { + _, report, err := exp.Parse([]byte(config)) + if len(report.Entries) > 0 { + r.Merge(report) + } else { + r.AddOnWarn(c.Append("ignition", "config", "merge", field), err) + } + } } - - return r + return } func (fs Filesystem) Validate(c path.ContextPath) (r report.Report) {