Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer: relax constraints on local sources #12911

Merged
merged 2 commits into from
Apr 29, 2024
Merged

Conversation

lbajolet-hashicorp
Copy link
Collaborator

@lbajolet-hashicorp lbajolet-hashicorp commented Apr 9, 2024

The source parsing logic was heavily directed towards Github compatible source URIs, however if we want to support more cases, we need to make sure we are able to specify those URIs, and to load plugins installed from those sources.

Right now, since the getters available are only github.com, we will not support remotely instlling plugins from sources other than github.com, with the same set of constraints as before. However, we do support now installing from a local plugin binary to any kind of source, and we support loading them, including if a template wants this plugin installed locally with version constraints.

Related to: #12863

@lbajolet-hashicorp lbajolet-hashicorp added enhancement plugin-block For plugin block feature command/plugins Issues related to the plugins management commands labels Apr 9, 2024
@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner April 9, 2024 15:19
@lbajolet-hashicorp lbajolet-hashicorp changed the title packer: relax constraints on sources packer: relax constraints on local sources Apr 9, 2024
@lbajolet-hashicorp lbajolet-hashicorp force-pushed the poc_relaxed_sources branch 6 times, most recently from b51b6f6 to 3242f81 Compare April 18, 2024 17:25
@sylviamoss
Copy link
Member

However, we do support now installing from a local plugin binary to any kind of source, and we support loading them, including if a template wants this template installed locally with version constraints.

I need help understanding this part, can you show me an example?

@lbajolet-hashicorp
Copy link
Collaborator Author

lbajolet-hashicorp commented Apr 23, 2024

However, we do support now installing from a local plugin binary to any kind of source, and we support loading them, including if a template wants this template installed locally with version constraints.

I need help understanding this part, can you show me an example?

Duplicate template in the message, it should read "including if a template wants this plugin installed locally with version constraints".

What that means essentially (and the problem we're trying to solve here), is if someone had a plugin that cannot be sourced through github.com, they could still install it manually as packer-plugin-<name>. Since we're removing this capacity with 1.11.0, that means they'd need to make their source something like github.com/org/name, which may not necessarily fit the expected source location of the plugin binaries.
Now they cannot be installed still, as we don't expose any getter other than github, but at least relaxing the constraints on the source means that they can have whatever makes sense for a source URI (so anything that is essentially a hostname and a resource path, even minimal), and they can install them locally, and use required_plugins blocks to manage which version of a plugin is required by their template.

Ex: artifactory.hashicorp.org/packer/releases/binaries would work as a source, but you cannot install remotely since we don't have a getter for it, but you can still get the binaries and install them with packer plugins install --path, with the expected source.

@sylviamoss
Copy link
Member

I had understood exactly that initially but wasn't sure if I was right. Thanks for explaining @lbajolet-hashicorp

Copy link
Member

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 LGTM

acctest/plugin/plugin_acc_test.go Outdated Show resolved Hide resolved
acctest/plugin/plugin_acc_test.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin.go Outdated Show resolved Hide resolved
Copy link
Member

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-roll looks good. I left a few more nits and suggestions. Feel free to merge when ready.

acctest/plugin/component_acc_test.go Outdated Show resolved Hide resolved
acctest/plugin/plugin_acc_test.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin.go Outdated Show resolved Hide resolved
hcl2template/addrs/plugin_test.go Outdated Show resolved Hide resolved
packer/plugin-getter/github/getter.go Show resolved Hide resolved
packer/plugin-getter/github/getter.go Outdated Show resolved Hide resolved
The invalid_inexplicit_source_2 subtest for parse used to fail in
previous versions of Packer, but with the latest changes to plugin
source management, it won't, at least at parsing time, instead it fails
later when the Github getter (the only available for now) cannot get the
plugin binary from the source, as the source is not a valid Github URI.
The source parsing logic was heavily directed towards Github compatible
source URIs, however if we want to support more cases, we need to make
sure we are able to specify those URIs, and to load plugins installed
from those sources.

Right now, since the getters available are only github.com, we will not
support remotely instlling plugins from sources other than github.com,
with the same set of constraints as before. However, we do support now
installing from a local plugin binary to any kind of source, and we
support loading them, including if a template wants this plugin
installed locally with version constraints.
@lbajolet-hashicorp lbajolet-hashicorp merged commit 6fc1d15 into main Apr 29, 2024
11 checks passed
@lbajolet-hashicorp lbajolet-hashicorp deleted the poc_relaxed_sources branch April 29, 2024 18:28
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
command/plugins Issues related to the plugins management commands enhancement plugin-block For plugin block feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants