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

This fixes the --ignore-missing-schemas flag #150

Merged
merged 1 commit into from
Jul 20, 2019

Conversation

ian-howell
Copy link
Contributor

@ian-howell ian-howell commented Jul 18, 2019

Addresses #149

This changes the behavior of the --ignore-missing-schemas flag. Prior to
this change, the flag prevented validation against schemas for all
documents. The new behavior is to prevent validation against schemas for
any document whose associated schema can not be found. All other
documents are validated against their corresponding schemas.

This also improves the expected behavior of the flag. Prior behavior was
to display a successful message for any document missing its schema. New
behavior will print a warning message that the document was not
validated against a schema. Note that this still returns a success code.

The following demostrates the new behavior against the valid.yaml, invalid.yaml, and test_crd.yaml files located in the fixtures directory:

$ kubeval fixtures/valid.yaml
The document fixtures/valid.yaml contains a valid ReplicationController

$ kubeval fixtures/valid.yaml --ignore-missing-schemas
Warning: Set to ignore missing schemas
The document fixtures/valid.yaml contains a valid ReplicationController


$ kubeval fixtures/invalid.yaml
The document fixtures/invalid.yaml contains an invalid ReplicationController
---> spec.replicas: Invalid type. Expected: integer, given: string

$ kubeval fixtures/invalid.yaml --ignore-missing-schemas
Warning: Set to ignore missing schemas
The document fixtures/invalid.yaml contains an invalid ReplicationController
---> spec.replicas: Invalid type. Expected: integer, given: string


$ kubeval fixtures/test_crd.yaml
1 error occurred:
        * Failed initalizing schema https://kubernetesjsonschema.dev/master-standalone/sealedsecret-bitnami-v1alpha1.json: Could not read schema from HTTP, response status is 404 Not Found

$ kubeval fixtures/test_crd.yaml --ignore-missing-schemas
Warning: Set to ignore missing schemas
The document fixtures/test_crd.yaml containing a SealedSecret was not validated against a schema

This changes the behavior of the --ignore-missing-schemas flag. Prior to
this change, the flag prevented validation against schemas for all
documents. The new behavior is to prevent validation against schemas for
any document whose associated schema can not be found. All other
documents are validated against their corresponding schemas.

This also improves the expected behavior of the flag. Prior behavior was
to display a successful message for any document missing its schema. New
behavior will print a warning message that the document was not
validated against a schema.
@mikespokefire
Copy link

Can confirm this fixes the bug, thanks for sorting that out @ian-howell! 🎉

@garethr garethr merged commit 296e801 into instrumenta:master Jul 20, 2019
@ian-howell ian-howell deleted the fix/ignore-missing-schema branch July 23, 2019 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants