Skip to content

Commit 477feb4

Browse files
committed
feat: convert the output error to yaml
1 parent 8f9abb8 commit 477feb4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"sigs.k8s.io/kustomize/kyaml/kio"
1717
"sigs.k8s.io/kustomize/kyaml/resid"
1818
"sigs.k8s.io/kustomize/kyaml/yaml"
19+
yamltojson "sigs.k8s.io/yaml"
1920
)
2021

2122
//
@@ -96,9 +97,11 @@ func (kcv *KubeconformValidator) Filter(rlItems []*yaml.RNode) ([]*yaml.RNode, e
9697
kc.loadResourceListItems(rlItems)
9798
cfg, out := kc.configure(&kcv.Spec)
9899

99-
// Run Kubeconform validate.
100+
// Run Kubeconform validate
101+
// and convert kc.IO stream to YAML.
100102
if err := kubeconform.Validate(cfg, out); err != nil {
101-
return nil, errors.Wrap(errors.Errorf("Kubeconform validation output: %s", kc.IO))
103+
outYAML, _ := yamltojson.JSONToYAML(kc.IO.(*bytes.Buffer).Bytes())
104+
return nil, errors.WrapPrefixf(err, "Kubeconform validation failed: %s", string(outYAML))
102105
}
103106

104107
return rlItems, nil

0 commit comments

Comments
 (0)