Commit Graph

19 Commits

Author SHA1 Message Date
Wilken Rivera acabc1c1aa
Add packer fmt command (#10225)
* Add packer fmt command

This change adds a new command that allows users to format one or more
HCL2 Packer configuration template files.

Related to: #9174

* command/fmt: Add check flag

Packer's fmt command now supports a check flag that will output the name
of any file that would be changed by the HCL2 formatting engine. The
check flag is mutually exclusive with the write flag and will only check
if formatting is needed.

The update write flag will now overwrite the source files with the newly
formatted HCL2 source unless the `-write=false` or `-check` is passed at
the command line.

* Returns a diagnostic error if Format is unable to show a diff - equivalent to `terraform fmt`
* Updates testing to run against #Format and not the private methods of the HCL2Formatter; fixes ShowDiff test failure on Windows
* Updates comments for exported functions

* Add docs for fmt command
2020-11-11 11:49:39 -05:00
Adrien Delorme 5ba134ac5b
JSON to HCL2 (minimal best-effort) transpiler (#9659)
hcl2_upgrade transforms a JSON build-file in a HCL2 build-file.
This starts a validated Packer core and from that core we generate an HCL 'block' per plugin/configuration. So for a builder, a provisioner, a post-processor or a variable. The contents of each block is just transformed as is and basically all fields are HCL2-ified.
A generated field can be valid in JSON but invalid on HCL2; for example JSON templating (in mapstructure) allows to set arrays of strings - like `x = ["a", "b"]` - with single strings - like `x="a"` -, HCL does not allow this.
Since JSON does not make the distinction between variables and locals, everything will be a variable. So variables that use other variables will not work.
hcl2_upgrade tries to transform go templating interpolation calls to HCL2 calls when possible, leaving the go templating calls like they are in case it cannot.

Work:
* transpiler
* tests
* update hcl v2 library so that output looks great.
* update docs
2020-08-25 10:51:43 +02:00
Megan Marsh b8ac1a800d implement a packer console analogous to the terraform console 2019-06-05 16:35:22 -07:00
Matthew Hooker ddf23a2c46
Complete Atlas deprecation.
Removes the push command and the Atlas post-processor.  Please see our
guide on building immutable infrastructure with Packer on CI/CD for
ideas on implementing these features yourself.
https://www.packer.io/guides/packer-on-cicd/
2018-08-02 20:23:28 -07:00
Krzysztof Wilczynski 0e08640fff
Re-factor version command to use version.FormattedVersion() function.
This commit removes surplus code which is almost a duplicate of the code
available in the version package by favouring the package implementation
instead.

Signed-off-by: Krzysztof Wilczynski <kw@linux.com>
2017-12-03 23:07:16 +01:00
Matthew Hooker 81522dced0
move packer to hashicorp 2017-04-04 13:39:01 -07:00
Matthew Hooker d1b20b3d9c
remove a bunch of dead code.
https://github.com/dominikh/go-tools/tree/master/cmd/unused
2017-03-28 20:36:20 -07:00
DanHam 2b0f52e84a
Fix copy/paste Terraform references 2017-01-29 16:31:23 +00:00
Christopher Boumenot 728c496370 Move version to its own package. (#3460) 2016-04-21 13:19:43 -07:00
Chris Bednarski d09a9ab0c7 Implemented internal plugins
- Internal plugins are compiled into the same packer binary and invoked through the plugin command
- Search paths allow disk-based plugins to override and should function as normal
- This should allow for a 94% space savings vs statically compiling all the plugins as separate binaries.. approximately 24mb vs 431mb
2015-10-21 16:57:38 -07:00
Mitchell Hashimoto 1ee2b014a6 packer: remove Ui/Cache from CoreConfig 2015-05-27 20:09:52 -07:00
Mitchell Hashimoto dc74ec5612 packer: remove Environment 2015-05-25 17:29:10 -07:00
Mitchell Hashimoto ba359394b1 fix compilation 2015-05-23 16:32:36 -07:00
Mitchell Hashimoto 9d89ca8e07 command: build should be converted to new API, compiles 2015-05-23 16:30:45 -07:00
Mitchell Hashimoto 84c8344794 hook up push to commands 2014-12-09 16:14:03 -08:00
Mitchell Hashimoto 8dbe0f065c Remove version from "packer" package 2014-10-27 20:51:34 -07:00
Mitchell Hashimoto fa36cf82ee command: move all remaining commands 2014-10-27 20:34:49 -07:00
Mitchell Hashimoto 8054e66db6 command: move more to this package, remove old packages 2014-10-27 20:31:02 -07:00
Mitchell Hashimoto 96b0ec5395 Start putting commands in command/, modify core 2014-10-27 20:21:13 -07:00