Add validation hook to template command execution

This commit is contained in:
Katrina Verey
2021-01-20 15:53:46 -08:00
parent 2e0d6d42bf
commit 4f184e8ce3

View File

@@ -392,6 +392,11 @@ type Defaulter interface {
Default() error Default() error
} }
// Validator is implemented by APIs to have Validate invoked
type Validator interface {
Validate() error
}
func (tc *TemplateCommand) doPreProcess(rl *ResourceList) error { func (tc *TemplateCommand) doPreProcess(rl *ResourceList) error {
// do any preprocessing // do any preprocessing
if tc.PreProcess != nil { if tc.PreProcess != nil {
@@ -531,6 +536,12 @@ func (tc TemplateCommand) Execute(rl *ResourceList) error {
} }
} }
if v, ok := rl.FunctionConfig.(Validator); ok {
if err := v.Validate(); err != nil {
return err
}
}
if err := tc.doPreProcess(rl); err != nil { if err := tc.doPreProcess(rl); err != nil {
return err return err
} }