mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
fix(outputs): refactor unroll_tags to use str as tags (#4819)
Co-authored-by: Pedro Martín <pedromarting3@gmail.com>
This commit is contained in:
committed by
GitHub
parent
03064f1f29
commit
dae26ad484
@@ -63,10 +63,16 @@ def unroll_tags(tags: list) -> dict:
|
||||
>>> tags = {"name": "John", "age": "30"}
|
||||
>>> unroll_tags(tags)
|
||||
{'name': 'John', 'age': '30'}
|
||||
|
||||
>>> tags = ["name", "age"]
|
||||
>>> unroll_tags(tags)
|
||||
{'name': '', 'age': ''}
|
||||
"""
|
||||
if tags and tags != [{}] and tags != [None]:
|
||||
if tags and tags != [{}] and tags != [None] and tags != []:
|
||||
if isinstance(tags, dict):
|
||||
return tags
|
||||
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}
|
||||
elif "Key" in tags[0]:
|
||||
|
||||
@@ -150,6 +150,15 @@ class TestOutputs:
|
||||
"terraform": "true",
|
||||
}
|
||||
|
||||
def test_unroll_tags_only_list(self):
|
||||
tags_list = ["tag1", "tag2", "tag3"]
|
||||
|
||||
assert unroll_tags(tags_list) == {
|
||||
"tag1": "",
|
||||
"tag2": "",
|
||||
"tag3": "",
|
||||
}
|
||||
|
||||
def test_unroll_dict(self):
|
||||
test_compliance_dict = {
|
||||
"CISA": ["your-systems-3", "your-data-1", "your-data-2"],
|
||||
|
||||
Reference in New Issue
Block a user