Commit 28dc1c2a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template: validate post-processor only/except

parent 637fabc1
......@@ -109,6 +109,19 @@ func (t *Template) Validate() error {
}
}
// Verify post-processors
for i, chain := range t.PostProcessors {
for j, p := range chain {
// Validate only/except
if verr := p.OnlyExcept.Validate(t); verr != nil {
for _, e := range multierror.Append(verr).Errors {
err = multierror.Append(err, fmt.Errorf(
"post-processor %d.%d: %s", i+1, j+1, e))
}
}
}
}
return err
}
......
......@@ -52,6 +52,26 @@ func TestTemplateValidate(t *testing.T) {
"validate-good-prov-except.json",
false,
},
{
"validate-bad-pp-only.json",
true,
},
{
"validate-good-pp-only.json",
false,
},
{
"validate-bad-pp-except.json",
true,
},
{
"validate-good-pp-except.json",
false,
},
}
for _, tc := range cases {
......
{
"builders": [{
"type": "foo"
}],
"post-processors": [{
"type": "bar",
"except": ["bar"]
}]
}
{
"builders": [{
"type": "foo"
}],
"post-processors": [{
"type": "bar",
"only": ["bar"]
}]
}
{
"builders": [{
"type": "foo"
}],
"post-processors": [{
"type": "bar",
"except": ["foo"]
}]
}
{
"builders": [{
"type": "foo"
}],
"post-processors": [{
"type": "bar",
"only": ["foo"]
}]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment