feat(docker): new version message in BE side menu [EE-4079] (#7680)

* export GetLatestVersion and HasNewerVersion
pull/7592/head^2
Chao Geng 2 years ago committed by GitHub
parent ceaee4e175
commit 8ef584e41c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,8 +58,8 @@ func (handler *Handler) version(w http.ResponseWriter, r *http.Request) {
}, },
} }
latestVersion := getLatestVersion() latestVersion := GetLatestVersion()
if hasNewerVersion(portainer.APIVersion, latestVersion) { if HasNewerVersion(portainer.APIVersion, latestVersion) {
result.UpdateAvailable = true result.UpdateAvailable = true
result.LatestVersion = latestVersion result.LatestVersion = latestVersion
} }
@ -67,7 +67,7 @@ func (handler *Handler) version(w http.ResponseWriter, r *http.Request) {
response.JSON(w, &result) response.JSON(w, &result)
} }
func getLatestVersion() string { func GetLatestVersion() string {
motd, err := client.Get(portainer.VersionCheckURL, 5) motd, err := client.Get(portainer.VersionCheckURL, 5)
if err != nil { if err != nil {
log.Debug().Err(err).Msg("couldn't fetch latest Portainer release version") log.Debug().Err(err).Msg("couldn't fetch latest Portainer release version")
@ -89,7 +89,7 @@ func getLatestVersion() string {
return data.TagName return data.TagName
} }
func hasNewerVersion(currentVersion, latestVersion string) bool { func HasNewerVersion(currentVersion, latestVersion string) bool {
currentVersionSemver, err := semver.NewVersion(currentVersion) currentVersionSemver, err := semver.NewVersion(currentVersion)
if err != nil { if err != nil {
log.Debug().Str("version", currentVersion).Msg("current Portainer version isn't a semver") log.Debug().Str("version", currentVersion).Msg("current Portainer version isn't a semver")

Loading…
Cancel
Save