Commit graph

690 commits

Author SHA1 Message Date
Adrien Delorme
0362a3ec10
all shells: Pass env vars through a key value store (#11569)
* allowing to set shell env vars from a key/value map.
* tests

This new map will work alongside the `environment_vars` but it allows using a
datasource value seamlessly. At validation, and because `environment_vars` was
an array of strings containing `KEY=value`, using datsources would not work,
because these values are not known yet and would evaluate to `<unknown>`. With
this, the value and the key can be unknown and will validate correctly for
datasources.
2022-02-16 12:05:44 +01:00
Adrien Delorme
e03ad29ca0
Sanitize var code (#11566)
* evaluateLocalVariables: modify code for readability and some (not benchmarked) perfs

* Make default input variable type the DynamicPseudoType

This should be the default, and avoids a panic. This type can represent situations where a type is not yet known. Its meaning is undefined in cty.

* do not take Empty types from default value

* Update types.variables.go

Co-authored-by: Wilken Rivera <wilken@hashicorp.com>
2022-02-14 11:00:41 -05:00
Adrien Delorme
9f4a1281dd
Add packer plugins command and subcommands to interact with plugins (#11553)
* add basic docs for plugins command

* refactor docs

Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com>

* add plugins command

* add plugins subcommands

they do nothing for now

* add plugins installed command + tests

* add plugins install command

* add remove plugin command

* better docs for the plugins install command

* remove duplicate content

* better output for installed plugins

* add plugins required command

* Update plugins_install.go

* add newline after `Usage:`

* Update plugins_remove.go

* Update plugins_required.go

* Update plugins_remove.go

* Update plugins_installed.go

* Update plugins_install.go

* add docs

* Update plugins_install.go

* fix typos

* Update plugins_test.go

* fix typos

Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com>

* Update core_wrapper.go

Co-Authored-By: Wilken Rivera <1749304+nywilken@users.noreply.github.com>

* Update website/content/docs/commands/plugins/remove.mdx

Co-authored-by: Wilken Rivera <wilken@hashicorp.com>

* Update website/content/docs/commands/plugins/required.mdx

Co-authored-by: Wilken Rivera <wilken@hashicorp.com>

* Update website/content/docs/commands/plugins/required.mdx

Co-authored-by: Wilken Rivera <wilken@hashicorp.com>

* Update plugins_required.go

* Update install.mdx

* Update required.mdx

* plugins requirement, warn when no plugin was found

* Update website/content/docs/commands/plugins/required.mdx

Co-authored-by: Wilken Rivera <wilken@hashicorp.com>

Co-authored-by: Wilken Rivera <1749304+nywilken@users.noreply.github.com>
Co-authored-by: Wilken Rivera <wilken@hashicorp.com>
2022-02-10 16:53:50 -05:00
teddylear
1d01ad3651
feat: print all locals errors when there is a circular error (#11527) 2022-01-27 14:40:45 +01:00
Wilken Rivera
58fa1f96e2
Temporarily revert the use of indirect redirects for external plugins (#11430)
The auto installation of external plugins via packer init only work for
HCL templates. Since we have not officially removed all plugins (slated
for 1.8.0) I am reverting this test change. Once 1.7.9 is released we
  can begin removing plugins and optimizing the redirect experience for
  JSON-only users.
2021-12-06 10:55:49 -05:00
Adrien Delorme
3278c1a817
Packer SVC acc tests (#11274) 2021-12-01 15:58:33 +01:00
Wilken Rivera
4a0fbd911a
Add support for variable interpolation to hcp_packer_registry and build blocks. (#11421)
* Add variable interpolation support to hcp_packer_registry block

* Add tests for variable interpolation in hcp_packer_registry block

* Add variable interpolation support to the build block (#11425)

* Add simple test to build command
2021-12-01 11:35:51 +01:00
Adrien Delorme
710d109c55
HCL2: fix a crash when an HCL2 component is nil after a misconfiguration (#11382)
* add test for crash

* fix

* show more precise error message when parse of a provisioner fails

* Revert "fix"

This reverts commit fc88e89fbb.

* add better severity
2021-11-04 10:08:27 -04:00
Adrien Delorme
c54326b030 remove all non official plugins from vendored plugins 2021-11-03 12:03:08 +01:00
Adrien Delorme
faeef90910 remove ansible plugin from bundled plugins 2021-11-03 11:47:29 +01:00
Adrien Delorme
8acd453065 remove vagrant plugin from bundled plugins 2021-11-03 11:46:06 +01:00
Adrien Delorme
bfe200d920 remove qemu plugin from bundled plugins 2021-11-03 11:46:05 +01:00
Adrien Delorme
d9d96169d8 remove googlecompute plugin from bundled plugins 2021-11-03 11:46:05 +01:00
Adrien Delorme
4efa69cfff remove docker plugin from bundled plugins 2021-11-03 11:46:05 +01:00
Adrien Delorme
7a21f141c8 remove vsphere plugin from bundled plugins 2021-11-03 11:46:05 +01:00
Adrien Delorme
eea27b02d5 remove parallels plugin from bundled plugins 2021-11-03 11:46:04 +01:00
Adrien Delorme
36c30706f1 remove vmware plugin from bundled plugins 2021-11-03 11:46:04 +01:00
Adrien Delorme
eca7b442c1 remove virtualbox plugin from bundled plugins 2021-11-03 11:46:04 +01:00
Adrien Delorme
37ac5b260f remove azure plugin from bundled plugins 2021-11-03 11:46:03 +01:00
Adrien Delorme
bb33cf9845 remove amazon plugin from bundled plugins 2021-11-03 11:46:03 +01:00
Rohit Kothari
6a569b964f
Show successful message upon successful packer validate (#11337)
* Show successful message upon successful packer validate

Co-authored-by: Adrien Delorme <azr@users.noreply.github.com>
2021-10-18 15:03:44 +02:00
Adrien Delorme
a766d59d82
packer init: better error handling with a special care for gh rate limit errors (#11330) 2021-10-14 13:57:59 +02:00
Megan Marsh
e3719dd8a4
Merge pull request #11319 from hashicorp/add_iteration_id
Add iteration
2021-10-11 13:18:10 -07:00
Megan Marsh
b763b79d9f implement contextual variable packer.iteration_id 2021-10-11 10:55:44 -07:00
Adrien Delorme
254e020b08
Allow to use build variables in a post processor (#11323)
* hcl: add test to verify that build.name can be used in a pp

* allow to use build vars in post processors
2021-10-11 10:17:34 -04:00
Adrien Delorme
3135714465
rename all things 'inexist[e|a]nt' to 'nonexistent' & fix tests (#11325)
+ a typo
2021-10-11 15:48:51 +02:00
teddylear
11f5da8b5a
fix: Removing test debris (#11300)
* fix: fixing provisioner file test debris

* fix: Setting hcl2_upgrade command create directory permissions to 0755
2021-10-04 10:58:27 -04:00
Adrien Delorme
fee561f8ea
use the github.com/scaleway/packer-plugin-scaleway now (#11296) 2021-09-29 16:33:58 +02:00
Wilken Rivera
d6a5234412 Unregister packer-image-iteration datasource
This change temporarily renames the type of the packer-image-iteration
datasource to prevent it from being automatically registered by the
Packer plugin tooling. The datasource is fully functional, but not quite
ready for full usage. It will be updated in a future release.
2021-09-14 14:25:48 -04:00
Wilken Rivera
b10df3abb7
Update HCP Packer registry image extraction, validation, publishing logic for registry capable plugins (#11221)
* Update handling of registry artifacts

This change uses the github.com/hashicorp/packer-plgin-sdk/packer/registryimage for querying
Artifact State for HCP Registry Image metadata. To handle the conversion
of the RPC response, mapstructure was introduced to conversion state
data into an registryimage.Image before publishing to a image bucket.

* Update to use registry image from packersdk

* Rename internal registry service pkg

* Update vendored plugins to latest version

* The latest release of Amazon, GoogleCompute, and Azure have support
  for publishing images to the HCP Packer registry.
2021-09-13 21:07:54 -04:00
Megan Marsh
48de1fc7da allow datasources to use other datasources
create a null data source for testing. We can choose to document if we want to, but it's a convenience for us

add a test to catch cyclic datasource dependency, update tests to include out of order data sources, and update the code to clean up the returned diagnostics generated from the recursive evaluation

PR review comments
2021-09-03 16:10:39 -07:00
Megan Marsh
fd80f8da8c Add two new data sources -- hcp-packer-iteration and hcp-packer-image. These data sources together will allow users to query hcp_packer for the image_ids they need to use as source images to their builds, with a simple UI and clear outputs.
add quick and dirty acceptance test for hcp packer image iteration and hcp packer image data sources
PR review
linting
2021-09-03 15:51:09 -07:00
Adrien Delorme
27d89ac8d4
update all plugins + pin go to go 1.17 (#11237)
* up plugins and get rid of a dependency loop from packer to packer
2021-09-02 12:15:13 +02:00
Megan Marsh
d6792820f4
Merge pull request #11227 from hashicorp/hcp_data_source
Implement hcp packer data source.
2021-08-31 09:33:48 -07:00
Adrien Delorme
c083b53c4f
packer fix: state that the command does not work for hcl files (#11238) 2021-08-31 16:12:47 +02:00
Adrien Delorme
d25373a8d6
move inspec provisioner out (#11230) 2021-08-31 12:07:26 +02:00
Adrien Delorme
acb01cb800
move salt-masterless provisioner out (#11229)
* move salt-masterless provisioner out
* go get github.com/hashicorp/packer-plugin-salt
2021-08-31 12:07:10 +02:00
Megan Marsh
980deeb684 Implement hcp packer data source. This is a rough copy of the terraform provider's data source, to make beta user experience consistent across both sources 2021-08-27 12:03:55 -07:00
Adrien Delorme
eb8e302941
hcl2_upgrade: special case: vsphere fix (#11216)
* fix typo

* hcl2_upgrade: special case linux_options and network_interface to block instead of maps

* Update hcl2_upgrade_test.go

* Update hcl2_upgrade_test.go

remove unused code

* hcl2_upgrade: support strftime too (#11220)

* hcl2_upgrade strftime function
* create legacy_strftime.mdx
2021-08-25 14:20:08 +02:00
Adrien Delorme
57f37c99ea
avoid hcl2_upgrade panic when file does not exist (#11206) 2021-08-13 16:08:12 +02:00
Wilken Rivera
a534c743cf
HCP Packer registry enabled Packer client (#11154)
* Add working registry pkg

* Add custom error for handling the loading of PAR environment variables

* Working Publish to Build, with proper error handling for bucket names

* Update hcp-sdk-go to use branch instead of mod replace directive

* Update Packer build status configuration

* Add support for HCP_PACKER_BUILD_FINGERPRINT env

* Add support for publishing one or more PARtifacts from a single build

* add git shas to this branch

* Add ability to set provider name if available

* Add working RegistryBuilder type

* Add RegistryPostProcessor as wrapper post-processor

* When in PAR mode a empty RegistryPostProcessor is added to the end of
  the post-processor list to publish all final image data.

* Add support for updating a build from PAR that is not in a DONE state

* Fix a small issue with creation the initial builds for an empty
  iteration.

* Add PAR URL to post-processor display

* Implement hcp_packer_registry block (#11168)

* Update vendored Amazon plugin to v1.0.1-dev

* Fix panic when running a Packer registry build in a clean directory

* Remove the publishing of post-processor metadata from the registry
  post-processor.

* Remove metadata add from registry_builder

* Update registry builder to skip a build that was found to be DONE

Co-authored-by: Megan Marsh <megan@hashicorp.com>
Co-authored-by: Sylvia Moss <moss@hashicorp.com>
2021-08-05 09:25:19 -04:00
Adrien Delorme
9d0193ac14
add possibility to use variables everywhere in post-processor blocks (#11094)
feature + tests.

Including in:
* name
* only
* except
* keep_input_artifact

Example file:

```hcl
source "null" "example1" {
  communicator = "none"
}

source "null" "example2" {
  communicator = "none"
}

locals {
  except = "null.example1"
}

variable "only" {
  default = "null.example1"
}

build {
  sources = ["source.null.example1", "source.null.example2"]
  post-processor "shell-local" {
    except = [local.except]
    inline = ["echo first post-processor"]
  }

  post-processor "shell-local" {
    only   = [var.only]
    inline = ["echo second post-processor"]
  }
}
```
Ouput:
```shell-session
$ packer build foo.pkr.hcl
null.example1: output will be in this color.
null.example2: output will be in this color.

==> null.example1: Running post-processor:  (type shell-local)
==> null.example2: Running post-processor:  (type shell-local)
==> null.example2 (shell-local): Running local shell script: /var/folders/3k/2gb5ct4s7cncr52_jh2kz6cw0000gq/T/packer-shell201696062
==> null.example1 (shell-local): Running local shell script: /var/folders/3k/2gb5ct4s7cncr52_jh2kz6cw0000gq/T/packer-shell494781572
    null.example1 (shell-local): second post-processor
Build 'null.example1' finished after 61 milliseconds 432 microseconds.
    null.example2 (shell-local): first post-processor
Build 'null.example2' finished after 111 milliseconds 678 microseconds.

==> Wait completed after 111 milliseconds 714 microseconds
```

close #4895
2021-06-15 18:29:26 +02:00
Wilken Rivera
e22346f0fa
Extract ProfitBricks Plugin (#11084)
* Extract ProfitBricks Plugin

* Update CHANGELOG
2021-06-14 17:30:58 -04:00
Sylvia Moss
927093e5c0
improve regex to fix escaping on split function (#11083) 2021-06-14 18:58:32 +02:00
Yoan Blanc
36a7b28b5f
fix: print unchanged formatted file when using stdin (#11047)
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2021-06-03 14:02:42 +02:00
Adrien Delorme
98990fc34e
hcl2_upgrade: allow to hcl2_upgrade with unknown builders, just log errors (#11049) 2021-06-03 13:41:16 +02:00
sylviamoss
444605c127 vendor oneandone 2021-05-25 14:46:44 +02:00
Wilken Rivera
c262467413
Extract Azure plugin components from Packer (#10979)
* Remove Azure plugin components and docs

* Add Azure plugin to vendored_plugins

* Updates Azure to use remote plugin docs

* Revendor packer-plugin-azure at v0.0.2

* Update to new version of the Packer plugin SDK v0.2.1
* Update to the official version of go-getter@v2.0.0
* Update salt provisioner to use new go-getter API

* Update vendored plugins to working versions

This changes fixes an issue with the go.sum for the Azure plugin.
It also revendors the plugins for puppet, chef, and ansible as v0.0.1
of those plugins where not usable.
2021-05-13 16:13:21 -04:00
Adrien Delorme
e60a7e60b9 add test to repro #10975 2021-04-26 17:31:22 +02:00
Adrien Delorme
38837848f9
Breakout yandex (#10970) 2021-04-22 17:03:14 +02:00