Skip to content

Commit e59dc3b

Browse files
feat: add the warning when the content is omitted (#1365)
* feat: add the warning when the content is omitted * fix: fix the style of warning * fix: fix the warning
1 parent 910ceac commit e59dc3b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/terraform/template.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ func avoidHTMLEscape(text string) htmltemplate.HTML {
143143
}
144144

145145
func wrapCode(text string) interface{} {
146+
header := ""
146147
if len(text) > 60000 { //nolint:mnd
148+
header = "\n:warning: **The content is omitted as it is too long.** :warning:\n"
149+
147150
text = text[:20000] + `
148151
149152
# ...
@@ -154,11 +157,11 @@ func wrapCode(text string) interface{} {
154157
}
155158
if strings.Contains(text, "```") {
156159
if strings.Contains(text, "~~~") {
157-
return htmltemplate.HTML(`<pre><code>` + htmltemplate.HTMLEscapeString(text) + `</code></pre>`) //nolint:gosec
160+
return htmltemplate.HTML(header + `<pre><code>` + htmltemplate.HTMLEscapeString(text) + `</code></pre>`) //nolint:gosec
158161
}
159-
return htmltemplate.HTML("\n~~~hcl\n" + text + "\n~~~\n") //nolint:gosec
162+
return htmltemplate.HTML(header + "\n~~~hcl\n" + text + "\n~~~\n") //nolint:gosec
160163
}
161-
return htmltemplate.HTML("\n```hcl\n" + text + "\n```\n") //nolint:gosec
164+
return htmltemplate.HTML(header + "\n```hcl\n" + text + "\n```\n") //nolint:gosec
162165
}
163166

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

0 commit comments

Comments
 (0)