Commit graph

18 commits

Author SHA1 Message Date
Lucas Bajolet
b24ab44a55 command: list releases only for remote installs
When installing a plugin from a remote source, we list the installed
plugins that match the constraints specified, and if the constraint is
already satisfied, we don't do anything.

However, since remote installation is only relevant for releases of a
plugin, we should only look at the installed releases of a plugin, and
not consider pre-releases for that step.

This wasn't the case before this commit, as if a prerelease version of a
commit (ex: 10.8.1-dev), and we try to invoke `packer init` with a
constraint on this version specifically, Packer would locate that
pre-release and assume it was already installed, so would silently
succeed the command and do nothing.

This isn't the expected behaviour as we should install the final release
of that plugin, regardless of any prerelease installation of the plugin.
So this commit fixes that by only listing releases, so we don't report
the plugin being already installed if a prerelease is what's installed.
2024-05-08 16:01:29 -04:00
Lucas Bajolet
2d8aa69779 init: fix --force and pre-releases installed case
When packer init is invoked with a --force argument, but no --update, we
clamp the version to install based on the last one locally installed.

Doing this may however cause the constraint to always be false if the
latest available version of a plugin is a pre-release, as none of the
upstream constraints will match that.

Therefore this commit changes how the constraint is derived from the
local list of installations, so that only the last installation that
matches the original constraint will be used, and not a pre-release.
2024-05-08 16:01:29 -04:00
Lucas Bajolet
4b00a81bf3 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-03-01 09:04:15 -05:00
Lucas Bajolet
94aaff44a1 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-03-01 09:04:15 -05:00
Lucas Bajolet
97e2e9e637 docs: add exerpt on packer plugins install --path 2023-12-04 16:34:31 -05:00
Lucas Bajolet
a2d9c9dce4 command: add --force option to init/install
The --force option for packer init and packer plugins install enforces
installation of a plugin, even if it is already locally installed.

This will become useful if for some reason a pre-existing plugin
binary/version is already installed, and we want to overwrite it.
2023-12-04 16:34:31 -05:00
Lucas Bajolet
020f18e37f command: remove unused FlagSetFlags enum
The enumeration for FlagSetFlags, which presumably was added when the
Meta structure was introduced, aims to pre-populate the flagset for a
subcommand with a series of arguments.

However, despite it being documented, it is actually not used, and
therefore can safely be removed from the codebase.
2023-10-16 09:51:53 -04:00
Lucas Bajolet
c0e594738b init: warn if no requirements specified
When users call `packer init' on a template that does not specify a
`required_plugin' block, the command succeeds but does nothing, which is
not helpful for users that may expect their plugins to install.

To remedy that problem, we now output a message like what `packer
plugins required' does on templates without such a block, so that users
have an idea of what to change in order to get the command to work.
2023-09-27 14:47:00 -04:00
Lucas Bajolet
eb9e1a4795 packer: remove implicit required plugins
Since this feature is no longer something we plan to activate later, as
it contradicts with our efforts to remove bundled plugins, and
encouraging users to move to either manually installing plugins, or
managing them through `packer init', we clean-up the code for this
feature.
2023-08-17 16:51:49 -04:00
hashicorp-copywrite[bot]
19055df3ec
[COMPLIANCE] License changes (#12568)
* Updating the license from MPL to Business Source License

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at https://hashi.co/license-faq, and details of the license at www.hashicorp.com/bsl.

* Update copyright file headers to BUSL-1.1

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-10 15:53:29 -07:00
Lucas Bajolet
3512a175a6 command: change wording for init's postitional arg
`packer init' is meant to be invoked on a template file or a directory.
This was described in the command-line help message as
`[template.pkr.hcl|folder]'.

Because this is encapsulated between square brackets, this could be
taken as an option instead of a positional, mandatory argument.

This commit changes the wording to adopt a similar convention as `packer
build', so the two are consistent in how they are invoked, and to avoid
mistaking this argument as optional.
2023-07-25 16:45:32 -04:00
hashicorp-copywrite[bot]
b7df3ca36f
[COMPLIANCE] Add Copyright and License Headers (#12254)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-03-02 15:37:05 -05:00
Adrien Delorme
a766d59d82
packer init: better error handling with a special care for gh rate limit errors (#11330) 2021-10-14 13:57:59 +02:00
Adrien Delorme
0e3fcb589b
Implicit required_plugin blocks (#10732)
* used components that don't have a required_plugin block will make Packer 'implicitly' require those. These components are manually selected and commented for now.
* add tests
 * docs
2021-03-24 11:31:39 +01:00
Adrien Delorme
8208f425c8 addrs: remove Plugin.ForDisplay func, the String one does the job
to make things less confusing
2021-02-15 15:32:42 +01:00
Adrien Delorme
692433721d
Add some acceptance testing for Packer init commands (#10566) 2021-02-05 14:06:28 +01:00
Adrien Delorme
92ccd5fa1d
init: show successful installs in cyan (#10557) 2021-02-04 11:11:42 +01:00
Adrien Delorme
ed091163be
HCL2 Parse packer.required_plugins block + packer init (#10304)
This adds the new `required_plugins` block to be nested under the packer block.

Example:
```hcl
packer {
  required_plugins {
    aws = {
      version = ">= 2.7.0"
      source = "azr/aws"
    }
    azure = ">= 2.7.0"
  }
}
```

For example on darwin_amd64 Packer will install those under :
* "${PACKER_HOME_DIR}/plugin/github.com/azr/amazon/packer-plugin-amazon_2.7.0_x5.0_darwin_amd64"
* "${PACKER_HOME_DIR}/plugin/github.com/hashicorp/azure/packer-plugin-azure_2.7.0_x5.0_darwin_amd64_x5"

+ docs
+ tests
2021-02-02 18:05:04 +01:00