mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 23:35:15 +08:00
CLI: Fix version selection for plugin install (#19498)
This commit is contained in:
@ -157,32 +157,34 @@ func latestSupportedVersion(plugin *m.Plugin) *m.Version {
|
||||
|
||||
// SelectVersion returns latest version if none is specified or the specified version. If the version string is not
|
||||
// matched to existing version it errors out. It also errors out if version that is matched is not available for current
|
||||
// os and platform.
|
||||
// os and platform. It expects plugin.Versions to be sorted so the newest version is first.
|
||||
func SelectVersion(plugin *m.Plugin, version string) (*m.Version, error) {
|
||||
var ver *m.Version
|
||||
if version == "" {
|
||||
ver = &plugin.Versions[0]
|
||||
}
|
||||
|
||||
for _, v := range plugin.Versions {
|
||||
if v.Version == version {
|
||||
ver = &v
|
||||
}
|
||||
}
|
||||
|
||||
if ver == nil {
|
||||
return nil, xerrors.New("Could not find the version you're looking for")
|
||||
}
|
||||
var ver m.Version
|
||||
|
||||
latestForArch := latestSupportedVersion(plugin)
|
||||
if latestForArch == nil {
|
||||
return nil, xerrors.New("Plugin is not supported on your architecture and os.")
|
||||
}
|
||||
|
||||
if latestForArch.Version == ver.Version {
|
||||
return ver, nil
|
||||
if version == "" {
|
||||
return latestForArch, nil
|
||||
}
|
||||
return nil, xerrors.Errorf("Version you want is not supported on your architecture and os. Latest suitable version is %v", latestForArch.Version)
|
||||
for _, v := range plugin.Versions {
|
||||
if v.Version == version {
|
||||
ver = v
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(ver.Version) == 0 {
|
||||
return nil, xerrors.New("Could not find the version you're looking for")
|
||||
}
|
||||
|
||||
if !supportsCurrentArch(&ver) {
|
||||
return nil, xerrors.Errorf("Version you want is not supported on your architecture and os. Latest suitable version is %v", latestForArch.Version)
|
||||
}
|
||||
|
||||
return &ver, nil
|
||||
}
|
||||
|
||||
func RemoveGitBuildFromName(pluginName, filename string) string {
|
||||
|
Reference in New Issue
Block a user