fix(aws): handle AWS key-only tags (#4845)

This commit is contained in:
Sergio Garcia
2024-08-23 07:02:59 -04:00
committed by GitHub
parent 61df2ce0c2
commit fb449cede8
2 changed files with 15 additions and 2 deletions
+10 -2
View File
@@ -52,6 +52,14 @@ def unroll_tags(tags: list) -> dict:
>>> unroll_tags(tags)
{'name': 'John', 'age': '30'}
>>> tags = [{"key": "name"}]
>>> unroll_tags(tags)
{'name': ''}
>>> tags = [{"Key": "name"}]
>>> unroll_tags(tags)
{'name': ''}
>>> tags = [{"name": "John", "age": "30"}]
>>> unroll_tags(tags)
{'name': 'John', 'age': '30'}
@@ -74,9 +82,9 @@ def unroll_tags(tags: list) -> dict:
if isinstance(tags[0], str) and len(tags) > 0:
return {tag: "" for tag in tags}
if "key" in tags[0]:
return {item["key"]: item["value"] for item in tags}
return {item["key"]: item.get("value", "") for item in tags}
elif "Key" in tags[0]:
return {item["Key"]: item["Value"] for item in tags}
return {item["Key"]: item.get("Value", "") for item in tags}
else:
return {key: value for d in tags for key, value in d.items()}
return {}
+5
View File
@@ -159,6 +159,11 @@ class TestOutputs:
"tag3": "",
}
def test_unroll_tags_with_key_only(self):
tags = [{"key": "name"}]
assert unroll_tags(tags) == {"name": ""}
def test_unroll_dict(self):
test_compliance_dict = {
"CISA": ["your-systems-3", "your-data-1", "your-data-2"],