Commit Graph
1128 Commits
Author SHA1 Message Date
anshul sharma b464f07522 description to the methods 2025-07-28 10:55:28 +05:30
anshul sharma 1ca1bf4b51 unit test cases for getting release from official site 2025-07-27 11:51:52 +05:30
anshul sharma d18efa1f96 added test cases for plugins getter 2025-07-27 08:18:21 +05:30
anshul sharma 034e357bec added test cases for getters 2025-07-26 11:19:17 +05:30
anshul sharma bc6d2a3ff4 added test cases for getters 2025-07-26 11:00:07 +05:30
anshul sharma 5f55f6f828 added test cases for getters 2025-07-26 07:32:56 +05:30
anshul sharma 3e60c779b5 added test cases for getters 2025-07-25 23:12:33 +05:30
anshul sharma 598387fe46 added test cases for getters 2025-07-25 23:05:39 +05:30
anshul sharma 37273a55fd github getter test cases 2025-07-25 22:53:03 +05:30
anshul sharma f8d6076305 manifest.json related changes 2025-07-24 15:22:03 +05:30
anshul sharma e55735296a manifest.json related changes 2025-07-24 15:20:12 +05:30
anshul sharma c1063f8644 manifest.json related changes 2025-07-24 15:19:11 +05:30
anshul sharma 26637ec673 manifest.json related changes 2025-07-24 15:15:26 +05:30
anshul sharma e8c1b290c5 lint fix 2025-07-23 12:56:58 +05:30
anshul sharma 2fd22549bf lint fix 2025-07-23 11:51:23 +05:30
anshul sharma 082c0b78b4 lint fix 2025-07-23 11:42:30 +05:30
anshul sharma 7b8e922105 changes for getter releases.hashicorp.com 2025-07-23 11:21:41 +05:30
anshul sharma 59a5abf4ab unit test coverage 2025-07-19 18:03:27 +05:30
anshul sharma 78aaaa5be8 unit test cases 2025-07-19 13:48:15 +05:30
anshul sharma 9728d4f947 unit test cases 2025-07-19 13:39:11 +05:30
anshul sharma 0869af9bdb cahnges for getting release from release official site 2025-07-18 20:47:33 +05:30
anshul sharma bdb93b458d cahnges for getting release from release official site 2025-07-18 20:40:33 +05:30
anshul sharma fb87672ec2 changes for pulling binary from releases.hashicorp.com 2025-07-14 18:57:49 +05:30
Tanmay Jain 24d73a2b6a Fixed Test Cases 2025-06-24 21:36:50 +05:30
Tanmay Jain 04dc274eaa IMPROV: Populating the PackerSensitiveVars variable 2025-06-24 21:36:50 +05:30
Tanmay Jain 9e90f48f2b Updated Tests 2025-04-28 12:48:45 +05:30
Tanmay Jain f41c2719a7 Deprecating Message method in UI interface 2025-04-24 14:16:02 +05:30
Lucas Bajolet 98198b5af8 packer: make GetBuilds return *[]CoreBuild
The GetBuilds function, available on both HCL2 and legacy JSON
configuration objects, used to return the Build interface.
This typing by interface is not useful in this instance, since all the
uses of `GetBuilds' are self-contained within Packer, and we're never
using any other implementation for it than `*CoreBuild`.

We've been relying on the dynamic type for all the builds being
*CoreBuild in some places of the code, so to avoid potential surprises
in the future, we'll change the signature now so it returns only
concrete types.
2025-02-13 16:06:02 -05:00
Jenna Goldstrich 347c57306c hcp: use enum for HCP SBOM upload
Since the protos for uploading an SBOM for a build have been changed to
use an enumeration instead of a plain string with the latest revisions
to the HCP Packer SBOM support feature, we update how we reference those
values for the SBOM format to use that enum instead.
2025-01-21 16:57:50 -05:00
Jenna Goldstrich 362c547211 hcp: integrate SBOM upload to HCP code
Since packer now supports keeping track of SBOMs produced during a
build, we add the code to integrate those changes into the internal/hcp
package, so we do upload them on build completion.
2025-01-21 16:57:50 -05:00
Devashish a353260f5d packer: add hcp-sbom provisioner
The hcp-sbom provisioner is a provisioner that acts essentially like a
download-only file provisioner, which also verifies the file downloaded
is a SPDX/CycloneDX JSON-encoded SBOM file, and sets up its upload to
HCP Packer later on.
2025-01-21 16:57:50 -05:00
Lucas Bajolet 9f6f0ba6a2 packer: pick protobuf/gob for serialisation (#13025)
As we're trying to move away from gob for serialising data over the
wire, this commit adds the capability for Packer to pick dynamically
between gob or protobuf for the serialisation format to communicate with
plugins.

As it stands, if all the plugins discovered are compatible with
protobuf, and we have not forced gob usage, protobuf will be the
serialisation format picked.

If any plugin is not compatible with protobuf, gob will be used for
communicating with all the plugins that will be used over the course of
a command.
2025-01-21 16:44:03 -05:00
huochexizhan 6e417bb883 fix: fix slice init length 2024-10-29 16:22:50 -04:00
Lucas Bajolet 586762564b hcl2template: intro and add UseSequential init opt
Following up on the DAG work, this commit adds a new option for
initialisation that disables DAG on request.

By default we are going to use the DAG approach, with an option to
fallback to using the older algorithm for evaluation in case users
end-up in an edge-case that prevents them from building a template.
2024-10-29 16:10:29 -04:00
Lucas Bajolet 3e3b136f3c packer: address unused lint errors 2024-07-18 10:51:17 -04:00
Lucas Bajolet 962ccdfc80 packer: address gosimple lint errors 2024-07-18 10:51:17 -04:00
Lucas Bajolet e8d3a55b5f packer: address errcheck lint errors
In a couple places in the codebase we didn't check the errors from
functions we execute.

In some cases this is harmless (or at least ignorable), but others may
need to log what went wrong, so for all the reported occurrences we
either ignore explicitly or handle the error with a log.
2024-07-18 10:51:17 -04:00
Lucas Bajolet 2009079246 packer: remove ineffasign pointed assigns/decls
Some of the variables we create are flagged by our linters as
ineffective assignments, which makes sense as those are generally fed by
code below, so we don't need to use the declaration/assignation syntax
(:=) but instead can fall back to using var with a type to get the zero
value of the declared entity.
2024-07-18 10:51:17 -04:00
Lucas Bajolet 4a7f5f38a6 Makefile: replace enumer upstream with dmarkham's (#13107)
Since the enumer implementation we used hadn't been updated for 5+
years, this didn't work with recent linux/go versions, and enumer
crashed while attempting to parse/analyse the source files.

There's another alternative on Github, forked from the one we used,
which seems more maintained now, and does produce the expected files in
Packer.
2024-07-16 21:14:27 -04:00
IAMDAVID0920 d625694a88 refactor: remove deprecated InitializePluginVersion, replace with NewPluginVersion 2024-06-03 09:37:30 -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
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 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
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