Skip to content

Commit 18939ca

Browse files
authored
Unify default values of inputs (terraform-docs#97)
1 parent 1ef60b5 commit 18939ca

20 files changed

+338
-440
lines changed

examples/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
variable unquoted {}
22

3+
variable "string-3" {
4+
default = ""
5+
}
6+
37
variable "string-2" {
48
description = "It's string number two."
59
type = "string"

internal/pkg/doc/doc.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ type Doc struct {
2121
Outputs []Output
2222
}
2323

24-
// Value represents a Terraform value.
25-
type Value struct {
26-
Type string
27-
Value interface{}
28-
}
29-
3024
// HasComment indicates if the document has a comment.
3125
func (d *Doc) HasComment() bool {
3226
return len(d.Comment) > 0
@@ -42,6 +36,17 @@ func (d *Doc) HasOutputs() bool {
4236
return len(d.Outputs) > 0
4337
}
4438

39+
// Value represents a Terraform value.
40+
type Value struct {
41+
Type string
42+
Value interface{}
43+
}
44+
45+
// IsAggregateType indicates if a Terraform value is an aggregate type.
46+
func (v Value) IsAggregateType() bool {
47+
return v.Type == "list" || v.Type == "map"
48+
}
49+
4550
// CreateFromPaths creates a new document from a list of file or directory paths.
4651
func CreateFromPaths(paths []string) (*Doc, error) {
4752
names := make([]string, 0)

0 commit comments

Comments
 (0)