|
|
@ -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")
|
|
|
|