hashicorp / packer-plugin-sdk

Packer Plugin SDK enables building Packer plugins (builders, provisioners, or post-processors) to manage any service providers or custom in-house solutions
Mozilla Public License 2.0
32 stars 44 forks source link

Version parsing rehaul #228

Closed lbajolet-hashicorp closed 2 months ago

lbajolet-hashicorp commented 3 months ago

As it stands now, plugin developers can only specify a version's core semver-compatible version, and a prerelease. In usage though, some plugins use metadata to add some extra context on the binary that was built, like the git commit, or the delta between the last release and the current HEAD from which a plugin was built.

This, coupled with the 1.11.0 changes to plugin loading and version support, means that we cannot support such a workflow with the current code, as we will now start enforcing proper semver for plugins, so we are at risk of having plugins either not load, or lose information when releasing.

Therefore as an attempt to address those issues, we are adding official support in the SDK for metadata in versions. That change introduces two new functions: NewPluginVersion and NewRawVersion. Both are intended as replacements for the now deprecated InitializePluginVersion.

In addition to this change, we are also limiting the number of segments to 3 in the version number, there are too many unknowns around 4-segmented version numbers, in addition to this not being semver compliant (despite the library supporting them).

cc @NorseGaud @torarnv @chris-rock since we've had recent exchanges regarding plugins recently on your respective repositories, this PR should cement the addition of metadata to what is supported for versions. Please feel free to take a look at this code, and let me know your thoughts, I'd like to know if this kind of interface would suit your development practices. Thanks in advance!

NorseGaud commented 3 months ago

Looks good to me!

torarnv commented 3 months ago

Nice! 👏🏻