From 4f184e8ce3e646d2465c48265af8ed2c8bc5c394 Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Wed, 20 Jan 2021 15:53:46 -0800 Subject: [PATCH] Add validation hook to template command execution --- kyaml/fn/framework/framework.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kyaml/fn/framework/framework.go b/kyaml/fn/framework/framework.go index 688c7c535..7eefcb24a 100644 --- a/kyaml/fn/framework/framework.go +++ b/kyaml/fn/framework/framework.go @@ -392,6 +392,11 @@ type Defaulter interface { Default() error } +// Validator is implemented by APIs to have Validate invoked +type Validator interface { + Validate() error +} + func (tc *TemplateCommand) doPreProcess(rl *ResourceList) error { // do any preprocessing 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 { return err }