Commit Graph
18526 Commits
Author SHA1 Message Date
Michele Degges 29e734ef1c Fix readme build badge (#11600) 2022-02-25 19:58:52 -05:00
b63a9c9803 Onboard to CRT (#11564)
Onboard Packer to CRT

Co-authored-by: Wilken Rivera <[email protected]>
Co-authored-by: Claire Labry <[email protected]>
2022-02-25 15:56:20 -08:00
Wilken RiveraandSylvia Moss dd525fb814 Update HCP Packer build labels when re-running Packer on an incomplete build (#11584)
* Update HCP Packer build labels argument

Previously when running a partial build on multi-cloud build template it
was found that build labels were only being applied at the creation for
the partially executed build. Leaving all other completed builds with
no HCP Packer build labels. This updates how incomplete builds are
loaded from the registry and ensure that any defined
hcp_packer_registry.build_labels are assigned to the build before
starting an actual Packer build.

Related to: #11573

* Add test case for overwriting build labels

* Update tests to call CreateInitialBuild for non-existing builds

* Rename test case to TestBucket_PopulateIteration

* Fix data race in PopulateIteration against mock service

Before Change
```
WARNING: DATA RACE
Write at 0x00c0005421b0 by goroutine 47:
  github.com/hashicorp/packer/internal/registry.(*MockPackerClientService).PackerServiceCreateBuild()
      /Users/scrubbed/Development/packer/internal/registry/mock_service.go:173 +0x2b6
  github.com/hashicorp/packer/internal/registry.(*Client).CreateBuild()
      /Users/scrubbed/Development/packer/internal/registry/service.go:169 +0x592
  github.com/hashicorp/packer/internal/registry.(*Bucket).CreateInitialBuildForIteration()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:107 +0x204
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration.func1()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:368 +0x14e
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration·dwrap·1()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:376 +0x58

Previous write at 0x00c0005421b0 by goroutine 46:
  github.com/hashicorp/packer/internal/registry.(*MockPackerClientService).PackerServiceCreateBuild()
      /Users/scrubbed/Development/packer/internal/registry/mock_service.go:173 +0x2b6
  github.com/hashicorp/packer/internal/registry.(*Client).CreateBuild()
      /Users/scrubbed/Development/packer/internal/registry/service.go:169 +0x592
  github.com/hashicorp/packer/internal/registry.(*Bucket).CreateInitialBuildForIteration()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:107 +0x204
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration.func1()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:368 +0x14e
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration·dwrap·1()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:376 +0x58

Goroutine 47 (running) created at:
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:362 +0x5c7
  github.com/hashicorp/packer/internal/registry.TestBucket_UpdateLabelsForBuild_withMultipleBuilds()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket_test.go:179 +0xf7
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47

Goroutine 46 (finished) created at:
  github.com/hashicorp/packer/internal/registry.(*Bucket).PopulateIteration()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket.go:362 +0x5c7
  github.com/hashicorp/packer/internal/registry.TestBucket_UpdateLabelsForBuild_withMultipleBuilds()
      /Users/scrubbed/Development/packer/internal/registry/types.bucket_test.go:179 +0xf7
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47
==================
```

* Add methods for managing builds on an Iteration

* Update Mock Service to be a bit more concurrent

It is a simple set of changes to make it work for the current testing
use cases. If we need to we can move the Called fields to counters or
re-architect the mock.

This change also fixes a race condition when appending to the Slice of
errs when calling PopulateIteration.

* Update test case descriptions

* Apply suggestions from code review

Only append to errs if err is not nil

Co-authored-by: Sylvia Moss <[email protected]>

* Fix linting issues

Co-authored-by: Sylvia Moss <[email protected]>
2022-02-25 15:50:41 -05:00
Wilken Rivera 0a7dbb65a3 Update CODEOWNERS
Codeowners for external plugins are tracked within the respective
plugin repo.
2022-02-25 14:25:26 -05:00
Pekka NurmiandWilken Rivera a4450adc54 Add UpCloud plugin documentation (#11587)
* Add UpCloud plugin documentation

* Update UpCloud plugin repository path

* Add sourceBranch to UpCloud plugin description

* Alphabetically sort plugin

Co-authored-by: Wilken Rivera <[email protected]>
2022-02-25 11:26:34 -05:00
Johanan Liebermann a66a15bd35 Add missing closing parenthesis (#11593)
Signed-off-by: Johanan Liebermann <[email protected]>
2022-02-25 11:09:56 -05:00
Zachary Shilton de613d297f website: bump docs-page to fix manual copy issue (#11538)
* website: bump docs-page to fix manual copy issue

* chore: pin to latest docs-page pre-release as fix demo

* chore: bump to latest pre-release

* chore: bump to latest docs-page
2022-02-24 15:07:54 -05:00
Wilken Rivera f204f19e06 Update CHANGELOG 2022-02-24 12:27:00 -05:00
Ygal Blum 30813e743d Fix secret name to GPG_PASSPHRASE (#11586) 2022-02-24 10:53:23 -05:00
Wilken Rivera 119a825296 Update CreateIntialBuildForIteration to initialize each build its own map (#11574)
* Rename mock bucket test file

* Add failing tests for reproducing #11573

```
=== RUN   TestBucket_CreateInitialBuildForIteration
2022/02/16 16:22:21 [TRACE] creating initial build for component happycloud.image
--- PASS: TestBucket_CreateInitialBuildForIteration (0.00s)
=== RUN   TestBucket_UpdateLabelsForBuild
2022/02/16 16:22:21 [TRACE] creating initial build for component happycloud.image
    types.bucket_test.go:87: expected the initial build to have an additional build label but thee is no diff: ""
--- FAIL: TestBucket_UpdateLabelsForBuild (0.00s)
=== RUN   TestBucket_UpdateLabelsForBuild_withMultipleBuilds
2022/02/16 16:22:21 [TRACE] creating initial build for component happycloud.image
2022/02/16 16:22:21 [TRACE] creating initial build for component happycloud.image2
    types.bucket_test.go:125: Comparing component build labels: map[based_off:alpine source_image:another-happycloud-image version:1.7.0]
         against global build labels: map[based_off:alpine source_image:another-happycloud-image version:1.7.0]
    types.bucket_test.go:128: expected the initial build to have an additional build label but they are equal
    types.bucket_test.go:125: Comparing component build labels: map[based_off:alpine source_image:another-happycloud-image version:1.7.0]
         against global build labels: map[based_off:alpine source_image:another-happycloud-image version:1.7.0]
    types.bucket_test.go:128: expected the initial build to have an additional build label but they are equal
--- FAIL: TestBucket_UpdateLabelsForBuild_withMultipleBuilds (0.00s)
FAIL
FAIL    github.com/hashicorp/packer/internal/registry   0.646s

```

* Update CreateIntialBuildForIteration to initialize each build with a new map

Previously upon creating the initial build the same map, which was
initialized for the build_labels argument was being shared across all
build images. This was causing an issue with labels being backed by the
same map for all builds. This change ensures that all builds get their
own map with any global build labels copied over during the initial creation.

Closes #11573

Passing tests with changes on branch
```
RUN   TestBucket_CreateInitialBuildForIteration
2022/02/16 16:37:40 [TRACE] creating initial build for component happycloud.image
--- PASS: TestBucket_CreateInitialBuildForIteration (0.00s)
=== RUN   TestBucket_UpdateLabelsForBuild
2022/02/16 16:37:40 [TRACE] creating initial build for component happycloud.image
--- PASS: TestBucket_UpdateLabelsForBuild (0.00s)
=== RUN   TestBucket_UpdateLabelsForBuild_withMultipleBuilds
2022/02/16 16:37:40 [TRACE] creating initial build for component happycloud.image
2022/02/16 16:37:40 [TRACE] creating initial build for component happycloud.image2
    types.bucket_test.go:125: Comparing component build labels: map[based_off:alpine source_image:another-happycloud-image version:1.7.0]
         against global build labels: map[based_off:alpine version:1.7.0]
    types.bucket_test.go:125: Comparing component build labels: map[based_off:alpine source_image:the-original-happycloud-image version:1.7.0]
         against global build labels: map[based_off:alpine version:1.7.0]
--- PASS: TestBucket_UpdateLabelsForBuild_withMultipleBuilds (0.00s)

```

* Handle errors from bucket methods

* Update test cases

Initialize maps for bucket when calling NewBucketWithIteration
2022-02-22 15:34:09 -05:00
Wilken Rivera df5699c10d Rename integration program documentation (#11570) 2022-02-18 10:01:59 -05:00
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
Michael Weibel f718dbdcc0 docs: add link to builder list (#11571)
browsing through the documentation I was searching for the list of builders available. The obvious choice (builders page) didn't link to the list of builders and it took me a few minutes to find that. Adding a link to the plugins might speed up that bit and would avoid having to rescue to the search engine.
2022-02-16 11:39:04 +01:00
Adrien DelormeandWilken Rivera 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 <[email protected]>
2022-02-14 11:00:41 -05:00
Adrien Delorme 19fc5added Allow to parse pgp signed checksums (#11495)
* get go-getter with comment ignore in checksum files

* get github.com/hashicorp/go-getter/v2 v2.0.1
2022-02-11 15:02:26 -05:00
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 <[email protected]>

* 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 <[email protected]>

* Update core_wrapper.go

Co-Authored-By: Wilken Rivera <[email protected]>

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

Co-authored-by: Wilken Rivera <[email protected]>

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

Co-authored-by: Wilken Rivera <[email protected]>

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

Co-authored-by: Wilken Rivera <[email protected]>

* 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 <[email protected]>

Co-authored-by: Wilken Rivera <[email protected]>
Co-authored-by: Wilken Rivera <[email protected]>
2022-02-10 16:53:50 -05:00
jugglinmike 759cadaf0d Correct typo (#11555) 2022-02-09 15:19:01 -05:00
Kevin Wang 833bd51448 chore(website): bump @hashicorp/platform-cli (#11549) 2022-02-03 11:29:57 -05:00
Wilken Rivera 2ad15617cc core/hcl2: Fix issue preventing builds from pausing between provisioners when the --debug argument has been passed (#11537)
* Update HCL2 PackerConfig to call SetDebug mode for CoreBuild when --debug flag is passed

```
~>  packer build --debug /tmp/source.pkr.hcl
Debug mode enabled. Builds will not be parallelized.
null.example: output will be in this color.

==> null.example: Pausing after run of step 'StepConnect'. Press enter to continue.
==> null.example: Pausing before the next provisioner . Press enter to continue.
==> null.example: Running local shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell4149319610
    null.example: hi
==> null.example: Pausing before the next provisioner . Press enter to continue.
==> null.example: Running local shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell3210691290
    null.example: hi 2
==> null.example: Pausing after run of step 'StepProvision'. Press enter to continue.
==> null.example: Pausing before cleanup of step 'StepProvision'. Press enter to continue.
==> null.example: Pausing before cleanup of step 'StepConnect'. Press enter to continue.
Build 'null.example' finished after 8 seconds 284 milliseconds.

==> Wait completed after 8 seconds 284 milliseconds

==> Builds finished. The artifacts of successful builds are:
--> null.example: Did not export anything. This is the null builder
```

* Add call to SetOnError, and SetForce
2022-02-03 09:03:11 -05:00
packer-ci f0e7edd62d Putting source back into Dev Mode 2022-02-02 22:42:15 +00:00
packer-ci fa0f6e6fdc Cut version 1.7.10 v1.7.10 2022-02-02 22:01:38 +00:00
packer-ci 661b85e18c cut version 1.7.10 2022-02-02 22:01:36 +00:00
packer-ci 8b35473005 update changelog 2022-02-02 22:01:36 +00:00
Jenna Goldstrich 69b9088e89 Update Changelog for 1.7.10 2022-02-02 13:51:19 -08:00
Frank Korving 19ce39077b Fixes link to tutorial in README (#11524) 2022-02-02 15:51:58 -05:00
Adrien Delorme 69373d8415 Update psutils dep to avoid crash on m1 machine (#11546)
* Update psutils dep to avoid crash on m1 machine

* go mod tidy
2022-02-02 13:56:18 +01:00
Xiaoyu Zhong 37b38f9cb6 Fix format in plugin-location.mdx (#11543) 2022-01-31 11:20:45 +01:00
Adrien Delorme 5d17d7fe65 prevent duplicate local block creation (#11534)
* prevent duplicate local block creation

* remove duplicate locals block bug

* local variables: first get block, then decode it + simplify retry loop

* Update types.packer_config.go

* revert go get of hcl lib
2022-01-28 13:21:53 -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 4550d9ddae Update CONTRIBUTING guide for Packer (#11532)
This changes includes details around the CLA requirements for first time
contributors.
2022-01-26 16:03:00 -05:00
Dylan Staley 93c4b993e8 feat: display warning in IE 11 (#11528) 2022-01-26 10:46:42 +01:00
Zachary Shilton 19bb4a9110 website: link plugin version badges (#11513) 2022-01-24 16:38:24 +01:00
Wilken Rivera ebcfd0cd8e windows-restart: Update documentation for restart_check_command (#11507)
Closes #11467
2022-01-24 12:48:02 +01:00
Ethan Davidson f9606a1352 plugin manifest file has been renamed (#11508) 2022-01-24 12:46:47 +01:00
Wilken Rivera 6c713d1fd6 Add example of marking Vault values as sensitive variables (#11503)
* Add example of marking Vault values as sensitive variables

* Update website/content/docs/templates/hcl_templates/functions/contextual/vault.mdx
2022-01-24 11:14:48 +01:00
Bryce Kalow 83a0bcf67a chore: upgrade downloads page (#11504) 2022-01-19 13:05:08 -05:00
packer-ci fd487b4d8b Putting source back into Dev Mode 2022-01-19 17:10:10 +00:00
packer-ci a3f94fd3dd Cut version 1.7.9 v1.7.9 2022-01-19 15:50:11 +00:00
packer-ci 418284afee cut version 1.7.9 2022-01-19 15:50:09 +00:00
packer-ci d3cc584e8a update changelog 2022-01-19 15:50:09 +00:00
Wilken Rivera 45beb94442 Update test client to use Org/Project ID from client; not environment variables (#11502)
On a local developer machine there is a good chance the HCP_ORG_ID and
HCP_PROJECT_ID are not set since the HCP Packer client can derive this
information using the token/secret. This change initializes the location
structure with the information obtained from the client and not the
envs.

Results of tests before change with no HCP_ORG_ID or HCP_PROJECT_ID set
```
    par_test.go:185: (*packer_service.PackerServiceGetIterationOK)(nil)
    par_test.go:185: &{0 []  } (*models.GrpcGatewayRuntimeError) is not supported by the TextConsumer, can be resolved by supporting TextUnmarshaler interface
--- FAIL: TestAcc_PAR_pkr_build (3.94s)
FAIL
FAIL    github.com/hashicorp/packer/internal/registry/acctest   6.446s
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/packer/internal/registry/env       0.318s [no tests to run]
FAIL

```

Results of tests after change with no HCP_ORG_ID or HCP_PROJECT_ID set
```
2022/01/18 12:23:48 ui: --> null.example: Published metadata to HCP Packer registry packer/pkr-acctest-temp-2/iterations/01FSQ3EPPY69PMXJSTTFYDPQ5R
--- PASS: TestAcc_PAR_pkr_build (3.20s)
PASS
ok      github.com/hashicorp/packer/internal/registry/acctest   5.121s
testing: warning: no tests to run
PASS
ok      github.com/hashicorp/packer/internal/registry/env       0.155s [no tests to run]

```
2022-01-19 10:36:03 -05:00
Wilken Rivera 1d86f6311f Update CHANGELOG.md
Fix link to blog post
2022-01-18 21:00:17 -05:00
Wilken Rivera 5d1245c231 Update CHANGELOG
Add note for deprecated provisioner plugins
2022-01-18 20:58:42 -05:00
Wilken Rivera e6b2e8c15b Update CHANGELOG 2022-01-18 20:42:59 -05:00
Wilken RiveraandAdrien Delorme 2e4cfb05c5 Update CHANGELOG (#11501)
* Update CHANGELOG

* add a link

Co-authored-by: Adrien Delorme <[email protected]>
2022-01-18 15:23:08 -05:00
Adrien Delorme ce32c2a157 up plugin azure and go mod tidy (#11499) 2022-01-17 08:06:32 -05:00
Wilken Rivera 3f0a09de0c Update CHANGELOG 2022-01-14 15:22:13 -05:00
Kevin Wang 5e1be6f5ab feat: versioned-docs (#11434)
This PR introduces Versioned-Docs to Packer!
2022-01-13 13:07:13 -05:00
Kevin Wang 573011622b fix(algolia-index): Use TypeScript (#11496)
* fix(algolia-index): npm install -g npm@latest

* fix(algolia-index): `ts-node`

* fix(algolia-index): ts errors
2022-01-13 13:05:33 -05:00
Sylvia Moss 9ffd7ce938 Fail for revoked iterations (#11492)
* Fail for revoked iterations

* check if iteration is revoked on GetIteration

* fix fmt
2022-01-13 12:28:50 +01:00