Skip to content

Commit

Permalink
chore: Remove the cerbos prefix from output keys (#1614)
Browse files Browse the repository at this point in the history
When we output metadata, we don't use the `cerbos.` prefix for the
policy name. To keep things consistent, the rule names in the policy
output should also drop the prefix.

Signed-off-by: Charith Ellawala <charith@cerbos.dev>
  • Loading branch information
charithe committed Jun 1, 2023
1 parent 0f78104 commit cac7569
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/namer/namer.go
Expand Up @@ -231,7 +231,7 @@ func RuleFQN(rpsMeta any, scope, ruleName string) string {
panic(fmt.Errorf("unknown runnable policy set meta type %T", m))
}

return fmt.Sprintf("%s#%s", policyFqn, ruleName)
return fmt.Sprintf("%s#%s", PolicyKeyFromFQN(policyFqn), ruleName)
}

type PolicyCoords struct {
Expand Down
Expand Up @@ -76,11 +76,11 @@ checkResources:
},
"outputs": [
{
"src": "cerbos.resource.equipment_request.vdefault/acme#rule-001",
"src": "resource.equipment_request.vdefault/acme#rule-001",
"val": "create_allowed:john"
},
{
"src": "cerbos.resource.equipment_request.vdefault#public-view",
"src": "resource.equipment_request.vdefault#public-view",
"val": {
"id": "john",
"keys": "XX125",
Expand All @@ -96,7 +96,7 @@ checkResources:
}
},
{
"src": "cerbos.resource.equipment_request.vdefault#rule-002",
"src": "resource.equipment_request.vdefault#rule-002",
"val": "approval_status:john:DRAFT"
}
]
Expand All @@ -113,7 +113,7 @@ checkResources:
},
"outputs": [
{
"src": "cerbos.resource.equipment_request.vdefault#public-view",
"src": "resource.equipment_request.vdefault#public-view",
"val": {
"id": "john",
"keys": "YY125",
Expand All @@ -129,7 +129,7 @@ checkResources:
}
},
{
"src": "cerbos.resource.equipment_request.vdefault#rule-002",
"src": "resource.equipment_request.vdefault#rule-002",
"val": "approval_status:john:DRAFT"
}
]
Expand Down
Expand Up @@ -54,11 +54,11 @@ checkResources:
},
"outputs": [
{
"src": "cerbos.principal.terry_tibbs.vdefault#equipment_request_rule-001",
"src": "principal.terry_tibbs.vdefault#equipment_request_rule-001",
"val": ["foo", ["bar", true]]
},
{
"src": "cerbos.resource.equipment_request.vdefault#public-view",
"src": "resource.equipment_request.vdefault#public-view",
"val": {
"id": "terry_tibbs",
"keys": "YY125",
Expand All @@ -74,7 +74,7 @@ checkResources:
}
},
{
"src": "cerbos.resource.equipment_request.vdefault#rule-002",
"src": "resource.equipment_request.vdefault#rule-002",
"val": "approval_status:terry_tibbs:DRAFT"
},
]
Expand Down

0 comments on commit cac7569

Please sign in to comment.