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