Commit Graph
18526 Commits
Author SHA1 Message Date
dependabot[bot] 7c498d7217 build(deps): bump dessant/lock-threads from 3 to 4 (#12145)
Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 3 to 4.
- [Release notes](https://github.com/dessant/lock-threads/releases)
- [Changelog](https://github.com/dessant/lock-threads/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dessant/lock-threads/compare/v3...v4)

---
updated-dependencies:
- dependency-name: dessant/lock-threads
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-08 07:31:51 -05:00
Wilken Rivera bd53a7e237 Add github.com/hashicorp/hcp-sdk-go to dependabot tracking (#12147) 2022-12-08 07:29:28 -05:00
Lucas Bajolet 4846301ff4 hcp: reject template type changes between builds
As a follow-up to tracking the template type for an iteration, we
actively check that it remains consistent between two invocations of
packer, and reject the update if it is not the case.
2022-12-07 16:18:52 -05:00
Lucas Bajolet 6d0045607c hcp: record template type when creating iterations
In order to ensure users keep the same templates between two packer
invocations for a single iteration, we start tracking the type of
template used when building images.
2022-12-07 16:18:52 -05:00
Lucas Bajolet 08f1e85fb1 hcp: fix payloads for new SDK version
The grpc_gateway v2 changes had some repercussions in the payloads of
the API calls, making the current code non-functional against the latest
SDK.
2022-12-07 16:18:52 -05:00
Christophe Jauffret abb2f79155 Add Nutanix docs (#12131) 2022-12-05 11:58:59 -05:00
HashiBot 97bdeadbe6 chore: Update Digital Team Files (#12139)
* Update generated website Makefile

* Update generated scripts (should-build.sh)

* Update generated scripts (website-start.sh)

* Update generated scripts (website-build.sh)
2022-12-05 11:53:10 -05:00
Wilken Rivera dbeeab448a cmd/hcl2_upgrade: Generate variable block for all referenced user input variables (#12136)
Currently the HCL2 upgrade command generates a valid variable block for all variables
within the JSON variables property. However JSON templates in Packer support variable
interpolation for input variables defined within a variable definition file without
it being declared within the variables property. When upgrading a JSON template to HCL2
the user variable reference gets converted to var.<var_name>. The upgraded template ultimately
fails on validation or build execution with undefined variable errors, with this change the upgrade
command will now create a variable block for all input variables referenced within the build template
to ensure all required variables been defined.
2022-11-30 15:25:25 -05:00
Wilken Rivera f29b6da035 Merge pull request #12130 from hashicorp/dependabot/github_actions/atlassian/gajira-create-3.0.1
build(deps): bump atlassian/gajira-create from 2.0.1 to 3.0.1
2022-11-28 13:37:41 -05:00
Wilken Rivera 077c15e9a6 Merge pull request #12129 from hashicorp/dependabot/github_actions/atlassian/gajira-login-3.0.1
build(deps): bump atlassian/gajira-login from 2.0.0 to 3.0.1
2022-11-28 13:37:29 -05:00
dependabot[bot] 15a9463030 build(deps): bump atlassian/gajira-create from 2.0.1 to 3.0.1
Bumps [atlassian/gajira-create](https://github.com/atlassian/gajira-create) from 2.0.1 to 3.0.1.
- [Release notes](https://github.com/atlassian/gajira-create/releases)
- [Commits](https://github.com/atlassian/gajira-create/compare/v2.0.1...v3.0.1)

---
updated-dependencies:
- dependency-name: atlassian/gajira-create
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-11-24 19:03:19 +00:00
dependabot[bot] 5dff58d776 build(deps): bump atlassian/gajira-login from 2.0.0 to 3.0.1
Bumps [atlassian/gajira-login](https://github.com/atlassian/gajira-login) from 2.0.0 to 3.0.1.
- [Release notes](https://github.com/atlassian/gajira-login/releases)
- [Commits](https://github.com/atlassian/gajira-login/compare/v2.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: atlassian/gajira-login
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2022-11-24 19:03:15 +00:00
Lucas Bajolet 338c95b2eb datasource: remove packer-image-iteration
The `packer-image-iteration' datasource is an undocumented, and
unexported datasource, so it cannot be used by clients.

Since this is dead weight, we can remove it safely from the codebase.
2022-11-17 15:47:01 -05:00
Lucas Bajolet ccb5a22bb4 hcp: remove duplicated build registration for JSON
In JSON templates, we register the builds to process on HCP at the
initialisation of the Registry.

However, during the HCP breakout, this code was duplicated with a slight
difference for the JSON templates, and the build names were registered
once during initialisation, with the expected full name, and once at the
start of PopulateIteration, with the truncated name.

This caused a bug when processing a template that contains a builder
with both a name and a type, as both would be registered, but only one
would complete, leading to the iteration being unable to complete.
2022-11-17 15:24:20 -05:00
Lucas Bajolet 14cad650ca website: add docs for variable warning bypass opts
When the options for bypassing/enabling assigned and undeclared
variables were added to Packer, the website documentation for those
commands and options was not updated.

This commit adds some documentation for those options.
2022-11-17 09:29:55 -05:00
Lucas Bajolet bb2384c56a command/validate: add option to eval datasources
When packer validate is invoked, it does not try to evaluate the
datasources before attempting to decide if the template is valid.

In many cases, this works, but sometimes it will fail as the value is
unknown by the validation code.

Since the validation code for all the elements of a Packer template is
left to be implemented by plugins, we cannot rely on checking for
unknown values everywhere, especially since the unknown references are
replaced automatically by a value of the right type for the
configuration expected.

So, in order for such configurations to be validable, we add an extra
option to packer validate, that will let users evaluate the datasources
from a template.
2022-11-17 09:29:55 -05:00
Wilken Rivera 4af0619721 Merge pull request #12112 from hashicorp/amb.fix-duplicate-line
Removing duplicate line of text
2022-11-15 10:42:34 -05:00
Ashlee M Boyer 991331c1fc Removing duplicate line of text 2022-11-14 19:52:51 -05:00
Wilken Rivera 57cbe4e203 core: Update validation options for undeclared variables (#12104)
* Update validation options for undeclared variables

In an effort to help users move from JSON to HCL2 templates the support for
variable definitions files are being updated to ignore undeclared
variable warnings on build execution. For legacy JSON templates builds no
warnings are displayed when var-files contain undeclared variables.

Since preferred mode HCL2 templates is to be explicit with variable
declarations - they must be declared to be used - validation for
undeclared variables still warns when running `packer validate`. A new
flag has been added to the validate command that can be used to disable
undeclared variable warnings.

* Update validation test for unused variables

Example Run
```
~>  go run . validate -no-warn-undeclared-var -var-file
command/test-fixtures/validate/var-file-tests/undeclared.pkrvars.hcl
command/test-fixtures/validate/var-file-tests/basic.pkr.hcl
The configuration is valid.

~>  go run . validate -var-file
command/test-fixtures/validate/var-file-tests/undeclared.pkrvars.hcl
command/test-fixtures/validate/var-file-tests/basic.pkr.hcl
Warning: Undefined variable

The variable "unused" was set but was not declared as an input variable.
To declare variable "unused" place this block in one of your .pkr.hcl
files,
such as variables.pkr.hcl

variable "unused" {
  type    = string
  default = null

}

The configuration is valid.

~>  go run . build -var-file
command/test-fixtures/validate/var-file-tests/undeclared.pkrvars.hcl
command/test-fixtures/validate/var-file-tests/basic.pkr.hcl
file.chocolate: output will be in this color.

Build 'file.chocolate' finished after 744 microseconds.

==> Wait completed after 798 microseconds

==> Builds finished. The artifacts of successful builds are:
--> file.chocolate: Stored file: chocolate.txt
```

* Rename Strict field to WarnOnUndeclaredVar

The field name Strict is a bit vague since it is only used for
checking against undeclared variables within a var-file definition.
To mitigate against potential overloading of this field it is
being renamed to be more explicit on its usage.

* command/build: Add warn-on-undeclared-var flag

Now that the default behaviour is to not display warnings for undeclared variables
an optional flag has been added to toggle the old behaviour.

```
~>  go run . build -warn-on-undeclared-var -var-file command/test-fixtures/validate/var-file-tests/undeclared.pkrvars.hcl command/test-fixtures/validate/var-file-tests/basic.pkr.hcl
Warning: Undefined variable

The variable "unused" was set but was not declared as an input variable.
To declare variable "unused" place this block in one of your .pkr.hcl files,
such as variables.pkr.hcl

variable "unused" {
  type    = string
  default = null

}

file.chocolate: output will be in this color.

Build 'file.chocolate' finished after 762 microseconds.

==> Wait completed after 799 microseconds

==> Builds finished. The artifacts of successful builds are:
--> file.chocolate: Stored file: chocolate.txt
```
2022-11-14 17:06:45 -05:00
Lucas Bajolet 719c8681cd registry: don't use datasource output for ancestry
The ancestry inferral code relied on HCP datasource outputs for deciding
what would be the ancestry for an image built with HCP.

This brings a dependency into the hcp package, which is not really
necessary as we only need a few information from those entities, hence
this commit removes the full dependency on the structures, in favour of
more focused data structures where we only cherry pick what is necessary
for this code.
2022-11-14 13:31:35 -05:00
Wilken Rivera 606e6c48f1 internal: reorganise registry/HCP code
This commit reorganises the code for both the registry/API and the
Orchestrator/Registry.

The main difference with the previous version is how stuff is exposed.
Now we only expose a Registry interface to the outside (previously named
Orchestrator), which has several implementations: null is the default,
and is returned if HCP is not enabled.

The other implementations being HCL/JSON, both private to the hcp
sub-package.

The api (previously `registry') is the set of functionality that
abstracts and calls the HCP API.
It was meant to be merged with the `hcp' package, but because of a
dependency loop with the datasources, both are separated for now.
2022-11-14 13:31:35 -05:00
Lucas Bajolet 1cee460d0d hcp: extract all HCP-related code to hcp package
As part of the work to displace everything related to HCP from scattered
places around the Packer code, we move it all to an hcp package.

This in turn reduces the amount of code that the commands have to
integrate, and leaves the HCP details to its own enclave.
2022-11-14 13:31:35 -05:00
Lucas Bajolet dad07c6097 hcp: keep map of build names for hcp tracking
To be able to track HCP builds during a Packer build, we need to
propagate the name used for registering the build to HCP.

This works out-of-the-box for JSON templates, as the build's name is
always the builder's, so there's no confusion on that.

For HCP templates however, there's a possibility for a template to
define a name for the build, which is returned by a CoreBuild's Name()
function, in addition to the source's Type/Name.
The builds are registered to HCP with the source.String() function
however, which does not contain the build's name. This prevents any
build containing a name to work, as their name/source.String does not
match.

The name we registered the build with is stored in a CoreBuild as the
Type attribute, but cannot be safely accessed, as builds are types
within the command as packersdk.Build, which only exposes Name() for
this purpose.

In order to circumvent this problem, and as a way to present a prototype
of solution that will likely have to be discussed before we merge it,
this commit hotfixes the issue.
2022-11-14 13:31:35 -05:00
Lucas Bajolet f3e4c2c3bb tmp: move HCP logic to unwrap builds/post 2022-11-14 13:31:35 -05:00
Lucas Bajolet f0d0a0e6c5 internal/registry: reverse image check condition
In order to determine whether or not a build is done or needs
processing, we check 3 things:

1. that its status is not done
2. that its ID is not empty
3. that it has no images linked to it

The was the image check was phrased indicated that we checked for the
reverse, so we reverse the naming to make it less confusing.
2022-11-14 13:31:35 -05:00
Wilken Rivera c1cd718e0e Update github.com/stretchr/testify to address vulnerabilities in dependencies
* Resolves CVE-2022-28948 in gopkg.in/yaml.v3

Many thanks to chncaption for bubbling this vulnerability in #12908
2022-11-11 10:36:07 -05:00
Lucas Bajolet 9d9f6d3a9a packer: try previous ver. on unavailable checksum
When Packer tries to get the latest version of a plugin, it will attempt
to get the latest version from a list that is picked from the list of
releases, fetched directly from Github.

What may happen is that a release is triggered, the assets are not yet
available, including the checksum file, which is uploaded last, at the
end of the release process.

This causes any client that tries to get the latest version of a plugin
to fail during that window, as the code will fail immediately whenever a
checksum file is unavailable.

To circumvent this issue, and fallback to a previous version, we
acknowledge that a checksum was unavailable then trying to get the
latest version, and fallback to a previous one.
2022-11-11 06:50:38 -05:00
Lucas Bajolet 0224d6e0de plugin_test: error on missing checksum file
The mockPluginGetter would always succeed in returning a file from the
list of suggested releases, which does not let us test what happens when
a release is not yet complete, and a checksum file fails to be fetched
from the source.

This commit changes this behaviour so that we get an error when a
checksum does not exist, mirrorring what happens in real conditions.
2022-11-11 06:50:38 -05:00
dependabot[bot] 113bc5eea4 Bump github.com/hashicorp/hcl/v2 from 2.13.0 to 2.14.1 (#12015)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.13.0 to 2.14.1.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.13.0...v2.14.1)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-02 13:07:31 -04:00
Zachary Shilton f3a0dbc491 chore: add empty page redirects 2022-11-01 17:15:02 -04:00
Zachary Shilton 1ec6b70028 chore: stub in empty page redirects 2022-11-01 17:15:02 -04:00
Paulo Dias 8ce3aae2f7 Add packages for iso builds 2022-10-28 13:12:17 -04:00
Wilken Rivera c6f530d6d5 Update CHANGELOG.md 2022-10-28 12:49:21 -04:00
Lucas Bajolet 83ca7c203c prepare 1.8.5 2022-10-28 12:13:31 -04:00
Lucas Bajolet 83cc093d50 cut release 1.8.4 v1.8.4 2022-10-28 10:43:05 -04:00
Wilken Rivera ef1fb675f7 Update CHANGELOG for 1.8.4 (#12083)
* Update CHANGELOG for 1.8.4

* Update HCP Packer environment variable notes

* Add CHANGELOG entry for 12068
2022-10-28 10:33:53 -04:00
Wilken Rivera 10c7b999ea Update bundled plugins to latest available version (#12085) 2022-10-27 18:24:13 -04:00
Lucas Bajolet 68ddb2f89d hcl2_upgrade: add share_image_gallery workaround (#12087)
In azure templates, the shared_image_gallery was mistakenly considered
an attribute while this is supposed to be a block.

This is due to a heuristic we use for deciding whether a JSON object is
to be translated to an attribute or a block that fell short as the
shared_image_gallery does not contain complex types.

This cannot be fixed trivially for the general case, so we add this
entity to the list of workarounds until we can implement something more
robust.
2022-10-27 18:09:40 -04:00
Jenna Goldstrich 0bac9b6f63 Remove a skip for darwin arm64 (m1/m2 macs) for exec tests. (#12088) 2022-10-27 17:52:26 -04:00
Lucas Bajolet 296562614f hcl2_upgrade: fix liniting issues with fmt.Sprintf
Some literal strings without format-string directives nor arguments were
littered around the hcl2_upgrade command's code, which is pointed out by
the linters.

Since they serve no purpose, we remove them.
2022-10-26 15:35:02 -04:00
Lucas Bajolet 3c249c0d42 hcl2_upgrade: replace passthroughs by pre-visit
In previous versions of hcl2_upgrade, we referenced a list of
passthrough statements from the original JSON template to be replaced by
their equivalent Go-template in HCL2.

This works but requires us to explicitely accept every possible
templated variable in order to not ever encounter <no value> in our
generated HCL2 templates.

This is suboptimal, hence this commit changes approach by pre-visting
the AST from the original Go Template, escaping every sequence that is
not covered by the list of functions we can migrate. Pipes are also
excluded from this function.
2022-10-26 15:35:02 -04:00
Wilken RiveraandLucas Bajolet bc55d6d2d6 [HPR-763] Update HCL variable documentation (#12058)
* Update HCL variable documentation

* Add supported arguments section for variables
* Add inpage links to key variable arguments
* Reorder content to cluster assignment documentation together
* Split variable definitions into two sub-sections

Co-authored-by: Lucas Bajolet <[email protected]>
2022-10-24 20:58:32 -04:00
Zach Shilton 7f533a0a63 website: fix intro link (#12076) 2022-10-24 15:24:42 -04:00
Zach Shilton 82062f05e9 website: reset redirects file (#12066)
* website: reset redirects file

* docs: add note on product prefix, with example

* docs: fix example redirect
2022-10-24 14:48:02 -04:00
HashiBot ed859dccb3 chore: Update Digital Team Files (#12069)
* Update generated scripts (website-start.sh)

* Update generated website Makefile

* Update generated scripts (website-build.sh)

* Update generated scripts (should-build.sh)
2022-10-24 14:46:25 -04:00
Wilken Rivera 1296cbfc92 Update links to packer-template-configuration (#12072) 2022-10-24 12:59:32 -04:00
Wilken RiveraandLaura Pacilio 414b576def [HPR-574] Add documentation for configuring Packer for HCP Packer (#12022)
* Add documentation for configuring Packer for HCP Packer

This change works to document the two configuration options for setting
up Packer to publish build artifacts to an active HCP Packer registry.
Currently the HashiCorp Cloud Platform documents the process for
configuring Packer via a HCL template, which is the preferred route.
This documentation focuses more on the use of environment variables for
configuring Packer for HCP Packer, which is necessary for legacy JSON
template users looking to publish to HCP Packer.

In light of the new HCP Packer documentation page we've opted for a shorter
version of the HCP Packer introduction section.

* Applying the first round of suggestions to tighten up the documentation.
* Move HCP Packer side bar to top
* Move intro into docs
* Add redirects for intro pages

Co-authored-by: Laura Pacilio <[email protected]>
2022-10-24 12:51:14 -04:00
Wilken Rivera 7cb0c98925 Merge pull request #12033 from hashicorp/error_messages_rework
[HPR-575] command/build: rework HCP-related error messages
2022-10-21 11:25:15 -04:00
Zach ShiltonandWilken Rivera 879fd9035c fix: update redirected and broken links (#12060)
* website: fix broken links on /docs/templates

* fix: redirected install-plugins link

* fix: debugging link

* fix: secrets manager link in docs

* fix: secrets manager link in source

* fix: amazon ami plugin link in docs

* fix: amazon ami plugin link in source

* fix: extending plugins link

* fix: plugins/builders/amazon links

* fix: various builders links

* fix: various amazon builder links

* fix: redirected terminology link

* fix: custom-provisioners link

* fix: docker-push redirected plugin link

* fix: googlecompute plugin links

* fix: hyperv iso plugin links

* website: update link to hcl upgrade guide

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

Co-authored-by: Wilken Rivera <[email protected]>
2022-10-21 11:00:58 -04:00
Lucas Bajolet 61c810e720 command: rework HCP-related error messages
The HCP error messages were sometimes a bit terse in terms of the
information it bubbles up to the user.
This made them useful for people who already knew what to look for, but
newcomers would almost certainly be lost because of the lack of
information in those.

To improve on this situation, we reword most of those error messages in
this commit.
2022-10-21 10:32:45 -04:00