Make `body` the last argument, so that requests can be inlined on call-sites. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
865 B
Go
34 lines
865 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// ConfigUpdateOptions holds options for updating a config.
|
|
type ConfigUpdateOptions struct {
|
|
Version swarm.Version
|
|
Spec swarm.ConfigSpec
|
|
}
|
|
|
|
// ConfigUpdateResult holds the result of [Client.ConfigUpdate].
|
|
type ConfigUpdateResult struct{}
|
|
|
|
// ConfigUpdate attempts to update a config
|
|
func (cli *Client) ConfigUpdate(ctx context.Context, id string, options ConfigUpdateOptions) (ConfigUpdateResult, error) {
|
|
id, err := trimID("config", id)
|
|
if err != nil {
|
|
return ConfigUpdateResult{}, err
|
|
}
|
|
query := url.Values{}
|
|
query.Set("version", options.Version.String())
|
|
resp, err := cli.post(ctx, "/configs/"+id+"/update", query, nil, options.Spec)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return ConfigUpdateResult{}, err
|
|
}
|
|
return ConfigUpdateResult{}, nil
|
|
}
|