2016-09-06 14:46:37 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-12-20 06:14:41 -05:00
|
|
|
// SwarmInit initializes the swarm.
|
2016-09-06 14:46:37 -04: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
|
|
|
|
}
|