fix: give optional array a default value#101
fix: give optional array a default value#101jkruse14 wants to merge 1 commit intoaws-cloudformation:mainfrom
Conversation
mrinaudo-aws
left a comment
There was a problem hiding this comment.
Hi @jkruse14, and thank you for your time in looking into this sample hook!
The models.py is a file that is automatically generated: making changes to it will result in such changes being removed the next time the user or maintainer for a hook runs cfn generate. Thus, proposed change(s) should not be applied to this file, because such changes will not be persisted.
If I use the following type configuration in my ~/.cfn-cli/typeConfiguration.json file:
{
"CloudFormationConfiguration": {
"HookConfiguration": {
"TargetStacks": "ALL",
"FailureMode": "FAIL",
"Properties": {
"excludeDBInstanceClassList": [
]
}
}
}
}
(whereas I pass an empty list to excludeDBInstanceClassList), and I do not make additional code changes to the sample hook (I also leave the models.py in its current state without proposed changes), when I package up the hook with cfn submit --dry-run and then I run contract tests locally with cfn test, the hook passes contract tests (7 passed, 3 skipped, 14 deselected). I also used the same settings when I tested using the CloudFormation console, whereas the hook in that case failed as I expected because the db instance described in the template was missing the hook's desired encryption settings and the exclusion list was an empty list.
Is this what you meant when you mentioned the use case of that the property not being given a value, or did you wish to encompass a use case that is different than the one I tried?
If the
excludeDBInstanceClassListproperty is not given a value, the hook will fail. This array is marked as optional in the python code. This update assigns a default value to the array.