Fixed empty tag handling

master
Patryk Gudalewicz 2022-07-29 09:32:18 +02:00
parent 324522e35d
commit 9a8e3a2032
1 changed files with 18 additions and 1 deletions

View File

@ -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"]})