Commit Graph
18526 Commits
Author SHA1 Message Date
Wilken Rivera cf4a6016c9 Update plugin loading specification navbar 2024-06-06 14:55:22 -04:00
Wilken Rivera 50106ce90f Apply suggestions from code review 2024-06-06 14:52:37 -04:00
Lucas Bajolet 309c4528af docs: add plugin loading spec documentation
The logic for discovering and loading plugins is not well documented on
the current documentation.
This causes issues for users that have to troubleshoot why a particular
plugin cannot be found or installed, so this commit adds a specification
document, detailing what are Packer's expectations when it comes to
discovering plugins.
2024-06-06 10:44:32 -04:00
hashicorp-tsccr[bot] 4bd7e951b7 Result of tsccr-helper -log-level=info gha update . 2024-06-03 14:20:36 -04:00
Alex Boutin 3fb6b76701 Fixed wrong parameter in doc 2024-06-03 10:09:35 -04:00
komisan19 9390f717ca refactor: remove deprecated function 2024-06-03 10:07:33 -04:00
IAMDAVID0920 d625694a88 refactor: remove deprecated InitializePluginVersion, replace with NewPluginVersion 2024-06-03 09:37:30 -04:00
Lucas Bajolet 361a432eac version: bump main to 1.12.0-dev
Since we released 1.11.0 today, we need to have main point to the next
minor release of Packer so CI succeeds, otherwise we get an unexpected
output for the version being out-of-date.
2024-05-31 15:17:52 -04:00
d75975821f Update plugins install docs for v1.11.0 (#12995)
* IPE-727 first commit, adds release notes

* content for the 1.11 release notes

* updates to init CLI reference

* updates to install plugins CLI reference

* updates to source information on the packer block configuration reference

* updated Packer configuration page

* updated plugins installation overview page

* updated plugins installation usage page

* added Upgrades section

* added outline for an upgrade page for this version

* added comments for upgrade page outline

* renamed install plugins mdx and added redirects

* Apply suggestions from code review

Co-authored-by: Lucas Bajolet <[email protected]>

* fix nav

* fix bad links

* applying additional feedback

* Apply suggestions from code review

Co-authored-by: Lucas Bajolet <[email protected]>

* integrated rationale into release notes

* removed 'upgrade from older version' section in the upgrade instructions

* docs: fill-in the upgrade/1.11 document

* Apply suggestions from code review

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

* edits to upgrade 1.11 and release note

* Apply suggestions from code review

Co-authored-by: Lucas Bajolet <[email protected]>

* Apply suggestions from code review

Co-authored-by: Lucas Bajolet <[email protected]>

---------

Co-authored-by: Lucas Bajolet <[email protected]>
Co-authored-by: Lucas Bajolet <[email protected]>
Co-authored-by: Wilken Rivera <[email protected]>
2024-05-31 14:52:47 -04:00
Steven Kalt 766c3d7fef docs: consistent code blocks around types 2024-05-31 11:15:55 -04:00
Wilken Rivera a5d220e0a2 CHANGELOG: Update release date for 1.11 2024-05-31 09:18:24 -04:00
Lucas Bajolet 2ea0889441 scripts: re-add wait for changelog listing (#13002)
This got committed by accident into another PR, and since the change was
not approved to begin with, its inclusion was a mistake, so we revert it
now.
2024-05-31 05:49:23 -04:00
Lucas Bajolet 3591d64bb3 scripts: remove wait for changelog listing 2024-05-30 13:35:48 -04:00
Lucas Bajolet bfd264beda CHANGELOG: update changelog for Packer 1.11.0
Since the release will happen soon, we are updating the changelog to
list all the changes before that happens.
2024-05-30 13:35:48 -04:00
Lucas Bajolet b4a843c4e2 commands: reject constraints with pre-releases (#12999)
When remotely installing a plugin, constraints are used by Packer to
determine which version of a plugin to install.

These constraints can be arbitrarily complex, including operators and
ranges in which to look for valid versions.

However, the versions specified in those constraints should always be
final releases, and not a pre-release since we don't explicitly support
remotely installing pre-releases.

This commit therefore addds checks to make sure these are reported ASAP,
even before the source is contacted to list releases and picking one to
install.
2024-05-30 14:25:21 +02:00
Lucas Bajolet 8d4a9d66ab config: rm mono-component support from config file (#12998)
The global `PACKER_CONFIG` config file was already deprecated from
Packer core, but now with 1.11.0 since we remove support for
mono-component plugins, we are also removing the capability for that
config file to declare them.

Instead of silently not using those, Packer will now error with a
message pointing to the web docs on how to manage their plugins with the
updated workflows for Packer 1.11 and above.
2024-05-30 14:25:08 +02:00
Lucas Bajolet accbe97e1e hcl2template: add text(encode|decode)base64 funcs (#12997)
Compared to Terraform, Packer was lacking a capability to encode/decode
strings to/from base64-encoded text encoded with another encoding.

This could be problematic in some cases, mainly when working with
Windows, as most of the OS uses UTF-16LE as its standard encoding for
many operations.

Therefore, we take a page from Terraform here, and add those functions
to what Packer supports in an HCL2 context.
2024-05-30 14:24:46 +02:00
Wilken Rivera 92aabc7c2e Bump github.com/hashicorp/go-getter/v2 modules to v2.2.2 2024-05-22 09:25:43 -04:00
Lucas Bajolet 5d43239654 datasource/http: don't error on 2xx code
When a server returns a code that is not 200, we error in the current
state.

This is not conformant to the HTTP norm, as anything in the 2xx range is
considered a success, so the datasource should not error in this case.

Therefore, this commit fixes the condition in which we report an error,
so that anything in the 2xx range is now considered a success by the
datasource.
2024-05-21 14:26:26 -04:00
dependabot[bot] 493ddb1f2b build(deps): bump github.com/hashicorp/hcp-sdk-go from 0.95.0 to 0.96.0
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.95.0 to 0.96.0.
- [Release notes](https://github.com/hashicorp/hcp-sdk-go/releases)
- [Changelog](https://github.com/hashicorp/hcp-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcp-sdk-go/compare/v0.95.0...v0.96.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcp-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-05-20 12:39:47 -04:00
Lucas Bajolet a9ba14f505 website: fix myawesomecloud reference
When updating the docs in prevision for Packer 1.11.0, we changed the
templates that show how plugins are installed/discovered with commands
like packer init.

While doing so, a template had its component renamed to coolcloud, but
the following prose did not change, making the text inconsistent.

Since there are other mentions of myawesomecloud in the codebase, we
choose to settle on this one for that example too.
2024-05-20 12:39:14 -04:00
Wilken Rivera f1efdee2dd Bump Go version to 1.12.10 to address CVE-2024-24787
Packer does not rely on CGO and is not susceptible to CVE-2024-24787 vulnerabilities,
but we are upgrading as a safeguard.
2024-05-17 10:21:10 -04:00
Lucas Bajolet 97db9d82c4 packer: fix splitting error message on pathsep 2024-05-16 13:27:50 -04:00
Lucas Bajolet ec92d231bc packer: use filepath for getting plugin basename
When Discovering plugins installed through the `Discover` function, we
use the base name of the plugin binary we discovered preliminarly, then
we match its name against a regex to extract the prefix for the plugin's
components.

Extracting the base path used to be done with `path.Base`, which while
working perfectly on UNIX systems, does not on Windows as it uses `\\`
as their path separator.

To circumvent this problem, we use the `filepath` package to extract the
base name of the plugin instead, making the discovery logic work again
on Windows.
2024-05-16 13:27:50 -04:00
Lucas Bajolet a852434410 packer: fix listing on windows with .exe ext
Listing installed plugins on Windows requires the extension to be set in
the ListOptions, otherwise they are not discovered.

While working on the discovery code, and consolidating it in a single
location, we've forgotten to pass the argument to ListInstallations, so
that makes it impossible to automatically discover installed components
on Windows.

This commit fixes this issue for the plugins required, and the general
discovery process during build/validate.
2024-05-16 13:27:50 -04:00
Lucas Bajolet 682968d0df packer: don't load plugins with metadata in name
If a plugin is installed in the PACKER_PLUGIN_PATH, and its version
contains metadata, we reject it. This is because metadata is free-form
data, which could then make it possible to have multiple conflicting
versions of a plugin installed, so we don't support it and explicitely
reject plugins like those.

A valid plugin with metadata in its version information should be
installed without its metadata part, so there can only be one variant of
the plugin installed at a specific version.
2024-05-16 13:03:29 -04:00
Wilken Rivera e161367e28 Update CHANGELOG 2024-05-15 14:50:41 -04:00
Wilken Rivera a7591c950a Add details on the importance of using required_plugins 2024-05-15 14:50:24 -04:00
Wilken Rivera 27b5f27ec9 Add section for Non-GitHub source addresses 2024-05-15 14:50:24 -04:00
Wilken Rivera ce7205ed79 required_plugins:Add source addresses section
* Document the purpose of a source address
* Add a note about non-GitHub source addresses containing one of more sub-folder parts
2024-05-15 14:50:24 -04:00
Wilken Rivera 4015e4d7be init:Document force flag option for init command 2024-05-15 14:50:24 -04:00
Lucas Bajolet ec682afc4a addrs: require at least 3 parts to source URIs 2024-05-15 14:12:41 -04:00
Estelle PoulinandWilken Rivera 47d8df33e9 Update Example of Parsing a Manifest to Use Only jq (#12894)
* Update manifest.mdx

* Remove extra space in split function

---------

Co-authored-by: Wilken Rivera <[email protected]>
2024-05-15 11:27:30 -04:00
dependabot[bot] 4444623a16 build(deps): bump github.com/hashicorp/hcp-sdk-go from 0.93.0 to 0.95.0
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.93.0 to 0.95.0.
- [Release notes](https://github.com/hashicorp/hcp-sdk-go/releases)
- [Changelog](https://github.com/hashicorp/hcp-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcp-sdk-go/compare/v0.93.0...v0.95.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcp-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2024-05-15 10:16:49 -04:00
Lucas Bajolet d8a95a741b docs: update plugins install command documentation
Since the plugins install subcommand can install both remotely and
locally sourced plugins, we update the documentation for it on the
web-docs to reflect this change.
2024-05-14 14:58:55 -04:00
Lucas Bajolet c7f2508373 addrs: return error on ParsePluginSource
The ParsePluginSource function can be invoked from either a HCL2 context
(when parsing a required_plugins block), or from the command-line
itself.

While in the first context a hcl.Diagnostics is coherent, in case the
source to parse is a command-line argument, for example when installing
or removing a plugin, the error message cannot have an HCL context,
leading to errors that are incorrectly prefixed by a <nil> string dure
to the lack of a reference to attach the diagnostic to.

Therefore, in order to fix this behaviour, the logic that parses plugin
sources now returns an error, and attaching the error to an HCL subject
is done independently, if needed.
2024-05-14 14:47:06 -04:00
Lucas Bajolet 9b38e0eb5c addrs: limit source component length to 16
When specifying/installing plugins, a source URI is required for Packer
to be able to locate or install a plugin to the local plugin hierarchy.

The plugin hierarchy is based on the plugin source, where each component
in this hierarchy will become a directory.

In order to avoid sources with too many levels of nesting, causing a lot
of mkdirs, we limit the number of sources to 16 in this commit, this
should be long enough for most of our users.
2024-05-14 14:47:06 -04:00
Lucas Bajolet 9f3dd5b72a website: update install plugins docs
Since we're changing how packer manages plugin installation with 1.11.0,
we reflect those changes to the website documentation.

Now, we only describe the packer init and packer plugins install
commands, along with the `--path` flag for installing from a local
source.

The explanations of how packer discovers and picks which version of a
plugin to load are also included, along with the list of constraints
that determine whether a plugin can be considered or not to be loadable.
2024-05-14 14:05:17 -04:00
Lucas Bajolet 266c4d99d2 website: update discovery/envvar documentation
With the changes coming up for 1.11.0, we update the Packer
configuration docs so they describe the one way to load plugins, and the
two environment variables which can be set to change this behaviour.
2024-05-14 14:05:17 -04:00
Lucas Bajolet f52502c464 website: remove trailing whitespace 2024-05-14 14:05:17 -04:00
Wilken Rivera 9f2d6ce1fc docs/plugins/remove: Update command usage text
* Add an example of piping the results of `plugins installed` to `plugins remove`
2024-05-14 13:13:22 -04:00
Lucas Bajolet d2ade9a783 packer: register plugin components only once
When running a packer command on an HCL2 template, depending on whether
or not there are required_plugin blocks defined, Packer may need to
discover and register a plugin's components multiple times.

This is the behaviour ever since those blocks were introduced to Packer,
but given we are doing the operation multiple times, this is suboptimal.

This commit changes the way things works by first doing the restricted
discovery of plugins (as dictated by required_plugins), then proceeding
to the global discovery, with the change that subsequent component
discoveries will not have precedence over those pre-discovered anymore.

This allows us to invert the call order of both discovery phases safely,
and maintains the constraints described in the templates.
2024-05-14 11:41:18 -04:00
Lucas Bajolet f80ba2821b packer: error multiple paths in PACKER_PLUGIN_PATH
When a user defines PACKER_PLUGIN_PATH in their environment, we need to
error if their path defines multiple directories separated by `:`.

This used to be supported, but this is removed with 1.11 as we're
simplifying the loading process for plugins, so we opted to fall-back to
only one plugin directory supported.
2024-05-10 15:11:41 -04:00
Lucas Bajolet 5ced785f2f docs: fix typo in HCP Packer artifact/version docs
In the full example for both the hcp-packer-artifact and
hcp-packer-version the hcp-packer-version reference in the example
template was mistakenly spelled as "hcp_packer_version", which won't
work, so we fix that typo here.
2024-05-10 09:36:47 -04:00
Wilken Rivera 20345f9118 Add check to prevent the installation of version constraints matching a prerelease
* Refactor InstallError string messages
2024-05-08 16:01:29 -04:00
Wilken Rivera 11dc684334 Add ConintuableInstallError for continuing installation on version mismatches 2024-05-08 16:01:29 -04:00
Wilken Rivera 2e8bdb5c4a Use single buffer for storing binary file before writes
* Only create plugin directories if there is  potential plugin install
2024-05-08 16:01:29 -04:00
Wilken Rivera 2ca5b2707c Add PrereleaseError for handling failed pre-release version installs
```
~>  packer init mondoo_req.pkr.hcl
Failed getting the "github.com/mondoohq/cnspec" plugin:
error:
Remote installation of the plugin version 10.8.1-dev is unsupported.
This is likely an upstream issue with the 10.8.1 release, which should be reported.
If you require this specific version of the plugin, download the binary and install it manually.

packer plugins install --path '<plugin_binary>' github.com/mondoohq/cnspec

```
2024-05-08 16:01:29 -04:00
Wilken Rivera eafdda8a94 Update plugin-getter version matching check
This change is an attempt to remove the need for additional temporary files, along with
calls to stat the temp files, to reduce the number of files being created, opened, and closed.
In addition to this change, the logic for falling back to a previous version if the highest matched version
is a pre-release has been removed. Instead we will assume that any prior versions will exhibit the same issue and
return immediately. A user can install the version manually if they will or they can modify their version constraint
to a properly released version.
2024-05-08 16:01:29 -04:00
Lucas Bajolet 35bd020a3e plugin-getter: rm vocal log on checksum entries
When a checksum file for a release is downloaded and iterated upon to
find the compatible binary for a release, we used to log each
non-compatible entry in the logs.

This is noisy as we know there's going to be multiple entries that don't
match the host's os/arch, and there's no good reason to show those, so
we silence them.
2024-05-08 16:01:29 -04:00