Skip to content

Commit

Permalink
feat: add the warning when the content is omitted (#1365)
Browse files Browse the repository at this point in the history
* feat: add the warning when the content is omitted

* fix: fix the style of warning

* fix: fix the warning
  • Loading branch information
suzuki-shunsuke authored Aug 13, 2024
1 parent 910ceac commit e59dc3b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/terraform/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ func avoidHTMLEscape(text string) htmltemplate.HTML {
}

func wrapCode(text string) interface{} {
header := ""
if len(text) > 60000 { //nolint:mnd
header = "\n:warning: **The content is omitted as it is too long.** :warning:\n"

text = text[:20000] + `
# ...
Expand All @@ -154,11 +157,11 @@ func wrapCode(text string) interface{} {
}
if strings.Contains(text, "```") {
if strings.Contains(text, "~~~") {
return htmltemplate.HTML(`<pre><code>` + htmltemplate.HTMLEscapeString(text) + `</code></pre>`) //nolint:gosec
return htmltemplate.HTML(header + `<pre><code>` + htmltemplate.HTMLEscapeString(text) + `</code></pre>`) //nolint:gosec
}
return htmltemplate.HTML("\n~~~hcl\n" + text + "\n~~~\n") //nolint:gosec
return htmltemplate.HTML(header + "\n~~~hcl\n" + text + "\n~~~\n") //nolint:gosec
}
return htmltemplate.HTML("\n```hcl\n" + text + "\n```\n") //nolint:gosec
return htmltemplate.HTML(header + "\n```hcl\n" + text + "\n```\n") //nolint:gosec
}

func generateOutput(kind, template string, data map[string]interface{}, useRawOutput bool) (string, error) {
Expand Down

0 comments on commit e59dc3b

Please sign in to comment.