Commit Graph

984 Commits

Author SHA1 Message Date
Megan Marsh bd7b31853e
Multi plugin naming (#10608) 2021-02-15 11:10:43 +01:00
Adrien Delorme 3677069010 test: manually-installed-single-component-plugin-works 2021-02-11 16:35:08 +01:00
Adrien Delorme 37769c2b95
Change PKR_GITHUB_API_TOKEN to PACKER_GITHUB_API_TOKEN to stay consistent with other env var settings (#10588) 2021-02-11 13:54:25 +01:00
Sylvia Moss f616955ebc
Fix issue when loading datasource single plugin type (#10589) 2021-02-08 13:58:35 +01:00
Wilken Rivera 39d550054d Fix lint errors 2021-02-05 16:46:24 -05:00
Wilken Rivera ef4d35097b Fix issue when loading single plugin type
This changes wraps the plugin client start call with an anonymous function so that Packer starts a
new plugin for each occurrence of a particular plugin block.

Before only one subprocess was being created causing subsquent calls to fail as it was trying start
an already started plugin subprocess.

Before Change
```
???????: failed loading comment: error dial unix /tmp/packer-plugin358226172: connect: no such file or directory
2021/02/05 16:09:13 On error:
2021/02/05 16:09:13 Waiting on builds to complete...

2021/02/05 16:09:13 Starting build run: null.basic-example
2021/02/05 16:09:13 Running builder:
2021/02/05 16:09:13 [INFO] (telemetry) Starting builder
  on examples/basic-example.pkr.hcl line 29:
  (source code not available)

dial unix /tmp/packer-plugin358226172: connect: no such file or directory

???????: failed loading comment: error dial unix /tmp/packer-plugin358226172: connect: no such file or directory

2021/02/05 16:09:13 packer.test plugin: [INFO] communicator disabled, will not connect
2021/02/05 16:09:13 packer.test plugin: Unable to load communicator config from state to populate provisionHookData
  on examples/basic-example.pkr.hcl line 38:
2021/02/05 16:09:13 packer.test plugin: Running the provision hook
  (source code not available)

dial unix /tmp/packer-plugin358226172: connect: no such file or directory

???????: failed loading comment: error dial unix /tmp/packer-plugin358226172: connect: no such file or directory

  on examples/basic-example.pkr.hcl line 42:
  (source code not available)

2021/02/05 16:09:13 [INFO] (telemetry) Starting provisioner comment
dial unix /tmp/packer-plugin358226172: connect: no such file or directory
```

After change
```

null.basic-example: output will be in this color.

==> null.basic-example:   ____                   _
==> null.basic-example:  | __ )    ___    __ _  (_)  _ __
==> null.basic-example:  |  _ \   / _ \  / _` | | | | '_ \
==> null.basic-example:  | |_) | |  __/ | (_| | | | | | | |
==> null.basic-example:  |____/   \___|  \__, | |_| |_| |_|
==> null.basic-example:                  |___/
==> null.basic-example:
==> null.basic-example: Running local shell script: /tmp/packer-shell646549657
    null.basic-example: This is a shell script
==> null.basic-example: Pausing at breakpoint provisioner.
==> null.basic-example: Press enter to continue.
==> null.basic-example: In the middle of Provisioning run
==> null.basic-example: Running local shell script: /tmp/packer-shell177279484
    null.basic-example: This is another shell script
==> null.basic-example:   _____               _
==> null.basic-example:  | ____|  _ __     __| |
==> null.basic-example:  |  _|   | '_ \   / _` |
==> null.basic-example:  | |___  | | | | | (_| |
==> null.basic-example:  |_____| |_| |_|  \__,_|
==> null.basic-example:
Build 'null.basic-example' finished after 1 second 32 milliseconds.

==> Wait completed after 1 second 32 milliseconds

==> Builds finished. The artifacts of successful builds are:
--> null.basic-example: Did not export anything. This is the null builder
 Please enter the commit message for your changes. Lines starting
```
2021-02-05 16:35:01 -05:00
Adrien Delorme ed091163be
HCL2 Parse packer.required_plugins block + packer init (#10304)
This adds the new `required_plugins` block to be nested under the packer block.

Example:
```hcl
packer {
  required_plugins {
    aws = {
      version = ">= 2.7.0"
      source = "azr/aws"
    }
    azure = ">= 2.7.0"
  }
}
```

For example on darwin_amd64 Packer will install those under :
* "${PACKER_HOME_DIR}/plugin/github.com/azr/amazon/packer-plugin-amazon_2.7.0_x5.0_darwin_amd64"
* "${PACKER_HOME_DIR}/plugin/github.com/hashicorp/azure/packer-plugin-azure_2.7.0_x5.0_darwin_amd64_x5"

+ docs
+ tests
2021-02-02 18:05:04 +01:00
Sylvia Moss 291121dd55
(2) Implement datasources (#10440) 2021-01-20 10:37:16 +01:00
Adrien Delorme 52d2d7fe5f
Copy `MapOf...` plugin types back into Packer core (#10466)
* move maps of plugins back in core

* go mod vendor

* more fixes

* fix imports

* Update core_test.go

* fix build

* more fixes

* more fixes

* up vendors after fixing sdk

* Update post_processor_mock.hcl2spec.go

* Leave implementatino of MapOf in the sdk for plugi tests

Other wise use the interface

* go mod tidy

* add MapOfDatasource type too
2021-01-13 12:14:06 +01:00
Megan Marsh da0ee96cdd fix imports 2021-01-07 15:38:46 -08:00
Megan Marsh beba3a90a9 fix discover.go 2021-01-07 15:38:38 -08:00
Megan Marsh 0666b787fc allow plugins with registered items with name from plugin.DEFAULT_NAME string constant to be passthroughs to the plugin binary suffix 2021-01-07 11:55:51 -08:00
Megan Marsh 88b7b0e14a remove sdk 2020-12-17 13:29:25 -08:00
Megan Marsh 5f34bbd56e add extra line before package declaration so this line does not become the synopsis of a package for godoc 2020-12-16 15:14:43 -08:00
Adrien Delorme 72c1912b60
allow to discover & start packer-plugin-* muliplugin binaries (#10277)
This add :
* discovery of `packer-plugin-*` binaries from the known folders and ask them to describe themselves
* tests

For testing: in go we create a bash script that in turn calls back to Go. I could not make the tests to work on windows and then would like to postpone testing this for when we know more about the finite layout of this feature. That is mainly: how things are going to work with init, versioning and such.
2020-12-15 10:58:09 +01:00
Megan Marsh 39ab646236
move plugin and rpc code into sdk; other minor tweaks (#10359) 2020-12-09 12:39:54 +01:00
Megan Marsh 823ff34434 remove noop ui, replace in adapter and ansible tests with sdk's TestUi 2020-12-07 15:45:16 -08:00
Megan Marsh 352f064b55 fix docker acceptance tests. Turns out they were broken on the main branch too; needed to move noop progress bar into the sdk to be used in the builder testui. 2020-12-03 16:04:49 -08:00
Megan Marsh 3681e2a7ee fix pathing 2020-12-03 10:39:21 -08:00
Megan Marsh d767c69ed3 rebase and fix conflicts
fix tests
2020-12-03 10:26:48 -08:00
Megan Marsh 5576bb5caa move packer config constants next to the packer config 2020-12-03 10:17:35 -08:00
sylviamoss efa7ec7883 don't override builder/prov/pproc 2020-12-03 18:24:00 +01:00
sylviamoss 4f8a27be10 fix linter 2020-12-03 17:11:35 +01:00
sylviamoss 2c10c21445 move plugin discover tests to plugin pkg 2020-12-03 17:07:24 +01:00
Megan Marsh bf6ab0c290 fix tests 2020-12-01 15:02:15 -08:00
Megan Marsh b69d69095e move postprocessor to sdk, fix generation code 2020-12-01 14:48:55 -08:00
Megan Marsh be5763ec41 move provisioner interface into sdk 2020-12-01 14:25:14 -08:00
Megan Marsh ada91b24e9 extract builder interface to sdk 2020-12-01 13:42:42 -08:00
Megan Marsh 0eff73293a fix imports, vendoring, and linting 2020-11-30 14:30:30 -08:00
Megan Marsh d5971ca25e fix tests by moving mock hooks and communicators, and BasicUi definition, into SDK 2020-11-30 14:30:30 -08:00
Megan Marsh f81ed344a2 regenerate code 2020-11-30 14:30:30 -08:00
Megan Marsh 56a45b04ab Move hook and communicator definitions to packer-plugin-sdk 2020-11-30 14:30:30 -08:00
Megan Marsh a6fdeca099 move logsecretfilter into packer sdk 2020-11-30 14:30:30 -08:00
Megan Marsh 14bdb9516c move Artifact and artifact mock to the sdk 2020-11-30 14:29:52 -08:00
Megan Marsh c70870cb83 move multierror and multierrorappend into sdk 2020-11-30 14:29:06 -08:00
Megan Marsh 001886670d move Ui definition into the packer plugin sdk. 2020-11-30 14:26:54 -08:00
Megan Marsh 9e47696dff move helper/config to bundle with the other template definitions 2020-11-18 10:34:59 -08:00
Megan Marsh 7d658149ea update tests and website and generated partials to reflect new package format 2020-11-17 10:36:01 -08:00
Megan Marsh 1ffc358ada move tmp helper func into packer-plugin-sdk 2020-11-16 15:13:08 -08:00
Megan Marsh 6402362018 create packer-plugin-sdk directory and begin moving the relevant folders into it. 2020-11-13 10:47:36 -08:00
Megan Marsh 1ecd715221 refactor code so that packer/version is not a dependency of sdk code or plugin code 2020-11-09 17:20:42 -08:00
Megan Marsh cd59d938b2 refactor core version pkg imports out of json interpolation/decode pathway. 2020-11-09 13:20:36 -08:00
Megan Marsh bc85854a53 refactor packer version out of hcltemplate code. 2020-11-09 12:29:53 -08:00
Megan Marsh cd74456026
Common provisioner helpers (#10229)
* update docstrings to make it clear that plugins are servers and core is client

* move provisioner guest helper functions into common dir.
2020-11-09 12:16:44 +01:00
Megan Marsh 2d90ffe7a4 move GeneratedData struct and PlaceholderMsg to same package under common 2020-11-06 10:45:38 -08:00
Megan Marsh 721cbac645
Merge pull request #9996 from hashicorp/fix_9995
Make shell-local post-processor return copy of previous artifact
2020-10-05 13:00:51 -07:00
Adrien Delorme 9f97173371 PostProcessorServer.PostProcess: don't close the artifact we are serving
Sometimes, the artifact returned by PostProcess is the artifact from client.Artifact() and in that case we don't want to close client; otherwise the outcome is sort of undetermined. See #9995 for a good test file.

fix #9995
2020-10-05 14:27:55 +02:00
Adrien Delorme a9107a8fe9 noop progress bar is nil progress bar 2020-09-24 12:26:09 +02:00
Megan Marsh 15ee44e857 review comments 2020-09-23 11:33:51 -07:00
Megan Marsh ae8d359bf1 Switch to explicitly declaring TrackProgress on UI, using an underlying progress bar specifically stored on the struct. Export UiProgressTracker. These changes allow us to optionaly switch to the NoopProgressTracker when no TTY is set. 2020-09-21 16:05:14 -07:00