Skip to content

Commit

Permalink
website: add docs for variable warning bypass opts
Browse files Browse the repository at this point in the history
When the options for bypassing/enabling assigned and undeclared
variables were added to Packer, the website documentation for those
commands and options was not updated.

This commit adds some documentation for those options.
  • Loading branch information
lbajolet-hashicorp committed Nov 17, 2022
1 parent bb2384c commit 14cad65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions website/content/docs/commands/build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ artifacts that are created will be outputted at the end of the build.
multiple times. This is useful for setting version numbers for your build.

- `-var-file` - Set template variables from a file.

- `-warn-on-undeclared-var` - Setting this flag will yield a warning for each assignment within
a variable definitions file (*.pkrvars.hcl | *.pkrvars.json) that does not have an accompanying
variable block. This can occur when using a var-file that contains a large amount of unused variables
for a given HCL2 template. For HCL2 template builds defining a value for a variable in a var-file is
not enough on its own for Packer to function, as there also needs to be a variable block definition in
the template files `pkr.hcl` for the variable. By default `packer build` will not warn when a var-file
contains one or more undeclared variables.
9 changes: 9 additions & 0 deletions website/content/docs/commands/validate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ Errors validating build 'vmware'. 1 error(s) occurred:
source block's "name" label, unless an in-build source definition adds the
"name" configuration option.

- `-no-warn-on-undeclared-var` - Silence warnings when the a variable definition
file contains variable assignments for undeclared variables. This can occur
when using a var-file that contains a large amount of unused variables for a
given HCL2 template. For HCL2 template defining a value for a variable in a
var-file is not enough on its own for Packer to function, as there also needs
to be a variable block definition in the template files `pkr.hcl` for the
variable. By default `packer validate` will warn when a var-file contains one
or more undeclared variables.

- `-only=foo,bar,baz` - Only validate the builds with the given comma-separated
names. In legacy JSON templates, build names default to the
types of their builders (e.g. `docker` or
Expand Down

0 comments on commit 14cad65

Please sign in to comment.