diff --git a/main.go b/main.go index 335dc70..b4ea644 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" ) // @@ -97,8 +98,12 @@ func (kcv *KubeconformValidator) Filter(rlItems []*yaml.RNode) ([]*yaml.RNode, e cfg, out := kc.configure(&kcv.Spec) // Run Kubeconform validate. + // and convert kc.IO stream to YAML. + // kc.IO stream is a JSON stream. + // kc.IO does not have method Bytes() so we need to convert it 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