From d4e5c5610a0cf321c7c71314e8d1a69e17841347 Mon Sep 17 00:00:00 2001 From: Jonathan Stewmon Date: Thu, 11 Jul 2019 16:24:32 -0500 Subject: [PATCH] fix: variables with "empty" default values should not be marked as required --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index aa0fb37..18625f1 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "reflect" "strings" "text/template" @@ -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) @@ -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}}