mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-29 17:41:13 +00:00
Handle kyaml Filter errors type Result as non-breaking errors and store in ResourceList
- Result can only count as error when passed as pointer, this makes easy use of "errors.As" - Existing Filter() implementations that return Result from the `framework` package won't return an error anymore but modify the ResourceList
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package framework
|
||||
|
||||
import (
|
||||
goerrors "errors"
|
||||
"os"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/errors"
|
||||
@@ -140,8 +141,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 instead of
|
||||
// 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user