-
Notifications
You must be signed in to change notification settings - Fork 909
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
schema: version schema-cloud-config-v1.json #1424
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
Thanks for the review @BigBlueHundids. |
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, thanks!
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.
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), |
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.
Could we also tests version == 22.2 please?
({"version": "v1"}, None), | |
({"version": "v1"}, None), | |
({"version": "22.2"}, None), |
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: