Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't validate multiple Objects in a Single Manifest #123

Open
philippe-granet opened this issue Apr 22, 2024 · 5 comments · May be fixed by #143
Open

Can't validate multiple Objects in a Single Manifest #123

philippe-granet opened this issue Apr 22, 2024 · 5 comments · May be fixed by #143
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@philippe-granet
Copy link

philippe-granet commented Apr 22, 2024

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

@philippe-granet philippe-granet added the kind/bug Categorizes issue or PR as related to a bug. label Apr 22, 2024
@philippe-granet
Copy link
Author

philippe-granet commented Apr 23, 2024

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{})
		...
}

@k8s-triage-robot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 22, 2024
@philippe-granet
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 22, 2024
@crandles crandles linked a pull request Oct 7, 2024 that will close this issue
@k8s-triage-robot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 20, 2024
@philippe-granet
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants