Skip to content

Commit

Permalink
Ignore inputs with terraform-docs-ignore comment
Browse files Browse the repository at this point in the history
kampka authored and khos2ow committed May 27, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 80c406f commit 943489c
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion terraform/load.go
Original file line number Diff line number Diff line change
@@ -187,10 +187,17 @@ func loadInputs(tfmodule *tfconfig.Module, config *print.Config) ([]*Input, []*I
var optional = make([]*Input, 0, len(tfmodule.Variables))

for _, input := range tfmodule.Variables {
comments := loadComments(input.Pos.Filename, input.Pos.Line)

// Skip over inputs that are marked as being ignored
if strings.Contains(comments, "terraform-docs-ignore") {
continue
}

// convert CRLF to LF early on (https://github.com/terraform-docs/terraform-docs/issues/305)
inputDescription := strings.ReplaceAll(input.Description, "\r\n", "\n")
if inputDescription == "" && config.Settings.ReadComments {
inputDescription = loadComments(input.Pos.Filename, input.Pos.Line)
inputDescription = comments
}

i := &Input{
6 changes: 6 additions & 0 deletions terraform/testdata/full-example/variables.tf
Original file line number Diff line number Diff line change
@@ -28,3 +28,9 @@ variable "G" {
description = "G description"
default = null
}

# terraform-docs-ignore
variable "H" {
description = "H description"
default = null
}

0 comments on commit 943489c

Please sign in to comment.