Skip to content

Commit

Permalink
fix: variables with "empty" default values should not be marked as re…
Browse files Browse the repository at this point in the history
…quired
  • Loading branch information
jstewmon committed Jul 11, 2019
1 parent 9c24e68 commit d4e5c56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"reflect"
"strings"
"text/template"

Expand Down Expand Up @@ -69,6 +70,9 @@ func showModuleMarkdown(module *tfconfig.Module) {
return ""
}
},
"isDefined": func(v interface{}) bool {
return reflect.ValueOf(v).Kind() != 0
},
})
template.Must(tmpl.Parse(markdownTemplate))
err := tmpl.Execute(os.Stdout, module)
Expand Down Expand Up @@ -99,7 +103,7 @@ Provider Requirements:
## Input Variables
{{- range .Variables }}
* {{ tt .Name }}{{ if .Default }} (default {{ json .Default | tt }}){{else}} (required){{end}}
* {{ tt .Name }}{{ if isDefined .Default }} (default {{ json .Default | tt }}){{else}} (required){{end}}
{{- if .Description}}: {{ .Description }}{{ end }}
{{- end}}{{end}}
Expand Down

0 comments on commit d4e5c56

Please sign in to comment.