Skip to content

Commit

Permalink
command: reject version with --path for install
Browse files Browse the repository at this point in the history
To avoid plugins being installed with a specific version when a path is
used for installing a plugin from a locally sourced plugin binary, we
explicitly reject the combination of both a path and a version for
plugins install.
  • Loading branch information
lbajolet-hashicorp committed Nov 24, 2023
1 parent 0ff5bf6 commit 12b9759
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions command/plugins_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Options:
installs the plugin where a normal invocation would, but will
not try to download it from a web server, but instead directly
install the binary for Packer to be able to load it later on.
This option cannot be specified with a version constraint.
- force: forces installation of a plugin, even if it is already there.
`

Expand Down Expand Up @@ -105,6 +106,12 @@ func (c *PluginsInstallCommand) ParseArgs(args []string) (*PluginsInstallArgs, i
pa.Version = args[1]
}

if pa.Path != "" && pa.Version != "" {
c.Ui.Error("Invalid arguments: a version cannot be specified with --path")
flags.Usage()
return pa, 1
}

pa.PluginName = args[0]

return pa, 0
Expand Down Expand Up @@ -256,12 +263,6 @@ an issue on our Github repo to signal it.`)
}})
}

// Let's override the plugin's version if we specify it in the options
// of the command
if args.Version != "" {
desc.Version = args.Version
}

pluginBinary, err := os.Open(args.PluginPath)
if err != nil {
return writeDiags(c.Ui, nil, hcl.Diagnostics{&hcl.Diagnostic{
Expand Down

0 comments on commit 12b9759

Please sign in to comment.