github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/client/config_create.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "encoding/json" 6 7 "github.com/docker/docker/api/types" 8 "github.com/docker/docker/api/types/swarm" 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 defer ensureReaderClosed(resp) 19 if err != nil { 20 return response, err 21 } 22 23 err = json.NewDecoder(resp.body).Decode(&response) 24 return response, err 25 }