-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Pack config: Process defaults and datastore values in patternProperties and additionalItems #5321
Pack config: Process defaults and datastore values in patternProperties and additionalItems #5321
Conversation
9475fe9
to
1b5d21a
Compare
It was trying to access lists as if they were dictionaries. So, adjust to allow both dicts and lists.
1b5d21a
to
8105360
Compare
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.
This is great. I've not had chance to check the arrayItems changes, but went through patternProperties. Just raised a couple of minor comments on the patternProperties.
This documents the properties schema flattening algorithm with code comments. That highlighted some vars and a method that could be renamed to clarify the code even more.
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.
Thanks for update, the additionalProperties handling is really clear now, and looks good.
I haven't looked at additionalItems, but will try and do that when you've added the extra tests.
Thanks for the refactor.
st2tests/st2tests/fixtures/packs/dummy_pack_schema_with_additional_items_1/config.schema.yaml
Show resolved
Hide resolved
K. I added a test showing the order of precedence in of properties, patternProperties, and additionalProperties in pack config. |
I'm reviewing the schema to make sure I implemented patternProperties correctly. We use draft 4 (and draft 3's
st2/st2common/st2common/util/schema/__init__.py Lines 46 to 50 in 9e336d8
In draft 4, patternProperties creates an all-of set of schemas for each property. Each property gets compared against all patterns. And it must match all of the schemas for the patterns it matches. So, we can't avoid compiling some of the patterns like I thought. 😥 So, I need to refactor a bit more to check all patterns against all keys not included in |
In draft 4, patternProperties creates an all-of set of schemas for each property. Each property gets compared against all patterns. And it must match all of the schemas for the patterns it matches. So, we cannot avoid compiling some of the patterns. https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00#section-8.3
95c6642
to
5931e6d
Compare
K. Refactored and ready for more reviews |
66b2a98
to
a6c9318
Compare
a6c9318
to
1463f4d
Compare
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.
this looks good to me.
The only thing I thought of was whether it was worth having additional additionalItems tests, e.g. are we covering the case where additionalItems is "true" and additionalIItems is "false".
I've approved though, if you don't think those are needed. As the logic looks good, and other than that tests look great.
Thanks for all the work.
With
But, I suppose there can still be jinja templates without auto-decryption. So, I just added a test for a template that uses |
d3e517f
to
a5084e7
Compare
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 Code-wise, didn't get a chance to set up and test.
Building on #5225 allowed pack config to get defaults populated and get datastore values injected when needed under
additionalProperties
This PR does the same for
patternProperties
andadditionalItems
.We're were not processing defaults or datastore values in pack config under:
patternProperties
on objects (discovered in Contribute new pack for Cisco ISE StackStorm-Exchange/exchange-incubator#166 (comment))additionalItems
on arrays (noticed while adding patternProperties support)This makes sure we are applying defaults on nested items in arrays as well.
TODO: