Commit Graph
18395 Commits
Author SHA1 Message Date
Lucas Bajolet e1b2669da9 command: migrate tests using the comment plugin
In order to test the Packer subcommands, some tests rely on a plugin:
github.com/sylviamoss/comment.

This plugin is outdated compared to our SDK, and some of the binaries
releases don't match what is expected by Packer, i.e. v1.0.0 vs. v0.2.8.

To fix that, we migrate to use the hashicups plugin, which is our demo
plugin for Packer, and is actually maintained, and up-to-date, which
will make those tests more reliable moving forward.
2024-02-23 16:01:01 -05:00
Lucas Bajolet f1a1726bb6 packer: support loading pre-release plugins
When a pre-release version of a plugin is locally installed, it may or
may not be loaded depending on the constraints expressed in the template
being executed.

If the template contains constraints for loading the plugin, it would be
ignored, while if that wasn't present, it would be loaded.

This is inconsistent, and deserves to be addressed, which is what this
commit does.

With this change, plugin pre-releases are now loaded, provided the
version reported matches the constraints, independently from its
pre-release suffix `-dev'.
Also, if a release with the same version is also installed alongside the
pre-release version of a plugin, it will have precedence over the
pre-release.
2024-02-23 14:24:11 -05:00
Lucas Bajolet 473d33c8d6 packer: fix plugin version sorting and pickup
When Packer orders the plugins by their version, we'd assumed it was
ordered from highest to lowest.

However, this was the case because our implementation of `Less' was
actually returning `>=', which is not what it was supposed to do.

This commit therefore fixes the implementation of `Less' to do what it
is documented to do, and ensures the behaviour is correct through
additional testing.
Changing this requires some changes to the loading process as well
because of the aforementioned assumption with regards to ordering.
2024-02-23 14:24:11 -05:00
Lucas Bajolet 20b8f34c44 command: move plugins remove tests outside of repo
Since the plugins remove subcommand now only loads valid plugins, it
cannot run on mock data anymore, and the logic for creating a valid
plugin hierarchy is not present in this repository, but does in another,
so we move those tests from here to that repository in order to continue
testing them.
2024-02-23 14:24:11 -05:00
Lucas Bajolet 16b7d7d5bb plugin-getter: reject plugin version mismatches
When a plugin is loaded from Packer, we now check that the version it
reports matches what the name implies. In case there's a mismatch, we
log, and reject the binary.
2024-02-23 14:24:11 -05:00
Lucas Bajolet 828073bf5f plugin: consolidate loading logic
Right now we had two paths for discovering installed plugins, i.e.
through plugin-getter's `ListInstallations' function, or through the
`Discover' call, which relied on a glob to list the installations.

This was required since we allowed plugins to be installed in multiple
locations, and with different constraints.

Now that we force a certain convention, we can consolidate the logic
into ListInstallations, and rely on that logic in `Discover' to load a
plugin into the PluginConfig for the current Packer run.
2024-02-23 14:24:11 -05:00
Lucas Bajolet ed127026d7 plugin-getter: implement Sort interface for List
The plugin installation list should be sorted according to a name first,
then version second basis.
Right now, we only rely on the glob to add plugin installs to this list,
making the order unreliable since the lexicographical order is not the
order in which we want to see the same plugin ordered (e.g. v1.0.9 >
1.0.10).

To fix this, we implement a logic for sorting a list of installations
that does what's described above with more accuracy.
2024-02-23 14:24:11 -05:00
Lucas Bajolet fbc2ca90ec plugin-getter: fix docs for Installation
The comments weren't capitalised correctly, and the directory example
included the `packer-plugin-' prefix, which should not be the case in
reality.
2024-02-23 14:24:11 -05:00
Lucas Bajolet e7d4bf2deb packer: remove path argument to discover installed
Since the plugin directory should now be unique instead of a list, we
can use it directly from the receiver's structure instead of as a
parameter to the function.
2024-02-23 14:24:11 -05:00
Lucas Bajolet be323c0d6f packer: remove directory slices from structs
Since we'll only look in the plugin directory, and not from multiple
sources now, for installing/listing plugins, we can simplify the
structures which used to accept multiple directories so they only accept
one.
2024-02-23 14:24:11 -05:00
Lucas Bajolet ff3cec1f95 packer: rm support for manually-installed plugins
Since we'll be only accepting plugins installed locally along with a
shasum, and those that adopt the convention we introduced with
required_plugins, we remove support for plugins that only have a
packer-plugin-.* type name.
2024-02-23 14:24:11 -05:00
Lucas Bajolet 1c4620e966 packer: only support one directory for plugins
Since we're removing the alternative plugin installation directories in
favour of only supporting installing them in the PACKER_PLUGIN_PATH
directory, we only return one directory when getting the known plugin
directories.
2024-02-23 14:24:09 -05:00
Jenna Goldstrich 72db1c35e9 Don't use old nomenclature in terminology docs (#12843) 2024-02-16 10:40:58 -08:00
Lucas Bajolet 548893bbee build: don't suggest lack of HCP support on fail
When running a build with HCP Packer enabled, Packer attempts to push
the build status to HCP.
If the build fails, we update the status to BUILD_FAILED, and that's the
end of it.
If however the build succeeds, Packer attempts to get the HCP artifact
from the builder, which will only succeed if the builder supports it.
Otherwise, we'll get either nil, or an artifact type that is not
compatible with what is expected for HCP support.

When either of those happens, we warn that the builder may not support
HCP Packer at all, so users are aware of the problem.

However, when the error was introduced, it only looked at the fact that
an error was produced, independently of the type of error. This caused
legitimate errors while building to be reported as potential
incompatibility between the builder and HCP, which was confusing to
users.

This commit changes this by introducing a new error type, only produced
when the artifact either is nil, or failed to be deserialised into a HCP
artifact, which lets us produce the incompatibility warning with more
accuracy.
2024-02-13 14:47:06 -05:00
dependabot[bot] 9b01bfa486 build(deps): bump github.com/hashicorp/hcp-sdk-go from 0.82.0 to 0.83.0 (#12827)
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.82.0 to 0.83.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.82.0...v0.83.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]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-08 12:13:09 -05:00
Wilken Rivera 4d38323ae1 Remove external Plugins from left navbar 2024-02-08 09:19:54 -05:00
Lucas Bajolet dff49df129 hcl2template: check bucket name at parse-time
Not validating the bucket's name during parse leads to configurations
being marked as valid, even if the bucket name is not, which will fail
during a real build afterwards.

To avoid this problem and fail with an error as quickly as possible, we
add a check during parsing, so that it gets reported for validate as
well.
2024-01-31 09:56:57 -05:00
Heat Hamilton 767005149c website: fix husky command (#12821)
* Change husky pre-commit hook to work in sub-directory of .git

* Added dart-linkcheck back in for linkcheck command
2024-01-30 17:25:03 -05:00
Wilken Rivera 08d41c2679 Fix URL rewrite check error for DevDot portal (#12818)
Refer to job https://github.com/hashicorp/packer/actions/runs/7709708630/job/21011464094
2024-01-30 15:33:21 -05:00
Wilken Rivera ca066f73bf Update CHANGELOG 2024-01-30 05:27:00 -05:00
Wilken Rivera 1e6041ab05 docs/plugins:Fix incorrect plugin directory path 2024-01-30 05:25:57 -05:00
Heat Hamilton ec403555dc Updated next, node, npm, nvmrc and Docker node versions; added husky pre-commit hook v9 2024-01-29 16:24:27 -05:00
Wilken Rivera da65323918 Remove all external plugin docs
This change removes all external plugin docs using the old remote docs framework
from the Packer core documentation in favor of the Packer integration framework.
Remove plugins will be enabled on the integration portal and contacted to merge their PRs to finalize the integration migration.
2024-01-29 15:06:08 -05:00
Devashish 682eca2877 Remove repeated code 2024-01-26 14:31:04 -05:00
Devashish 4b591d6937 Add PR suggestions 2024-01-26 14:31:04 -05:00
Devashish 14ce2a559c fix shell session in the docs 2024-01-26 14:31:04 -05:00
Devashish b77d581cda Add the deprecation warning and update docs 2024-01-26 14:31:04 -05:00
Devashish cbc16cfed5 Add versionFingerprint to EvalContext 2024-01-26 14:31:04 -05:00
Devashish 91ce35f439 Expose versionFingerprint instead of versionId from packer template 2024-01-26 14:31:04 -05:00
Wilken RiveraandLucas Bajolet 12b8c885a3 Update error messaging for HCP incompatible plugin builds (#12800)
* Update error messaging for HCP incompatible plugin builds

* Update command/build.go

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

---------

Co-authored-by: Lucas Bajolet <[email protected]>
2024-01-25 11:32:18 -05:00
3fa637c608 Migrate HCP Packer to API V2 and new nomenclature changes (#12794)
* add hcp packer new nomenclature updates

* Update docs with nomenclature changes

* Update navigation bar links

* Bump github.com/hashicorp/hcp-sdk-go from 0.81.0 to 0.82.0

* fix acceptance test template

---------

Co-authored-by: sylviamoss <[email protected]>
Co-authored-by: Wilken Rivera <[email protected]>
2024-01-24 13:17:35 -05:00
dependabot[bot] 91ce018cf1 build(deps): bump github.com/hashicorp/hcp-sdk-go from 0.79.0 to 0.81.0
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.79.0 to 0.81.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.79.0...v0.81.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-01-19 10:39:28 -05:00
Wilken Rivera 96755d2f7b Remove migrated integrations from plugin manifest
This change removes Scaleway and Mondoo from the external plugins manifest in favor
of the integration framework, which they have migrated to.
2024-01-17 10:23:37 -05:00
Lucas Bajolet 6c99f387a0 packer: remove single-component plugins
Single-component plugins are a relic from the past that has been
deprecated from version 1.7.0 and onwards.

Since we're revisiting how plugins are installed/loaded, and the changes
will be incompatible with those, we remove them in preparation of this
work.
2024-01-12 09:06:22 -05:00
Wilken Rivera beb5fcf470 Bump github.com/cloudflare/circl to address GHSA-9763-4f94-gfch (#12781) 2024-01-10 10:03:51 -05:00
dependabot[bot] a9000f3a70 build(deps): bump github.com/hashicorp/hcp-sdk-go from 0.74.0 to 0.79.0
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.74.0 to 0.79.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.74.0...v0.79.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-01-09 14:59:39 -05:00
Wilken Rivera bfc3f8b564 Bump github.com/go-git/go-git/v5 to address CVE-2023-49568 2024-01-08 11:11:39 -05:00
Wilken Rivera 2515aa27a7 Bump golang.org/x/crypto to address CVE-2023-48795 2024-01-08 11:11:39 -05:00
Wilken Rivera 0a64a5fb90 Bump Go version to 1.20.12
Bumped to pull in security fixes to the go command, the net/http package,
and path/filepath package.
2024-01-08 11:11:39 -05:00
Aidan Mundy 0b06cb58a3 Fix Typo make check-generate -> make generate-check 2024-01-08 09:44:56 -05:00
Lucas Bajolet 311a3b1d6a website: remove UpCloud from manifest
Since the UpCloud plugin has moved to the integrations model, we don't
want to continue looking for a docs.zip in their repo, as it doesn't
exist anymore with this migration.
2024-01-08 09:37:45 -05:00
Brian McClain 76de1d3fc0 Merge pull request #12767 from hashicorp/bmm/upcloud-version-pin
Pin UpCloud plugin version
2024-01-03 15:52:22 -05:00
Brian McClain 9afafd962f Pin UpCloud plugin version 2024-01-03 13:36:05 -05:00
hc-github-team-es-release-engineering 4825c65234 Merge pull request #12752 from hashicorp/RELPLAT-955-EOY-license-updates
[DO NOT MERGE UNTIL EOY] EOY license updates
2024-01-02 13:37:55 -08:00
Wilken Rivera 699c0f814c Update plugin_integration.md
Fix todo list markdown formatting
2023-12-13 14:47:39 -05:00
hc-github-team-es-release-engineering fd7fc49f17 update year in license files 2023-12-06 12:43:42 -08:00
Wilken Rivera 2241b1fba7 Update spacing for flags within Help text
Before Change
```

Options:
  - path <path>: install the plugin from a locally-sourced plugin binary. This
                 installs the plugin where a normal invocation would, but will
                 not try to download it from a remote location, and instead
                 install the binary in the Packer plugins path.
                 This option cannot be specified with a version constraint.
  - force:       forces reinstallation of plugins, even if already installed.

```

After Change
```
Options:
  -path <path>                  Install the plugin from a locally-sourced plugin binary.
                                This installs the plugin where a normal invocation would, but will
                                not try to download it from a remote location, and instead
                                install the binary in the Packer plugins path. This option cannot
                                be specified with a version constraint.
  -force                        Forces reinstallation of plugins, even if already installed.
```
2023-12-06 07:29:10 -05:00
9d46c90c03 Apply suggestions from code review
Co-authored-by: Lucas Bajolet <[email protected]>
Co-authored-by: Sylvia Moss <[email protected]>
2023-12-05 16:15:12 -05:00
Wilken Rivera 9565eca354 Remove reference to deprecated single components 2023-12-05 16:15:12 -05:00
Wilken Rivera e2a2a08f56 Add example shell commands for copying integration files into plugin repository 2023-12-05 16:15:12 -05:00