kubernetes-sigs/kubectl-validate

Can't validate multiple Objects in a Single Manifest

philippe-granet opened this issue · 5 comments

What happened?

I can't validate multiple Objects in a Single Manifest

What did you expect to happen?

It should fail if one of the objects in a manifest file is invalid

How can we reproduce it (as minimally and precisely as possible)?

Using a manifest.yaml file with multiple Objects:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: validkind

---
apiVersion: v1
kind: configmap
metadata:
  name: invalidkind

and running kubectl-validate manifest.yaml, it return:

manifest.yaml...OK

but it should fail with this error message:

manifest.yaml...ERROR
failed to retrieve validator: kind configmap not found in v1 groupversion
Error: validation failed

Anything else we need to know?

No response

Kubernetes version

Using kubectl-validate 0.0.3

I think you should replace this:

func SplitYamlDocuments(fileBytes Document) ([]Document, error) {
var documents [][]byte
reader := utilyaml.NewYAMLReader(bufio.NewReader(bytes.NewBuffer(fileBytes)))
for {
document, err := reader.Read()
if err == io.EOF || len(document) == 0 {
break
} else if err != nil {
return nil, err
}
documents = append(documents, []byte(document))
}
return documents, nil

by something like this:

func SplitYamlDocuments(fileBytes Document) ([]Document, error) {
	var documents [][]byte
	decoder := utilyaml.NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader(fileBytes)))
	for {
		document, err := decoder.Read([]byte{})
		...
}

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

/remove-lifecycle stale