Add rbac docs generators
This commit is contained in:
parent
4437627eb3
commit
745a501019
13
codegen/assets/templates/docs/rbac.$component.adoc.tpl
Normal file
13
codegen/assets/templates/docs/rbac.$component.adoc.tpl
Normal file
@ -0,0 +1,13 @@
|
||||
= {{ .label }}
|
||||
|
||||
[cols="1s,5a,5a"]
|
||||
|===
|
||||
| Operation| Description | Default
|
||||
|
||||
{{ range .operations }}
|
||||
| [#{{ .slug }}]#<<{{ .slug }},{{ .label }}>>#
|
||||
| {{ .description }}
|
||||
| Deny
|
||||
|
||||
{{ end }}
|
||||
|===
|
||||
13
codegen/assets/templates/docs/rbac.$resource.adoc.tpl
Normal file
13
codegen/assets/templates/docs/rbac.$resource.adoc.tpl
Normal file
@ -0,0 +1,13 @@
|
||||
= {{ .label }}
|
||||
|
||||
[cols="1s,5a,5a"]
|
||||
|===
|
||||
| Operation| Description | Default
|
||||
|
||||
{{ range .operations }}
|
||||
| [#{{ .slug }}]#<<{{ .slug }},{{ .label }}>>#
|
||||
| {{ .description }}
|
||||
| Deny
|
||||
|
||||
{{ end }}
|
||||
|===
|
||||
11
codegen/assets/templates/docs/rbac.index.adoc.tpl
Normal file
11
codegen/assets/templates/docs/rbac.index.adoc.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
= {{ .label }}
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
include::./component.gen.adoc[]
|
||||
{{ range .resources }}
|
||||
include::./resource.{{ . }}.gen.adoc[]
|
||||
{{ end }}
|
||||
|
||||
:leveloffset: -1
|
||||
|
||||
67
codegen/docs.rbac.cue
Normal file
67
codegen/docs.rbac.cue
Normal file
@ -0,0 +1,67 @@
|
||||
package codegen
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/codegen/schema"
|
||||
"github.com/cortezaproject/corteza-server/app"
|
||||
)
|
||||
|
||||
#_indexPayload: {
|
||||
label: string
|
||||
resources: [...string]
|
||||
}
|
||||
|
||||
#_operationsPayload: {
|
||||
label: string
|
||||
|
||||
operations: [...{
|
||||
slug: string
|
||||
label: string
|
||||
description: string
|
||||
}]
|
||||
}
|
||||
|
||||
[...schema.#codegen] &
|
||||
[
|
||||
for cmp in app.corteza.components {
|
||||
template: "docs/rbac.index.adoc.tpl"
|
||||
output: "src/modules/generated/partials/access-control/\(cmp.handle)/index.gen.adoc"
|
||||
payload: #_indexPayload & {
|
||||
label: cmp.label
|
||||
resources: [ for res in cmp.resources { res.handle } ]
|
||||
}
|
||||
}
|
||||
] +
|
||||
[
|
||||
for cmp in app.corteza.components {
|
||||
template: "docs/rbac.$component.adoc.tpl"
|
||||
output: "src/modules/generated/partials/access-control/\(cmp.handle)/component.gen.adoc"
|
||||
payload: #_operationsPayload & {
|
||||
label: cmp.label
|
||||
|
||||
operations: [
|
||||
for op in cmp.rbac.operations {
|
||||
slug: "rbac-\(cmp.handle)-\(op.handle)"
|
||||
label: op.handle
|
||||
description: op.description
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
] +
|
||||
[
|
||||
for cmp in app.corteza.components for res in cmp.resources {
|
||||
template: "docs/rbac.$resource.adoc.tpl"
|
||||
output: "src/modules/generated/partials/access-control/\(cmp.handle)/resource.\(res.handle).gen.adoc"
|
||||
payload: #_operationsPayload & {
|
||||
label: res.handle
|
||||
|
||||
operations: [
|
||||
for op in res.rbac.operations {
|
||||
slug: "rbac-\(res.handle)-\(op.handle)"
|
||||
label: op.handle
|
||||
description: op.description
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
Loading…
x
Reference in New Issue
Block a user