-
Notifications
You must be signed in to change notification settings - Fork 104
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
(PDK-1112) Create json schema to validate pdk config file #742
Merged
glennsarti
merged 7 commits into
puppetlabs:master
from
glennsarti:pdk-1112-config-schema
Sep 20, 2019
Merged
(PDK-1112) Create json schema to validate pdk config file #742
glennsarti
merged 7 commits into
puppetlabs:master
from
glennsarti:pdk-1112-config-schema
Sep 20, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
glennsarti
changed the title
(PDK-1112) Create json schema to validate pdk config file
{WIP}(PDK-1112) Create json schema to validate pdk config file
Sep 2, 2019
glennsarti
force-pushed
the
pdk-1112-config-schema
branch
3 times, most recently
from
September 3, 2019 03:29
8ace120
to
9598537
Compare
glennsarti
changed the title
{WIP}(PDK-1112) Create json schema to validate pdk config file
(PDK-1112) Create json schema to validate pdk config file
Sep 3, 2019
scotje
reviewed
Sep 9, 2019
glennsarti
force-pushed
the
pdk-1112-config-schema
branch
from
September 16, 2019 06:21
9598537
to
af296b7
Compare
Previously the Config Namespace class conflated a few concepts together and had less than ideal method naming. This commit: * Changes the name of a namespace value to a namespace setting. This is because the class held more than just a value, such as the default value and validators. Therefore it made more sense to call it a a Namespace Setting. * The namespace had an abstract method called parse_data which was passed both the data and the name to the file. This didn't make sense as the filename is all that's required, not the filename. The method was also renamed to parse_file which is more accurate name. * The parse_file used to return an array of objects, but this create extra array objects during parsing. This commit changes the method to instead yield namespace setting objects. This will allow namespaces to create their own settings objects instead of only using the one. * Refactors common file based namespace tests to an rspec shared example. * Adds tests for assigning values to a setting
Previously there was no formal schema, or a way to validate a schema, for configuration settings. This commit adds two new namespace types, YAML and JSON files with JSON schema validation. These namespaces will also take a JSON Schema file and use that to provide defaults and validation. Any settings NOT in the schema will not be visible in the namespace, but will not be lost when saving the namespace to disk; That is the namespace will only modify settings that are in the schema. This also includes tests for any schema files, to ensure that they are indeed valid. This commit adds a schema for the PDK analytics configuration. This commit introduces a new setting type, JSONSchemaSetting which uses the schema to validate and get default values for a setting from the schema.
This commit adds the tests for the new schema based namespaces. This commit also refactors common tests between JSON, YAML and non-schema namespaces into rspec shared example groups. Note that due to a bug in json-schema object, the tests fail on non-Windows platforms.
Unfortunately the json-schema gem fails to load filed based schema on Windows due to URI encoding issues. Also the json-schema gem is abandoned so it won't get fixed either, and other gems don't have support for old ruby 2.1. This commit monkey patches the JSON Schema read_file method to munge the pathname on Windows platforms. This commit removes the test guards on non-Windows platforms.
This commit removes some TODOs from the yard documentation for the PDK::Config::Setting class.
The PDK::Config::Validator class is no longer used. This commit removes the class from the PDK.
Previously the previous_setting attribute was added without much documentation. This command adds comments to describe how this works.
glennsarti
force-pushed
the
pdk-1112-config-schema
branch
from
September 16, 2019 07:59
af296b7
to
c6411c3
Compare
scotje
approved these changes
Sep 16, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me @glennsarti !
rodjek
approved these changes
Sep 19, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the Config Namespace class conflated a few concepts together and had
less than ideal method naming. This commit:
Changes the name of a namespace value to a namespace setting. This is because
the class held more than just a value, such as the default value and
validators. Therefore it made more sense to call it a a Namespace Setting.
The namespace had an abstract method called parse_data which was passed both
the data and the name to the file. This didn't make sense as the filename is
all that's required, not the filename. The method was also renamed to
parse_file which is more accurate name.
The parse_file used to return an array of objects, but this create extra array
objects during parsing. This commit changes the method to instead yield
namespace setting objects. This will allow namespaces to create their own
settings objects instead of only using the one.
Refactors common file based namespace tests to an rspec shared example.
Adds tests for assigning values to a setting
Previously there was no formal schema, or a way to validate a schema, for
configuration settings. This commit adds two new namespace types, YAML and
JSON files with JSON schema validation.
These namespaces will also take a JSON Schema file and use that to provide
defaults and validation. Any settings NOT in the schema will not be visible in
the namespace, but will not be lost when saving the namespace to disk; That is
the namespace will only modify settings that are in the schema. This also
includes tests for any schema files, to ensure that they are indeed valid.
This commit adds a schema for the PDK analytics configuration.
This commit introduces a new setting type, JSONSchemaSetting which uses the
schema to validate and get default values for a setting from the schema.
This commit adds the tests for the new schema based namespaces. This commit
also refactors common tests between JSON, YAML and non-schema namespaces into
rspec shared example groups.
Note that due to a bug in json-schema object, the tests fail on non-Windows
platforms.
Unfortunately the json-schema gem fails to load filed based schema on Windows
due to URI encoding issues. Also the json-schema gem is abandoned so it get
fixed either, and other gems don't have support for old ruby 2.1. This commit
monkey patches the JSON Schema read_file method to munge the pathname on
Windows platforms.
This commit removes the test guards on non-Windows platforms.