diff --git a/rules/k8s-common-labels-usage/raw.rego b/rules/k8s-common-labels-usage/raw.rego index 1c293215f..df723f5fa 100644 --- a/rules/k8s-common-labels-usage/raw.rego +++ b/rules/k8s-common-labels-usage/raw.rego @@ -90,6 +90,13 @@ no_K8s_label_or_no_K8s_label_usage(wl, beggining_of_path) = path{ path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}] } +no_K8s_label_or_no_K8s_label_usage(wl, beggining_of_path) = path{ + metadata := wl.metadata + not metadata.labels + label_key := get_label_key("") + path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}] +} + no_K8s_label_or_no_K8s_label_usage(wl, beggining_of_path) = path{ labels := wl.metadata.labels not all_kubernetes_labels(labels)