diff --git a/command/inspect/command.go b/command/inspect/command.go index 0681b400f..00ab16179 100644 --- a/command/inspect/command.go +++ b/command/inspect/command.go @@ -44,10 +44,20 @@ func (c Command) Run(env packer.Environment, args []string) int { ui := env.Ui() // Variables - ui.Say("Variables and their defaults:\n") if len(tpl.Variables) == 0 { + ui.Say("Variables:\n") ui.Say(" ") } else { + ui.Say("Required variables:\n") + for k, v := range tpl.Variables { + if v.Required { + ui.Machine("template-variable", k, v.Default, "1") + ui.Say(" " + k) + } + } + + ui.Say("") + ui.Say("Optional variables and their defaults:\n") keys := make([]string, 0, len(tpl.Variables)) max := 0 for k, _ := range tpl.Variables { @@ -61,10 +71,14 @@ func (c Command) Run(env packer.Environment, args []string) int { for _, k := range keys { v := tpl.Variables[k] + if v.Required { + continue + } + padding := strings.Repeat(" ", max-len(k)) output := fmt.Sprintf(" %s%s = %s", k, padding, v) - ui.Machine("template-variable", k, v) + ui.Machine("template-variable", k, v.Default, "0") ui.Say(output) } } diff --git a/website/source/docs/machine-readable/command-inspect.html.markdown b/website/source/docs/machine-readable/command-inspect.html.markdown index bda66a9df..3d24c884d 100644 --- a/website/source/docs/machine-readable/command-inspect.html.markdown +++ b/website/source/docs/machine-readable/command-inspect.html.markdown @@ -9,7 +9,7 @@ These are the machine-readable types that exist as part of the output of `packer inspect`.
-
template-variable (2)
+
template-variable (3)

A user variable @@ -24,6 +24,11 @@ of `packer inspect`. Data 2: default - The default value of the variable.

+ +

+ Data 3: required - If non-zero, then this variable + is required. +

template-builder (2)