Uh oh!
There was an error while loading. Please reload this page.
fix Globals.Function Architectures override behavior - #3940
fix Globals.Function Architectures override behavior#3940allenheltondev wants to merge 1 commit into
Conversation
Signed-off-by: Allen Helton <allenheltondev@gmail.com>
reedham-aws
left a comment
There was a problem hiding this comment.
Thank you for raising this!
Seems like the linter is failing as well, you can fix locally with make format or make lint.
| global_properties = self._drop_overridden_globals(self.global_properties, local_properties) | ||
| return self._do_merge(global_properties, local_properties) # type: ignore[no-untyped-call] | ||
| def _drop_overridden_globals(self, global_properties, local_properties): # type: ignore[no-untyped-def] | ||
| if not self.override_properties or not isinstance(global_properties, dict) or not isinstance(local_properties, dict): | ||
| return global_properties | ||
| global_properties = global_properties.copy() | ||
| for key in self.override_properties: | ||
| if key in global_properties and key in local_properties: | ||
| del global_properties[key] | ||
| return global_properties |
There was a problem hiding this comment.
I think this approach makes sense and would work, but I my first instinct is that we could get rid of the loop/copy by checking the override_properties in _merge_dict. I left another comment in the place where that might work, but I could be missing something, let me know what you think.
| global_dict = global_dict.copy() | ||
| for key in local_dict: | ||
| if key in global_dict: |
There was a problem hiding this comment.
I think we could have a condition here to see if the key is in the overrides, and if it's not then we could enter the else. I think this would accomplish the same thing.
Issue #, if available
Fixes#3939
Description of changes
Updates
Globals.Functionmerge behavior so resource-levelArchitecturesoverrides globalArchitecturesinstead of concatenating both lists.Architecturesis list-shaped, but Lambda functions support a single architecture value. This keeps the existing default list merge behavior for other properties, such asLayers, while handlingArchitectureslike other overridable function properties.Description of how you validated changes
Ran:
Result: 48 passed.
Also updated the globals_for_function translator fixture to cover resource-level Architectures overriding Globals.Function.Architectures across standard, aws-cn, and aws-us-gov outputs.
Integration tests were not added because this change is limited to Globals merge behavior and is covered by unit tests plus translator output fixtures.
Checklist
Examples?
Please reach out in the comments if you want to add an example. Examples will be
added to
sam initthrough aws/aws-sam-cli-app-templates.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.