Commit 501e67a6 by Dan Cech Committed by Torkel Ödegaard

use semver when comparing grafana and plugin versions (#6108)

parent 9a94072c
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
"github.com/hashicorp/go-version"
) )
var ( var (
...@@ -85,7 +86,15 @@ func checkForUpdates() { ...@@ -85,7 +86,15 @@ func checkForUpdates() {
for _, gplug := range gNetPlugins { for _, gplug := range gNetPlugins {
if gplug.Slug == plug.Id { if gplug.Slug == plug.Id {
plug.GrafanaNetVersion = gplug.Version plug.GrafanaNetVersion = gplug.Version
plug.GrafanaNetHasUpdate = plug.Info.Version != plug.GrafanaNetVersion
plugVersion, err1 := version.NewVersion(plug.Info.Version)
gplugVersion, err2 := version.NewVersion(gplug.Version)
if err1 != nil || err2 != nil {
plug.GrafanaNetHasUpdate = plug.Info.Version != plug.GrafanaNetVersion
} else {
plug.GrafanaNetHasUpdate = plugVersion.LessThan(gplugVersion)
}
} }
} }
} }
...@@ -117,4 +126,11 @@ func checkForUpdates() { ...@@ -117,4 +126,11 @@ func checkForUpdates() {
GrafanaLatestVersion = githubLatest.Stable GrafanaLatestVersion = githubLatest.Stable
GrafanaHasUpdate = githubLatest.Stable != setting.BuildVersion GrafanaHasUpdate = githubLatest.Stable != setting.BuildVersion
} }
currVersion, err1 := version.NewVersion(setting.BuildVersion)
latestVersion, err2 := version.NewVersion(GrafanaLatestVersion)
if err1 == nil && err2 == nil {
GrafanaHasUpdate = currVersion.LessThan(latestVersion)
}
} }
...@@ -64,13 +64,13 @@ ...@@ -64,13 +64,13 @@
<a href="http://grafana.org" target="_blank">Grafana</a> <a href="http://grafana.org" target="_blank">Grafana</a>
<span>v[[.BuildVersion]] (commit: [[.BuildCommit]])</span> <span>v[[.BuildVersion]] (commit: [[.BuildCommit]])</span>
</li> </li>
<li> [[if .NewGrafanaVersionExists]]
[[if .NewGrafanaVersionExists]] <li>
<a href="http://grafana.org/download" target="_blank" bs-tooltip="'[[.NewGrafanaVersion]]'"> <a href="http://grafana.org/download" target="_blank" bs-tooltip="'[[.NewGrafanaVersion]]'">
New version available! New version available!
</a> </a>
[[end]] </li>
</li> [[end]]
</ul> </ul>
</div> </div>
</footer> </footer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment