command: scrub metadata from version at install

When installing plugins with the `packer plugins install --path'
command, the metadata is now scrubbed from the file installed locally.

This is as a protection against collisions in the versions, as metadata
is meaningless for version comparison, so if two versions of the same
plugin are installed, the precedence order between them is undefined.

Therefore to avoid such collisions, we remove the metadata from the file
name, that way if two successive versions of a plugin include metadata
in the version, they won't coexist, and the last installed will be the
only installed version locally.
pull/12900/head
Lucas Bajolet 2 years ago committed by Lucas Bajolet
parent 3f721ff03e
commit d7f299886d

@ -300,10 +300,16 @@ func (c *PluginsInstallCommand) InstallFromBinary(opts plugingetter.ListInstalla
}})
}
// Remove metadata from plugin path
noMetaVersion := semver.Core().String()
if semver.Prerelease() != "" {
noMetaVersion = fmt.Sprintf("%s-%s", noMetaVersion, semver.Prerelease())
}
outputPrefix := fmt.Sprintf(
"packer-plugin-%s_v%s_%s",
pluginIdentifier.Type,
semver.String(),
noMetaVersion,
desc.APIVersion,
)
binaryPath := filepath.Join(

Loading…
Cancel
Save