From 9a8e3a2032a2baaf49ebec8548cca8565c5f5842 Mon Sep 17 00:00:00 2001 From: Patryk Gudalewicz Date: Fri, 29 Jul 2022 09:32:18 +0200 Subject: [PATCH] Fixed empty tag handling --- createReport.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/createReport.py b/createReport.py index b83f823..8355e8e 100644 --- a/createReport.py +++ b/createReport.py @@ -59,7 +59,24 @@ def GatherReportingInfo(DTAPIToken, DTENV,friendlyName): appnametagval = next((tag for tag in entity["tags"] if tag["stringRepresentation"].startswith('app-name')), None) compassidtagval = next((tag for tag in entity["tags"] if tag["stringRepresentation"].startswith('compass-id')), None) msidtagval = next((tag for tag in entity["tags"] if tag["stringRepresentation"].startswith('[Kubernetes]ms-id')), None) - row={'AppId':appidtagval["value"],'AppName':appnametagval["value"],'CompassId':compassidtagval["value"],'MsId':msidtagval["value"],'ServiceName':entity['displayName'],'ServiceId':entity['entityId']} + row={'ServiceName':entity['displayName'],'ServiceId':entity['entityId']} + if appidtagval: + row.update({'AppId':appidtagval["value"]}) + else: + row.update({'AppId':''}) + if appnametagval: + row.update({'AppName':appnametagval["value"]}) + else: + row.update({'AppName':''}) + if compassidtagval: + row.update({'CompassId':compassidtagval["value"]}) + else: + row.update({'CompassId':''}) + if msidtagval: + row.update({'MsId':msidtagval["value"]}) + else: + row.update({'MsId':''}) + for kubetag in entity["tags"]: if(kubetag["key"].startswith("app.bmwgroup.com/")): row.update({kubetag["key"]:kubetag["value"]})