mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-11 09:40:17 -04:00
packer: alias version as goversion for getter
Since we named the version from the getter `version', this means we have a naming conflict inside the loop that attempts to install a versioned candidate for a plugin, making it impossible to invoke something from the go-version package. Since we'll introduce a change that needs the latter capability, we must either rename the local variable to something else than `version', or we need to alias the package locally. This commit implements the latter, opting to call the package goversion.
This commit is contained in:
parent
d40df8e899
commit
64ae3e8ea4
1 changed files with 8 additions and 8 deletions
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/go-version"
|
||||
goversion "github.com/hashicorp/go-version"
|
||||
pluginsdk "github.com/hashicorp/packer-plugin-sdk/plugin"
|
||||
"github.com/hashicorp/packer-plugin-sdk/tmp"
|
||||
"github.com/hashicorp/packer/hcl2template/addrs"
|
||||
|
|
@ -47,7 +47,7 @@ type Requirement struct {
|
|||
|
||||
// VersionConstraints as defined by user. Empty ( to be avoided ) means
|
||||
// highest found version.
|
||||
VersionConstraints version.Constraints
|
||||
VersionConstraints goversion.Constraints
|
||||
}
|
||||
|
||||
type BinaryInstallationOptions struct {
|
||||
|
|
@ -220,7 +220,7 @@ func (pr Requirement) ListInstallations(opts ListInstallationsOptions) (InstallL
|
|||
// versionsStr now looks like v1.2.3_x5.1 or amazon_v1.2.3_x5.1
|
||||
parts := strings.SplitN(versionsStr, "_", 2)
|
||||
pluginVersionStr, protocolVersionStr := parts[0], parts[1]
|
||||
ver, err := version.NewVersion(pluginVersionStr)
|
||||
ver, err := goversion.NewVersion(pluginVersionStr)
|
||||
if err != nil {
|
||||
// could not be parsed, ignoring the file
|
||||
log.Printf("found %q with an incorrect %q version, ignoring it. %v", path, pluginVersionStr, err)
|
||||
|
|
@ -237,13 +237,13 @@ func (pr Requirement) ListInstallations(opts ListInstallationsOptions) (InstallL
|
|||
continue
|
||||
}
|
||||
|
||||
rawVersion, err := version.NewVersion(pluginVersionStr)
|
||||
rawVersion, err := goversion.NewVersion(pluginVersionStr)
|
||||
if err != nil {
|
||||
log.Printf("malformed version string in filename %q: %s, ignoring", pluginVersionStr, err)
|
||||
continue
|
||||
}
|
||||
|
||||
descVersion, err := version.NewVersion(describeInfo.Version)
|
||||
descVersion, err := goversion.NewVersion(describeInfo.Version)
|
||||
if err != nil {
|
||||
log.Printf("malformed reported version string %q: %s, ignoring", describeInfo.Version, err)
|
||||
continue
|
||||
|
|
@ -411,7 +411,7 @@ type GetOptions struct {
|
|||
|
||||
BinaryInstallationOptions
|
||||
|
||||
version *version.Version
|
||||
version *goversion.Version
|
||||
|
||||
expectedZipFilename string
|
||||
}
|
||||
|
|
@ -614,7 +614,7 @@ func (pr *Requirement) InstallLatest(opts InstallOptions) (*Installation, error)
|
|||
getters := opts.Getters
|
||||
|
||||
log.Printf("[TRACE] getting available versions for the %s plugin", pr.Identifier)
|
||||
versions := version.Collection{}
|
||||
versions := goversion.Collection{}
|
||||
var errs *multierror.Error
|
||||
for _, getter := range getters {
|
||||
|
||||
|
|
@ -642,7 +642,7 @@ func (pr *Requirement) InstallLatest(opts InstallOptions) (*Installation, error)
|
|||
continue
|
||||
}
|
||||
for _, release := range releases {
|
||||
v, err := version.NewVersion(release.Version)
|
||||
v, err := goversion.NewVersion(release.Version)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("could not parse release version %s. %w", release.Version, err)
|
||||
errs = multierror.Append(errs, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue