Skip to content

Commit

Permalink
fix: improve include/exclude conditions
Browse files Browse the repository at this point in the history
Signed-off-by: djerfy <[email protected]>
  • Loading branch information
djerfy committed Jul 10, 2024
1 parent d026015 commit 7cf30b5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a style="text-decoration:none" href="https://github.com/djerfy/zabbix-kubernetes-discovery/actions/workflows/trivy-scan-code.yml">
<img alt="Pipeline Helm" src="https://img.shields.io/github/actions/workflow/status/djerfy/zabbix-kubernetes-discovery/trivy-scan-code.yml?logo=github&color=0&label=Trivy%20Scan&style=flat-square">
</a>
<a style="text-decoration:none" href="https://github.com/djerfy/zabbix-kubernetes-discovery/releases/tag/v1.4.14">
<a style="text-decoration:none" href="https://github.com/djerfy/zabbix-kubernetes-discovery/releases/tag/v1.4.15">
<img alt="Release" src="https://img.shields.io/github/v/release/djerfy/zabbix-kubernetes-discovery?logo=github&color=0&label=Release&style=flat-square">
</a>
</p>
Expand Down
4 changes: 2 additions & 2 deletions helm/zabbix-kubernetes-discovery/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: zabbix-kubernetes-discovery
version: 1.4.14
appVersion: "1.4.14"
version: 1.4.15
appVersion: "1.4.15"
description: Kubernetes monitoring for Zabbix with discovery objects
annotations:
category: Monitoring
Expand Down
2 changes: 1 addition & 1 deletion helm/zabbix-kubernetes-discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $ helm delete zabbix-kubernetes-discovery \
| `serviceAccount.create` | boolean | `true` |
| `serviceAccount.name` | string | `zabbix-kubernetes-discovery` |
| `deployment.name` | string | `zabbix-kubernetes-discovery` |
| `deployment.image.name` | string | `ghcr.io/djerfy/zabbix-kubernetes-discovery:v1.4.14` |
| `deployment.image.name` | string | `ghcr.io/djerfy/zabbix-kubernetes-discovery:v1.4.15` |
| `deployment.image.pullPolicy` | string | `IfNotPresent` |
| `deployment.replicas` | integer | `1` |
| `deployment.strategy` | string | `Recreate` |
Expand Down
2 changes: 1 addition & 1 deletion helm/zabbix-kubernetes-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ serviceAccount:
deployment:
name: zabbix-kubernetes-discovery
image:
name: ghcr.io/djerfy/zabbix-kubernetes-discovery:v1.4.14
name: ghcr.io/djerfy/zabbix-kubernetes-discovery:v1.4.15
pullPolicy: IfNotPresent
replicas: 1
strategy: Recreate
Expand Down
56 changes: 28 additions & 28 deletions src/modules/kubernetes/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def getNode(
}
}

if match_label is not None and not ifLabelMatch(match_label, node.metadata.labels):
if match_label and not ifLabelMatch(match_label, node.metadata.labels):
continue

if not ifObjectMatch(include_name, json['name']):
if include_name and not ifObjectMatch(include_name, json['name']):
continue

if ifObjectMatch(exclude_name, json['name']):
if exclude_name and ifObjectMatch(exclude_name, json['name']):
continue

if name == json['name']:
Expand Down Expand Up @@ -90,19 +90,19 @@ def getDaemonset(
if json['replicas'][i] is None:
json['replicas'][i] = 0

if match_label is not None and not ifLabelMatch(match_label, daemonset.metadata.labels):
if match_label and not ifLabelMatch(match_label, daemonset.metadata.labels):
continue

if not ifObjectMatch(include_name, json['name']):
if include_name and not ifObjectMatch(include_name, json['name']):
continue

if not ifObjectMatch(include_namespace, json['namespace']):
if include_namespace and not ifObjectMatch(include_namespace, json['namespace']):
continue

if ifObjectMatch(exclude_name, json['name']):
if exclude_name and ifObjectMatch(exclude_name, json['name']):
continue

if ifObjectMatch(exclude_namespace, json['namespace']):
if exclude_namespace and ifObjectMatch(exclude_namespace, json['namespace']):
continue

if name == json['name']:
Expand Down Expand Up @@ -152,19 +152,19 @@ def getVolume(
volume['namespace'] = volume['pvcRef']['namespace']
volume['name'] = volume['pvcRef']['name']

if match_label is not None and not ifLabelMatch(match_label, volume.metadata.labels):
if match_label and not ifLabelMatch(match_label, volume.metadata.labels):
continue

if not ifObjectMatch(include_name, volume['name']):
if include_name and not ifObjectMatch(include_name, volume['name']):
continue

if not ifObjectMatch(include_namespace, volume['namespace']):
if include_namespace and not ifObjectMatch(include_namespace, volume['namespace']):
continue

if ifObjectMatch(exclude_name, volume['name']):
if exclude_name and ifObjectMatch(exclude_name, volume['name']):
continue

if ifObjectMatch(exclude_namespace, volume['namespace']):
if exclude_namespace and ifObjectMatch(exclude_namespace, volume['namespace']):
continue

for i in ["time", "pvcRef"]:
Expand Down Expand Up @@ -212,19 +212,19 @@ def getDeployment(
}
}

if match_label is not None and not ifLabelMatch(match_label, deployment.metadata.labels):
if match_label and not ifLabelMatch(match_label, deployment.metadata.labels):
continue

if not ifObjectMatch(include_name, json['name']):
if include_name and not ifObjectMatch(include_name, json['name']):
continue

if not ifObjectMatch(include_namespace, json['namespace']):
if include_namespace and not ifObjectMatch(include_namespace, json['namespace']):
continue

if ifObjectMatch(exclude_name, json['name']):
if exclude_name and ifObjectMatch(exclude_name, json['name']):
continue

if ifObjectMatch(exclude_namespace, json['namespace']):
if exclude_namespace and ifObjectMatch(exclude_namespace, json['namespace']):
continue

for i in ["desired", "ready", "available"]:
Expand Down Expand Up @@ -270,19 +270,19 @@ def getStatefulset(
}
}

if match_label is not None and not ifLabelMatch(match_label, statefulset.metadata.labels):
if match_label and not ifLabelMatch(match_label, statefulset.metadata.labels):
continue

if not ifObjectMatch(include_name, json['name']):
if include_name and not ifObjectMatch(include_name, json['name']):
continue

if not ifObjectMatch(include_namespace, json['namespace']):
if include_namespace and not ifObjectMatch(include_namespace, json['namespace']):
continue

if ifObjectMatch(exclude_name, json['name']):
if exclude_name and ifObjectMatch(exclude_name, json['name']):
continue

if ifObjectMatch(exclude_namespace, json['namespace']):
if exclude_namespace and ifObjectMatch(exclude_namespace, json['namespace']):
continue

for i in ["desired", "ready", "available"]:
Expand Down Expand Up @@ -371,19 +371,19 @@ def getCronjob(
}
}

if match_label is not None and not ifLabelMatch(match_label, cronjob.metadata.labels):
if match_label and not ifLabelMatch(match_label, cronjob.metadata.labels):
continue

if not ifObjectMatch(include_name, json['name']):
if include_name and not ifObjectMatch(include_name, json['name']):
continue

if not ifObjectMatch(include_namespace, json['namespace']):
if include_namespace and not ifObjectMatch(include_namespace, json['namespace']):
continue

if ifObjectMatch(exclude_name, json['name']):
if exclude_name and ifObjectMatch(exclude_name, json['name']):
continue

if ifObjectMatch(exclude_namespace, json['namespace']):
if exclude_namespace and ifObjectMatch(exclude_namespace, json['namespace']):
continue

if name == json['name']:
Expand Down
2 changes: 1 addition & 1 deletion zabbix/TemplateZabbixKubernetesDiscovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ zabbix_export:
value: Kubernetes
-
tag: Version
value: 1.4.14
value: 1.4.15
macros:
-
macro: '{$KUBERNETES.NODE.PODS.CRITICAL}'
Expand Down

0 comments on commit 7cf30b5

Please sign in to comment.