1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

add last version

This commit is contained in:
Victor Vieux 2013-07-03 17:11:00 +00:00
parent 5dcd11be16
commit 64450ae3f8
2 changed files with 31 additions and 0 deletions

View file

@ -407,6 +407,15 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
if out.GoVersion != "" { if out.GoVersion != "" {
fmt.Fprintf(cli.out, "Go version: %s\n", out.GoVersion) fmt.Fprintf(cli.out, "Go version: %s\n", out.GoVersion)
} }
release := utils.GetReleaseVersion()
if release != "" {
fmt.Fprintf(cli.out, "Last stable version: %s", release)
if VERSION != release || out.Version != release {
fmt.Fprintf(cli.out, ", please update docker")
}
fmt.Fprintf(cli.out, "\n")
}
return nil return nil
} }

View file

@ -687,3 +687,25 @@ func ParseHost(host string, port int, addr string) string {
} }
return fmt.Sprintf("tcp://%s:%d", host, port) return fmt.Sprintf("tcp://%s:%d", host, port)
} }
func GetReleaseVersion() string {
type githubTag struct {
Name string `json:"name"`
}
resp, err := http.Get("https://api.github.com/repos/dotcloud/docker/tags")
if err != nil {
return ""
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return ""
}
var tags []githubTag
err = json.Unmarshal(body, &tags)
if err != nil || len(tags) == 0 {
return ""
}
return strings.TrimPrefix(tags[0].Name, "v")
}