2016-09-06 18:46:37 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-12-20 11:14:41 +00:00
|
|
|
// SwarmInit initializes the swarm.
|
2016-09-06 18:46:37 +00:00
|
|
|
func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
|
|
|
|
serverResp, err := cli.post(ctx, "/swarm/init", nil, req, nil)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
var response string
|
|
|
|
err = json.NewDecoder(serverResp.body).Decode(&response)
|
|
|
|
ensureReaderClosed(serverResp)
|
|
|
|
return response, err
|
|
|
|
}
|