841 Validate properties are defined on cfn validate#892
Draft
mgentry612 wants to merge 2 commits intoaws-cloudformation:masterfrom
Draft
841 Validate properties are defined on cfn validate#892mgentry612 wants to merge 2 commits intoaws-cloudformation:masterfrom
mgentry612 wants to merge 2 commits intoaws-cloudformation:masterfrom
Conversation
PatMyron
reviewed
Mar 14, 2023
| def verify_listed_properties_are_defined(resource_spec): | ||
| LOG.debug("verify_listed_properties_are_defined") | ||
|
|
||
| schema_keys = [ |
Contributor
There was a problem hiding this comment.
Some newer JSON pointer property types
Suggested change
| schema_keys = [ | |
| schema_keys = [ | |
| "nonPublicProperties", | |
| "conditionalCreateOnlyProperties", |
Contributor
|
To get all the validations included and keep them up to date over time is not a trivial task. May I suggest you give https://github.com/aws-cloudformation/resource-schema-guard-rail a try and see if it helps solve your problems? |
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.
Issue #, if available:
841
Description of changes:
This PR is not ready for production - it makes several of the current test cases fail. I wanted to start a conversation about whether all of this validation is needed before I considered modifying current test cases. The main reason I made this PR was to introduce myself to the codebase. I realize this PR may or may not be helpful to your team. If you find that this PR is heading in the right direction, please provide feedback. If you're not interested in adding this functionality, no problem, it was fun diving in.
This PR implements validation for the top level of properties in the resource schema. For the following resource schema keys, a validation function ensures that properties at the top level of the "property" object are defined.
"readOnlyProperties", "createOnlyProperties", "primaryIdentifier", "required", "additionalIdentifiers", "deprecatedProperties", "writeOnlyProperties",The following assumptions are made in these changes, please confirm:
These changes handle examples like this:
"createOnlyProperties": [ "/properties/Name" ]but not nested properties like this, see below section about traversing the json structure:
"createOnlyProperties": [ "/properties/obj1/obj2/str1" ]As mentioned above, this PR omits nested properties. I started diving into nested properties but I decided I would need discuss the requirements before doing any more work. There were several complexities which I had questions about including the array data type and circular references. If you think it would be helpful to show you what I have so far for this on another branch, let me know and I'll share.
I've included several new test cases which run successfully only in isolation at this time.
pytest --cov="rpdk.core" --doctest-modules --random-order-bucket="parent" "tests/test_data_loaders.py" -k test_load_resource_spec_property_not_defined --pyargs "rpdk.core" --verboseBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.