mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
33 lines
800 B
Go
33 lines
800 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
|
|
}
|
|
|
|
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, options.Spec, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return ConfigUpdateResult{}, err
|
|
}
|
|
return ConfigUpdateResult{}, nil
|
|
}
|