Skip to content

Commit 2c298a2

Browse files
committed
refactor(cfn-lang-ext): use jmespath for artifact property copy
1 parent 11181cc commit 2c298a2

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

samcli/lib/package/language_extensions_packaging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,12 @@ def _copy_artifact_uris_for_type(
271271

272272
copied = False
273273
for prop_name in prop_names:
274-
if prop_name not in exported_props:
274+
exported_value = _get_prop_value(exported_props, prop_name)
275+
if exported_value is None:
275276
continue
276277
if dynamic_prop_keys and foreach_key and (foreach_key, prop_name) in dynamic_prop_keys:
277278
continue
278-
original_props[prop_name] = exported_props[prop_name]
279+
_set_prop_value(original_props, prop_name, exported_value)
279280
copied = True
280281

281282
return copied

tests/unit/commands/package/test_package_context.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,18 @@ def test_set_prop_value_dotted_key_creates_intermediate(self):
10021002
# Existing keys preserved
10031003
self.assertEqual(props["Command"]["Name"], "glueetl")
10041004

1005+
def test_copy_artifact_uris_for_type_glue_job_dotted_path(self):
1006+
"""Regression: dotted property path (Command.ScriptLocation) must be copied."""
1007+
original_props = {"Command": {"Name": "glueetl", "ScriptLocation": "./script.py"}}
1008+
exported_props = {"Command": {"Name": "glueetl", "ScriptLocation": "s3://b/k.py"}}
1009+
1010+
result = _copy_artifact_uris_for_type(original_props, exported_props, "AWS::Glue::Job")
1011+
1012+
self.assertTrue(result)
1013+
self.assertEqual(original_props["Command"]["ScriptLocation"], "s3://b/k.py")
1014+
# Sibling keys preserved
1015+
self.assertEqual(original_props["Command"]["Name"], "glueetl")
1016+
10051017

10061018
class TestPackageContextMappingsIntegration(TestCase):
10071019
"""Test cases for the complete Mappings transformation integration in _export()"""

0 commit comments

Comments
 (0)