github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/swarm_init.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "github.com/docker/docker/api/types/swarm" 7 "golang.org/x/net/context" 8 ) 9 10 // SwarmInit initializes the swarm. 11 func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) { 12 serverResp, err := cli.post(ctx, "/swarm/init", nil, req, nil) 13 if err != nil { 14 return "", err 15 } 16 17 var response string 18 err = json.NewDecoder(serverResp.body).Decode(&response) 19 ensureReaderClosed(serverResp) 20 return response, err 21 }