From 477feb4de819604367a904f4dffbd39b34d9745b Mon Sep 17 00:00:00 2001 From: Abdalaziz Ali Date: Tue, 16 May 2023 05:58:37 +0200 Subject: [PATCH] feat: convert the output error to yaml --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 335dc70..bce2131 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( "sigs.k8s.io/kustomize/kyaml/kio" "sigs.k8s.io/kustomize/kyaml/resid" "sigs.k8s.io/kustomize/kyaml/yaml" + yamltojson "sigs.k8s.io/yaml" ) // @@ -96,9 +97,11 @@ func (kcv *KubeconformValidator) Filter(rlItems []*yaml.RNode) ([]*yaml.RNode, e kc.loadResourceListItems(rlItems) cfg, out := kc.configure(&kcv.Spec) - // Run Kubeconform validate. + // Run Kubeconform validate + // and convert kc.IO stream to YAML. if err := kubeconform.Validate(cfg, out); err != nil { - return nil, errors.Wrap(errors.Errorf("Kubeconform validation output: %s", kc.IO)) + outYAML, _ := yamltojson.JSONToYAML(kc.IO.(*bytes.Buffer).Bytes()) + return nil, errors.WrapPrefixf(err, "Kubeconform validation failed: %s", string(outYAML)) } return rlItems, nil