mirror of https://github.com/grafana/grafana.git
Preinstall: Avoid overwriting development versions (#104781)
This commit is contained in:
parent
8435eb2876
commit
0d50efe198
|
|
@ -129,6 +129,10 @@ func (s *Service) shouldUpdate(ctx context.Context, pluginID, currentVersion str
|
|||
s.log.Debug("New major version available, skipping update due to possible breaking changes", "pluginId", pluginID, "version", info.Version)
|
||||
return false
|
||||
}
|
||||
if parsedCurrentVersion.Compare(parsedLatestVersion) >= 0 {
|
||||
s.log.Debug("No update available", "pluginId", pluginID, "version", info.Version)
|
||||
return false
|
||||
}
|
||||
|
||||
// We should update the plugin
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -120,6 +120,20 @@ func TestService_Run(t *testing.T) {
|
|||
shouldInstall: true,
|
||||
pluginsToInstall: []setting.InstallPlugin{{ID: "myplugin", URL: "https://example.com/myplugin.tar.gz"}},
|
||||
},
|
||||
{
|
||||
name: "Should not update a plugin if the current version is greater than the latest version",
|
||||
shouldInstall: false,
|
||||
pluginsToInstall: []setting.InstallPlugin{{ID: "myplugin", Version: ""}},
|
||||
existingPlugins: []*plugins.Plugin{{JSONData: plugins.JSONData{ID: "myplugin", Info: plugins.Info{Version: "1.0.1"}}}},
|
||||
latestPlugin: &repo.PluginArchiveInfo{Version: "1.0.0"},
|
||||
},
|
||||
{
|
||||
name: "Should not update a plugin if the current version is equal to the latest version, ignoring the prerelease",
|
||||
shouldInstall: false,
|
||||
pluginsToInstall: []setting.InstallPlugin{{ID: "myplugin", Version: ""}},
|
||||
existingPlugins: []*plugins.Plugin{{JSONData: plugins.JSONData{ID: "myplugin", Info: plugins.Info{Version: "1.0.0"}}}},
|
||||
latestPlugin: &repo.PluginArchiveInfo{Version: "1.0.0-rc.1"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue