From 14cad650ca9c0da9471c48f9803b0209549387d6 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 16 Nov 2022 10:57:57 -0500 Subject: [PATCH] website: add docs for variable warning bypass opts 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. --- website/content/docs/commands/build.mdx | 8 ++++++++ website/content/docs/commands/validate.mdx | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/website/content/docs/commands/build.mdx b/website/content/docs/commands/build.mdx index 90a2420e3d8..bb5ba266321 100644 --- a/website/content/docs/commands/build.mdx +++ b/website/content/docs/commands/build.mdx @@ -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. diff --git a/website/content/docs/commands/validate.mdx b/website/content/docs/commands/validate.mdx index 8b06c274f4f..562c501eceb 100644 --- a/website/content/docs/commands/validate.mdx +++ b/website/content/docs/commands/validate.mdx @@ -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