schema: version schema-cloud-config-v1.json#1424
Merged
Merged
Conversation
4068a96 to
17ddf05
Compare
8941078 to
c4d3b2c
Compare
Provide top-level version.schema.cloud-config.json which will be consumed by https://github.com/SchemaStore/schemastore/ and provided for json validator tooling. Rename cloud-init-schema.json to schema-cloud-config-v1.json to allow space for providing static scoped schema definitions for vendor-data, meta-data and network-config in the future.
- Move static schema files into cloudinit/config/schemas. - versions.schema.cloud-config.json to use correct raw github URL as $id - add get_schema_dir for use in testing
c4d3b2c to
5bde6f0
Compare
7016f12 to
2665793
Compare
30beb3b to
9909fd2
Compare
Collaborator
Author
|
Thanks for the review @BigBlueHundids. |
TheRealFalcon
approved these changes
May 16, 2022
Contributor
TheRealFalcon
left a comment
There was a problem hiding this comment.
Looks good, thanks!
aciba90
approved these changes
May 16, 2022
Contributor
There was a problem hiding this comment.
LGTM thank you.
As an optional nit, I think it would be more clear and concise if we refactor test_versioned_cloud_config_schema_is_valid_json to something like:
diff --git a/tests/unittests/config/test_schema.py b/tests/unittests/config/test_schema.py
index c75b7227..5a7cafce 100644
--- a/tests/unittests/config/test_schema.py
+++ b/tests/unittests/config/test_schema.py
@@ -106,11 +106,25 @@ class TestVersionedSchemas:
full_path_schema["oneOf"][0]["allOf"][1]["$ref"] = file_ref
return full_path_schema
+ def validate_cloudconfig_schema_safe(self, schema, version_schema):
+ try:
+ validate_cloudconfig_schema(
+ schema, schema=version_schema, strict=True
+ )
+ except jsonschema.exceptions.RefResolutionError:
+ full_path_schema = self._relative_ref_to_local_file_path(
+ version_schema
+ )
+ validate_cloudconfig_schema(
+ schema, schema=full_path_schema, strict=True
+ )
+
@pytest.mark.parametrize(
"schema,error_msg",
(
({}, None),
({"version": "v1"}, None),
({"version": "v2"}, "is not valid"),
({"version": "v1", "final_message": -1}, "is not valid"),
({"version": "v1", "final_message": "some msg"}, None),
@@ -128,30 +142,10 @@ class TestVersionedSchemas:
version_schema["$id"] = f"file://{version_schemafile}"
if error_msg:
with pytest.raises(SchemaValidationError) as context_mgr:
- try:
- validate_cloudconfig_schema(
- schema, schema=version_schema, strict=True
- )
- except jsonschema.exceptions.RefResolutionError:
- full_path_schema = self._relative_ref_to_local_file_path(
- version_schema
- )
- validate_cloudconfig_schema(
- schema, schema=full_path_schema, strict=True
- )
+ self.validate_cloudconfig_schema_safe(schema, version_schema)
assert error_msg in str(context_mgr.value)
else:
- try:
- validate_cloudconfig_schema(
- schema, schema=version_schema, strict=True
- )
- except jsonschema.exceptions.RefResolutionError:
- full_path_schema = self._relative_ref_to_local_file_path(
- version_schema
- )
- validate_cloudconfig_schema(
- schema, schema=full_path_schema, strict=True
- )
+ self.validate_cloudconfig_schema_safe(schema, version_schema)| "schema,error_msg", | ||
| ( | ||
| ({}, None), | ||
| ({"version": "v1"}, None), |
Contributor
There was a problem hiding this comment.
Could we also tests version == 22.2 please?
Suggested change
| ({"version": "v1"}, None), | |
| ({"version": "v1"}, None), | |
| ({"version": "22.2"}, None), |
This was referenced May 12, 2023
Closed
This file contains hidden or 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
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.
Provide top-level versions.schema.cloud-config.json which will be
published to https://github.com/SchemaStore/schemastore/ and provided
for external json validator tools.
Move static JSON schema files into cloudinit/config/schemas/.
Rename cloud-init-schema.json to schema-cloud-config-v1.json to allow
space for providing static scoped schema definitions for vendor-data,
meta-data and network-config in the future.
Proposed Commit Message
Additional Context
This PR follows the suggested naming conventions and versioning best-practices for adding an out-of-tree
schema definition for schemastore.org.
It attempts to follow the contributing guidelines for non-local schema definitions as well as guidance for multi-version support
Test Steps
Checklist: