|
|
|
|
@ -410,9 +410,28 @@ func normalizeVersion(version string) string { |
|
|
|
|
return normalized |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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. It expects plugin.Versions to be sorted so the newest version is first.
|
|
|
|
|
func (i *Installer) GetUpdateInfo(pluginID, version, pluginRepoURL string) (plugins.UpdateInfo, error) { |
|
|
|
|
plugin, err := i.getPluginMetadataFromPluginRepo(pluginID, pluginRepoURL) |
|
|
|
|
if err != nil { |
|
|
|
|
return plugins.UpdateInfo{}, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
v, err := i.selectVersion(&plugin, version) |
|
|
|
|
if err != nil { |
|
|
|
|
return plugins.UpdateInfo{}, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return plugins.UpdateInfo{ |
|
|
|
|
PluginZipURL: fmt.Sprintf("%s/%s/versions/%s/download", pluginRepoURL, pluginID, v.Version), |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// selectVersion selects the most appropriate plugin version
|
|
|
|
|
// returns the specified version if supported.
|
|
|
|
|
// returns latest version if no specific version is specified.
|
|
|
|
|
// returns error if the supplied version does not exist.
|
|
|
|
|
// returns error if supplied version exists but is not supported.
|
|
|
|
|
// NOTE: It expects plugin.Versions to be sorted so the newest version is first.
|
|
|
|
|
func (i *Installer) selectVersion(plugin *Plugin, version string) (*Version, error) { |
|
|
|
|
var ver Version |
|
|
|
|
|
|
|
|
|
|