Skip to content

Commit

Permalink
Update mermaid template (#175)
Browse files Browse the repository at this point in the history
* Update mermaid template with a few fixes

The mermaid template in the schema command wasn't showing relationship
actions for resources and showed one-to-many relationships between
resources. Technically, we don't keep track of constraints on number
of relationships, so to reflect that in the ER diagram this commit
updates the edges between nodes to reflect that. It also adds related
actions to union types.

Signed-off-by: John Schaeffer <[email protected]>

* Rename "perm" to "action" in mermaid template

This commit renames "perm" to "action" in the mermaid template to make
the intent of the attribute a little clearer to consumers.

Signed-off-by: John Schaeffer <[email protected]>

---------

Signed-off-by: John Schaeffer <[email protected]>
  • Loading branch information
jnschaeffer authored Oct 10, 2023
1 parent ca3f471 commit 04a7a79
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/schema_mermaid.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,33 @@ var (
{{ $resource.Name }} {
id_prefix {{ $resource.IDPrefix }}
{{- range $action := index $.Actions $resource.Name }}
perm {{ $action }}
action {{ $action }}
{{- end }}
{{- range $relation, $actions := index $.RelatedActions $resource.Name }}
{{- range $action := $actions }}
{{ $relation }}_perm {{ $action }}
{{ $relation }}_action {{ $action }}
{{- end }}
{{- end }}
}
{{- range $rel := $resource.Relationships }}
{{- range $targetName := $rel.TargetTypeNames }}
{{ $resource.Name }} ||--o{ {{ $targetName }} : {{ $rel.Relation }}
{{ $resource.Name }} }o--o{ {{ $targetName }} : {{ $rel.Relation }}
{{- end }}
{{- end }}
{{- end }}
{{- range $union := .Unions }}
{{ $union.Name }} {
{{- range $action := index $.Actions $union.Name }}
perm {{ $action }}
action {{ $action }}
{{- end }}
{{- range $relation, $actions := index $.RelatedActions $union.Name }}
{{- range $action := $actions }}
{{ $relation }}_action {{ $action }}
{{- end }}
{{- end }}
}
{{- range $typ := $union.ResourceTypeNames }}
{{ $union.Name }} }o--|| {{ $typ }} : alias
{{ $union.Name }} ||--|| {{ $typ }} : alias
{{- end }}
{{- end }}`

Expand Down

0 comments on commit 04a7a79

Please sign in to comment.