Skip to content

Commit efbed45

Browse files
committed
support env for docker plugin set
Signed-off-by: Victor Vieux <vieux@docker.com>
1 parent 7eb4a1d commit efbed45

File tree

15 files changed

+333
-22
lines changed

15 files changed

+333
-22
lines changed

api/server/router/plugin/plugin_routes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ func (pr *pluginRouter) setPlugin(ctx context.Context, w http.ResponseWriter, r
8989
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
9090
return err
9191
}
92-
return pr.backend.Set(vars["name"], args)
92+
if err := pr.backend.Set(vars["name"], args); err != nil {
93+
return err
94+
}
95+
w.WriteHeader(http.StatusNoContent)
96+
return nil
9397
}
9498

9599
func (pr *pluginRouter) listPlugins(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

docs/reference/api/docker_remote_api_v1.25.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,16 +4290,26 @@ Content-Type: application/json
42904290
- **200** - no error
42914291
- **404** - plugin not installed
42924292
4293-
<!-- TODO Document "docker plugin set" endpoint once implemented
42944293
### Configure a plugin
42954294
4296-
`POST /plugins/(plugin name)/set`
4295+
POST /plugins/(plugin name)/set`
42974296
4298-
**Status codes**:
4297+
**Example request**:
42994298
4300-
- **500** - not implemented
43014299
4302-
-->
4300+
POST /plugins/tiborvass/no-remove/set
4301+
Content-Type: application/json
4302+
4303+
["DEBUG=1"]
4304+
4305+
**Example response**:
4306+
4307+
HTTP/1.1 204 No Content
4308+
4309+
**Status codes**:
4310+
4311+
- **204** - no error
4312+
- **404** - plugin not installed
43034313
43044314
### Enable a plugin
43054315

docs/reference/commandline/plugin_disable.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ tiborvass/no-remove latest A test plugin for Docker false
5959
* [plugin inspect](plugin_inspect.md)
6060
* [plugin install](plugin_install.md)
6161
* [plugin rm](plugin_rm.md)
62+
* [plugin set](plugin_set.md)

docs/reference/commandline/plugin_enable.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ tiborvass/no-remove latest A test plugin for Docker true
5959
* [plugin inspect](plugin_inspect.md)
6060
* [plugin install](plugin_install.md)
6161
* [plugin rm](plugin_rm.md)
62+
* [plugin set](plugin_set.md)

docs/reference/commandline/plugin_inspect.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@ $ docker plugin inspect -f '{{.Id}}' tiborvass/no-remove:latest
159159
* [plugin disable](plugin_disable.md)
160160
* [plugin install](plugin_install.md)
161161
* [plugin rm](plugin_rm.md)
162+
* [plugin set](plugin_set.md)

docs/reference/commandline/plugin_install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ tiborvass/no-remove latest A test plugin for Docker true
6464
* [plugin disable](plugin_disable.md)
6565
* [plugin inspect](plugin_inspect.md)
6666
* [plugin rm](plugin_rm.md)
67+
* [plugin set](plugin_set.md)

docs/reference/commandline/plugin_ls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ tiborvass/no-remove latest A test plugin for Docker true
4848
* [plugin inspect](plugin_inspect.md)
4949
* [plugin install](plugin_install.md)
5050
* [plugin rm](plugin_rm.md)
51+
* [plugin set](plugin_set.md)

docs/reference/commandline/plugin_rm.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ tiborvass/no-remove
5151
* [plugin disable](plugin_disable.md)
5252
* [plugin inspect](plugin_inspect.md)
5353
* [plugin install](plugin_install.md)
54+
* [plugin set](plugin_set.md)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: "plugin set"
3+
description: "the plugin set command description and usage"
4+
keywords: "plugin, set"
5+
advisory: "experimental"
6+
---
7+
8+
<!-- This file is maintained within the docker/docker Github
9+
repository at https://github.com/docker/docker/. Make all
10+
pull requests against that repo. If you see this file in
11+
another repository, consider it read-only there, as it will
12+
periodically be overwritten by the definitive file. Pull
13+
requests which include edits to this file in other repositories
14+
will be rejected.
15+
-->
16+
17+
# plugin set (experimental)
18+
19+
```markdown
20+
Usage: docker plugin set PLUGIN key1=value1 [key2=value2...]
21+
22+
Change settings for a plugin
23+
24+
Options:
25+
--help Print usage
26+
```
27+
28+
Change settings for a plugin. The plugin must be disabled.
29+
30+
31+
The following example installs change the env variable `DEBUG` of the
32+
`no-remove` plugin.
33+
34+
```bash
35+
$ docker plugin inspect -f {{.Config.Env}} tiborvass/no-remove
36+
[DEBUG=0]
37+
38+
$ docker plugin set DEBUG=1 tiborvass/no-remove
39+
40+
$ docker plugin inspect -f {{.Config.Env}} tiborvass/no-remove
41+
[DEBUG=1]
42+
```
43+
44+
## Related information
45+
46+
* [plugin ls](plugin_ls.md)
47+
* [plugin enable](plugin_enable.md)
48+
* [plugin disable](plugin_disable.md)
49+
* [plugin inspect](plugin_inspect.md)
50+
* [plugin install](plugin_install.md)
51+
* [plugin rm](plugin_rm.md)

integration-cli/docker_cli_plugins_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
117117
dockerCmd(c, "volume", "ls")
118118
}
119119

120+
func (s *DockerSuite) TestPluginSet(c *check.C) {
121+
testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network)
122+
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName)
123+
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
124+
125+
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Config.Env}}", pName)
126+
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
127+
128+
dockerCmd(c, "plugin", "set", pName, "DEBUG=1")
129+
130+
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Config.Env}}", pName)
131+
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
132+
}
133+
120134
func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
121135
testRequires(c, DaemonIsLinux, ExperimentalDaemon)
122136
out, _, err := dockerCmdWithError("plugin", "install", "redis")

0 commit comments

Comments
 (0)