Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Meital Rudnitsky <[email protected]>
  • Loading branch information
itsmeital committed Oct 8, 2023
1 parent 662926e commit 82c8a3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions rules/k8s-common-labels-usage/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,22 @@ no_K8s_label_usage(wl, podSpec, beggining_of_pod_path) = path{

no_K8s_label_or_no_K8s_label_usage(wl, beggining_of_path) = path{
not wl.metadata.labels
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
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{
metadata := wl.metadata
not metadata.labels
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
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)
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
label_key := get_label_key()
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}]
}

all_kubernetes_labels(labels){
Expand Down
9 changes: 6 additions & 3 deletions rules/label-usage-for-resources/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,22 @@ no_label_usage(wl, podSpec, beggining_of_pod_path) = path{

no_label_or_no_label_usage(wl, beggining_of_path) = path{
not wl.metadata
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
label_key := get_label_key()
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}]
}

no_label_or_no_label_usage(wl, beggining_of_path) = path{
metadata := wl.metadata
not metadata.labels
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
label_key := get_label_key()
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}]
}

no_label_or_no_label_usage(wl, beggining_of_path) = path{
labels := wl.metadata.labels
not is_desired_label(labels)
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, get_label_key()]), "value": "YOUR_VALUE"}]
label_key := get_label_key()
path = [{"path": sprintf("%vmetadata.labels.%v", [beggining_of_path, label_key]), "value": "YOUR_VALUE"}]
}

is_desired_label(labels) {
Expand Down

0 comments on commit 82c8a3e

Please sign in to comment.