github.com/skf/moby@v1.13.1/client/secret_create.go (about) 1 package client 2 3 import ( 4 "encoding/json" 5 6 "github.com/docker/docker/api/types" 7 "github.com/docker/docker/api/types/swarm" 8 "golang.org/x/net/context" 9 ) 10 11 // SecretCreate creates a new Secret. 12 func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) { 13 var headers map[string][]string 14 15 var response types.SecretCreateResponse 16 resp, err := cli.post(ctx, "/secrets/create", nil, secret, headers) 17 if err != nil { 18 return response, err 19 } 20 21 err = json.NewDecoder(resp.body).Decode(&response) 22 ensureReaderClosed(resp) 23 return response, err 24 }