2016-01-05 02:26:13 +03:00
|
|
|
package client
|
2015-12-04 01:20:46 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"net/url"
|
|
|
|
|
2016-01-05 02:26:13 +03:00
|
|
|
"github.com/docker/engine-api/types"
|
2016-03-08 07:38:46 +03:00
|
|
|
"golang.org/x/net/context"
|
2015-12-04 01:20:46 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Info returns information about the docker server.
|
2016-03-08 07:38:46 +03:00
|
|
|
func (cli *Client) Info(ctx context.Context) (types.Info, error) {
|
2015-12-04 01:20:46 +03:00
|
|
|
var info types.Info
|
2016-03-08 07:38:46 +03:00
|
|
|
serverResp, err := cli.get(ctx, "/info", url.Values{}, nil)
|
2015-12-04 01:20:46 +03:00
|
|
|
if err != nil {
|
|
|
|
return info, err
|
|
|
|
}
|
2015-12-04 22:57:22 +03:00
|
|
|
defer ensureReaderClosed(serverResp)
|
2015-12-04 01:20:46 +03:00
|
|
|
|
|
|
|
if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil {
|
|
|
|
return info, fmt.Errorf("Error reading remote info: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return info, nil
|
|
|
|
}
|