-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathconfig_update.go
More file actions
33 lines (28 loc) · 865 Bytes
/
config_update.go
File metadata and controls
33 lines (28 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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, options.Spec, nil)
defer ensureReaderClosed(resp)
if err != nil {
return ConfigUpdateResult{}, err
}
return ConfigUpdateResult{}, nil
}