Skip to content

Commit

Permalink
Addressed review comments and fixed 'all' namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil-sumologic committed Dec 3, 2024
1 parent 179b4bd commit 8c933e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions sumologic-app-utils/src/sumoresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,11 @@ def build_source_params(self, props, source_json=None):
return source_json

@staticmethod
def _prepare_aws_filter_tags(props, namespaces):
def _prepare_aws_filter_tags(props):
filters = []

namespaces = props.get("Namespaces", [])
namespaces = [namespace for namespace in namespaces if namespace.strip().startswith('AWS/')]
aws_tag_filters = props.get("AWSTagFilters", {})
if aws_tag_filters:
# Convert the string to JSON (Python dictionary)
Expand All @@ -338,7 +341,7 @@ def _prepare_aws_filter_tags(props, namespaces):
else:
aws_tag_filters = {}
for key, value in aws_tag_filters.items():
if key in namespaces:
if key in namespaces or key.lower() == "all":
filters.append({
"type": "TagFilters",
"namespace": key,
Expand All @@ -365,8 +368,7 @@ def _get_path(self, props):
path["limitToRegions"] = regions
if "Namespaces" in props:
path["limitToNamespaces"] = props.get("Namespaces")
print("limitToNamespaces: ", path["limitToNamespaces"])
aws_filter_tag = self._prepare_aws_filter_tags(props, props.get("Namespaces", []))
aws_filter_tag = self._prepare_aws_filter_tags(props)
if aws_filter_tag:
path["tagFilters"] = aws_filter_tag
if source_type == "AwsCloudWatch":
Expand Down Expand Up @@ -465,11 +467,12 @@ def _prepare_aws_filter_tags(props):
else:
aws_tag_filters = {}
for key, value in aws_tag_filters.items():
filters.append({
"type": "TagFilters",
"namespace": key,
"tags": value["tags"]
})
if key.strip().startswith('AWS/') or key.lower() == "all":
filters.append({
"type": "TagFilters",
"namespace": key,
"tags": value["tags"]
})
return filters

def _get_path(self, props):
Expand Down
Binary file modified sumologic-app-utils/sumo_app_utils.zip
Binary file not shown.

0 comments on commit 8c933e6

Please sign in to comment.