Merge pull request #4241 from Goodwine/kyaml-result-provider

Handle "Result" errors as non-fatal errors in kyaml FilterFuncs
This commit is contained in:
Natasha Sarkar
2021-11-22 11:07:18 -08:00
committed by GitHub
2 changed files with 17 additions and 10 deletions

View File

@@ -4,6 +4,7 @@
package framework
import (
goerrors "errors"
"os"
"sigs.k8s.io/kustomize/kyaml/errors"
@@ -153,8 +154,19 @@ func Execute(p ResourceListProcessor, rlSource *kio.ByteReadWriter) error {
// Filter executes the given kio.Filter and replaces the ResourceList's items with the result.
// This can be used to help implement ResourceListProcessors. See SimpleProcessor for example.
//
// Filters that return a Result as error will store the result in the ResourceList
// and continue processing instead of erroring out.
func (rl *ResourceList) Filter(api kio.Filter) error {
var err error
rl.Items, err = api.Filter(rl.Items)
return errors.Wrap(err)
if err != nil {
var r Results
if goerrors.As(err, &r) {
rl.Results = append(rl.Results, r...)
return nil
}
return errors.Wrap(err)
}
return nil
}