From 55d547b53b4703558cb84d9f530aaf0eaacb5b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 24 Feb 2025 09:44:50 +0100 Subject: [PATCH] feat: Make policy available in doc command --- internal/commands/document.go | 2 ++ internal/commands/document_policy_csv.tpl | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 internal/commands/document_policy_csv.tpl diff --git a/internal/commands/document.go b/internal/commands/document.go index bffe51af..f18dc070 100644 --- a/internal/commands/document.go +++ b/internal/commands/document.go @@ -36,6 +36,7 @@ type Document struct { Header Header URL string Rego string + Policy rego.Rego } //go:embed document_template.tpl @@ -308,6 +309,7 @@ func getDocumentation(path string, outputDirectory string) (map[rego.Severity][] Header: header, URL: url, Rego: rego, + Policy: policy, } if policy.Severity() == "" { diff --git a/internal/commands/document_policy_csv.tpl b/internal/commands/document_policy_csv.tpl new file mode 100644 index 00000000..e04490e7 --- /dev/null +++ b/internal/commands/document_policy_csv.tpl @@ -0,0 +1,6 @@ +{{/* This is an example how to create a CSV file that includes the policy ID and the policy name */}} +{{- range $severity, $value := . }} +{{- range . }} +{{ .Policy.PolicyID | default "-" }},{{ .Policy.Name }} +{{- end }} +{{- end }}