1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/client/lib/version.go
David Calavera d9a62c5f2b Lowercase http method functions.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-09 12:04:59 -05:00

38 lines
1 KiB
Go

package lib
import (
"encoding/json"
"runtime"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/utils"
)
// SystemVersion returns information of the docker client and server host.
func (cli *Client) SystemVersion() (types.VersionResponse, error) {
client := &types.Version{
Version: dockerversion.Version,
APIVersion: api.Version,
GoVersion: runtime.Version(),
GitCommit: dockerversion.GitCommit,
BuildTime: dockerversion.BuildTime,
Os: runtime.GOOS,
Arch: runtime.GOARCH,
Experimental: utils.ExperimentalBuild(),
}
resp, err := cli.get("/version", nil, nil)
if err != nil {
return types.VersionResponse{Client: client}, err
}
defer ensureReaderClosed(resp)
var server types.Version
err = json.NewDecoder(resp.body).Decode(&server)
if err != nil {
return types.VersionResponse{Client: client}, err
}
return types.VersionResponse{Client: client, Server: &server}, nil
}