Skip to content

Commit

Permalink
Merge pull request #9410 from theBeginner86/theBeginner86/chore/63
Browse files Browse the repository at this point in the history
[policy] Add Sibling Policy
  • Loading branch information
aabidsofi19 committed Nov 23, 2023
2 parents 1b64f1a + 15a8c80 commit 1a0d459
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions server/meshmodel/kubernetes/policies/sibling-policy.rego
@@ -0,0 +1,75 @@
package meshmodel_policy
#https://play.openpolicyagent.org/p/YcqqNCLuJx

label_obj[label_key] {
some key
svc := input.services[_]
labels := svc.labels
labels[key]
label_key = key
}

annotation_obj[annotation_key] {
some key
svc := input.services[_]
annotation := svc.annotations
annotation[key]
annotation_key = key
}


group_objects_with_matching_field = result {
labels_result := {labels_map: key |
some labels_map
label_obj[labels_map]
svc := input.services[_]
svc.labels
some keys
svc.labels[keys]
keys == labels_map

key := {value: result |
svc := input.services[_]
labels := svc.labels
some value
some k
value = labels[k]
k == labels_map
result = {r |
some name
x := input.services[name]
x.labels == labels
id := x.traits.meshmap.id
r := {"id": id, "name": name}
}
}
}

annotation_result := {annotations_map: key |
some annotations_map
annotation_obj[annotations_map]
svc := input.services[_]
svc.annotations
some keys
svc.annotations[keys]
keys == annotations_map

key := {value: result |
svc := input.services[_]
annotations := svc.annotations
some value
some k
value = annotations[k]
k == annotations_map
result = {r |
some name
x := input.services[name]
x.annotations == annotations
id := x.traits.meshmap.id
r := {"id": id, "name": name}
}
}
}

result := {"annotations": annotation_result, "labels": labels_result}
}

0 comments on commit 1a0d459

Please sign in to comment.