16 Commits

Author SHA1 Message Date
Sylvia Moss
291121dd55
(2) Implement datasources (#10440) 2021-01-20 10:37:16 +01:00
Tristan Watson
17c806fbf5
Removing obsolete packer HCL warnings from CLI for validate and command (#10461) 2021-01-11 11:50:23 +01:00
Megan Marsh
00cc425b84 docs tweaks 2020-10-14 12:58:04 -07:00
Adrien Delorme
44616d3bff
refactor initialization out from packer configs + tests (#9627)
The initialization of packer core in JSON also validates that `null` variables were set, except in the case of `packer validate --syntax-only` , but after the refactor to allow to have all commands work with HCL2 and JSON this subtlety was lost.

This refactors the initialisation of the core in order to allow to have `packer validate --syntax-only` not error in case a variable is not set. Since these calls are refactored this works for HCL2 too.

fix #9478
2020-07-24 10:58:03 +02:00
Wilken Rivera
f672f5bd9b command/validate: Add support for HCL2 configuration files
* Update validate command to use FixConfig for checking against known
fixers
* Update validation command flag docs
* Add ConfigFixer method to PackerHandler Interface
* Implement ConfigFixer interface in PackerConfig
* Remove all stdout messaging (i.e calls to c.Ui.Say) in the validate
command. The command will only display hcl.Diagnotic messaging when there is an error or warning.

HCL2 Configs
```
⇶  packer validate docker_centos_shell_provisioner.pkr.hcl

```

JSON Configs
```
⇶  packer validate vmware-iso_ubuntu_minimal/vmware-iso_ubuntu_minimal.json
Error: Failed to prepare build: "vmware-iso"

1 error occurred:
        * Deprecated configuration key: 'iso_checksum_type'. Please call `packer fix`
against your template to update your template to be compatable with the current
version of Packer. Visit https://www.packer.io/docs/commands/fix/ for more
detail.

Warning: Fixable configuration found.
You may need to run `packer fix` to get your build to run correctly.
See debug log for more information.

  map[string]interface{}{
        "builders": []interface{}{
                map[string]interface{}{
                        ... // 3 identical entries
                        "guest_os_type":     string("ubuntu-64"),
                        "http_directory":    string("http"),
-                       "iso_checksum":
string("946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2"),
+                       "iso_checksum":
string("sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2"),
-                       "iso_checksum_type": string("sha256"),
                        "iso_url":
string("http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso"),
                        "shutdown_command":  string("echo 'vagrant' | sudo -S shutdown -P now"),
                        ... // 4 identical entries
                },
        },
  }
```
2020-06-05 14:24:39 -04:00
Adrien Delorme
22a36ef97a Move vars from Meta to cla args; this forces us to use it in GetConfigFromJSON which in turn forces us into updating console and validate 2020-05-12 11:24:22 +02:00
Adrien Delorme
c71a792186 simplify/refactor core for build & validate 2020-04-30 16:36:01 +02:00
Adrien Delorme
d2964d59e9 document that the -var-file option still expects JSON files for now 2020-03-03 17:19:51 +01:00
Josh Soref
66738ccaf4 Try to make help more consistent
Also try to synchronize the completion script
2018-10-10 21:34:35 -04:00
Matthew Hooker
dde6805ee8
ignore empty top-level config keys when vetting fix 2018-07-02 13:57:11 -07:00
Matthew Hooker
a5e29e68da
cmd/validate: notify user if config is "fixable" 2018-06-25 22:21:16 -07:00
Jeremy Voorhis
bfc75eb9d9 Implement cli.CommandAutocomplete for most commands 2017-10-13 11:57:44 -07:00
Matthew Hooker
81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Mitchell Hashimoto
c49fe672b3 command/validate: bail if can't initialize build [GH-2139] 2015-05-29 16:09:37 -07:00
Mitchell Hashimoto
dc74ec5612 packer: remove Environment 2015-05-25 17:29:10 -07:00
Mitchell Hashimoto
8054e66db6 command: move more to this package, remove old packages 2014-10-27 20:31:02 -07:00