Skip to content

Commit

Permalink
fix: objects exception if not exists
Browse files Browse the repository at this point in the history
Signed-off-by: djerfy <[email protected]>
  • Loading branch information
djerfy committed Jan 13, 2024
1 parent d7c5e31 commit c3ed0cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/modules/kubernetes/openebs/cstorpoolclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ def openebsGetCstorpoolclusters(config):
if config['monitoring']['openebs']['engine'] != "cstor":
return cstorpoolclusters

for cstorpoolcluster in rawObjects(kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolclusters")):
try:
objects = kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolclusters")
except Exception:
return cstorpoolclusters

for cstorpoolcluster in rawObjects(objects):
json = {
"name": cstorpoolcluster['metadata']['name'],
"namespace": cstorpoolcluster['metadata']['namespace'],
Expand Down
7 changes: 6 additions & 1 deletion src/modules/kubernetes/openebs/cstorpoolinstances.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ def openebsGetCstorpoolinstances(config):

if config['monitoring']['openebs']['engine'] != "cstor":
return cstorpoolinstances

try:
objects = kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolinstances")
except Exception:
return cstorpoolinstances

for cstorpoolinstance in rawObjects(kubernetes.list_cluster_custom_object(group="cstor.openebs.io", version="v1", plural="cstorpoolinstances")):
for cstorpoolinstance in rawObjects(objects):
json = {
"name": cstorpoolinstance['metadata']['name'],
"namespace": cstorpoolinstance['metadata']['namespace'],
Expand Down
7 changes: 6 additions & 1 deletion src/modules/kubernetes/trivy/vulnerabilityreports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def trivyGetVulnerabilityreports(config=None):

reports = []

for vuln in rawObjects(kubernetes.list_cluster_custom_object(group="aquasecurity.github.io", version="v1alpha1", plural="vulnerabilityreports")):
try:
objects = kubernetes.list_cluster_custom_object(group="aquasecurity.github.io", version="v1alpha1", plural="vulnerabilityreports")
except Exception:
return reports

for vuln in rawObjects(objects):
print(vuln['metadata']['name'])
print(vuln['report']['summary'])

0 comments on commit c3ed0cc

Please sign in to comment.