Refactor refvartransformer with kyaml

This commit is contained in:
Donny Xia
2020-07-22 14:46:14 -07:00
parent c48e584d1a
commit af057a95c5
8 changed files with 457 additions and 73 deletions

View File

@@ -11,7 +11,7 @@ import (
"sigs.k8s.io/kustomize/kyaml/kio"
)
func RunFilter(t *testing.T, input string, f kio.Filter) string {
func run(input string, f kio.Filter) (string, error) {
var out bytes.Buffer
rw := kio.ByteReadWriter{
Reader: bytes.NewBufferString(input),
@@ -23,8 +23,26 @@ func RunFilter(t *testing.T, input string, f kio.Filter) string {
Filters: []kio.Filter{f},
Outputs: []kio.Writer{&rw},
}.Execute()
if err != nil {
return "", err
}
return out.String(), nil
}
// RunFilter runs filter and panic if there is error
func RunFilter(t *testing.T, input string, f kio.Filter) string {
output, err := run(input, f)
if !assert.NoError(t, err) {
t.FailNow()
}
return out.String()
return output
}
// RunFilterE runs filter and return error if there is
func RunFilterE(t *testing.T, input string, f kio.Filter) (string, error) {
output, err := run(input, f)
if err != nil {
return "", err
}
return output, nil
}