-
Notifications
You must be signed in to change notification settings - Fork 163
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
Implement canary file generation functionality from contract test PatchInputs #1074
Conversation
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 PR needs some work. I think we should have a method that will translate desired state (dict) into a stack template (which we already have). Then you should prepare a list of such structures. You should iterate over each CreateInputs
and apply PatchInputs
then we can loop through all of them and generate stack template with names added incrementally.
Example:
{
"CreateInputs": {
"property1": "value1",
"property2": "value1",
"property3": "value1",
},
"PatchInputs": [
{
"op": "add",
"path": "/property4",
"value": "value1"
},
{
"op": "replace",
"path": "/property1",
"value": "value2"
}
]
}
those inputs will be translated into this
[
{
"property1": "value1",
"property2": "value1",
"property3": "value1"
},
{
"property1": "value2",
"property2": "value1",
"property3": "value1",
"property4": "value1",
}
]
then you can iterate and run it through stack generation method
def apply_patch(document:dict, patch_document: Sequence[Dict]):
modified_document = jsonpatch.JsonPatch(patch_document).apply(document)
...
def generate_canaries(...):
inputs = get_list_of_inputs(...)
for input in inputs:
canary_file = generate_canary(input)
Summary of Updates:
|
Issue #, if available:
Description of changes:
Add canary file generation functionality for Patch Operation canaries from contract test inputs.
canarySettings will be shared with generating Create Operation canaries.
Testing Scenarios:
CreateInputs
will be updated by areplace
,add
orremove
operation inPatchInputs
.replace
,add
andremove
operations result in an update. Other operations such asmove
,copy
andtest
are ignored.CreateInputs
but included inPatchInputs
foradd
andreplace
operations.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.