github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/config_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 // ConfigCreate creates a new Config. 12 func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) { 13 var response types.ConfigCreateResponse 14 if err := cli.NewVersionError("1.30", "config create"); err != nil { 15 return response, err 16 } 17 resp, err := cli.post(ctx, "/configs/create", nil, config, nil) 18 if err != nil { 19 return response, err 20 } 21 22 err = json.NewDecoder(resp.body).Decode(&response) 23 ensureReaderClosed(resp) 24 return response, err 25 }