This fix tries to address the issue raised on 29185 where
`docker inspect <unknown object>` on Windows will return:
```
Error response from daemon: plugins are not supported on this platform
```
The reason was that in case `--type` is not specified, `docker inspect`
will iterate through different types `container`, `image`, `network`,
`plugin` etc. The `plugin` object is the last type to check.
However, as `plugin` is not supported on Windows yet, the error message
is not very informative for `plugins are not supported on this platform`.
This fix tries to fix the issue by return a `not found` error on unsupported
platforms as well.
An integration test has been added to cover the changes for Windows/Linux.
This fix fixes 29185.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
| ... | ... |
@@ -447,3 +447,12 @@ func (s *DockerSuite) TestInspectPlugin(c *check.C) {
|
| 447 | 447 |
c.Assert(err, checker.IsNil) |
| 448 | 448 |
c.Assert(out, checker.Contains, pNameWithTag) |
| 449 | 449 |
} |
| 450 |
+ |
|
| 451 |
+// Test case for 29185 |
|
| 452 |
+func (s *DockerSuite) TestInspectUnknownObject(c *check.C) {
|
|
| 453 |
+ // This test should work on both Windows and Linux |
|
| 454 |
+ out, _, err := dockerCmdWithError("inspect", "foobar")
|
|
| 455 |
+ c.Assert(err, checker.NotNil) |
|
| 456 |
+ c.Assert(out, checker.Contains, "Error: No such object: foobar") |
|
| 457 |
+ c.Assert(err.Error(), checker.Contains, "Error: No such object: foobar") |
|
| 458 |
+} |
| ... | ... |
@@ -4,6 +4,7 @@ package plugin |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 | 6 |
"errors" |
| 7 |
+ "fmt" |
|
| 7 | 8 |
"io" |
| 8 | 9 |
"net/http" |
| 9 | 10 |
|
| ... | ... |
@@ -24,8 +25,11 @@ func (pm *Manager) Enable(name string, config *types.PluginEnableConfig) error {
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
// Inspect examines a plugin config |
| 27 |
-func (pm *Manager) Inspect(name string) (tp types.Plugin, err error) {
|
|
| 28 |
- return tp, errNotSupported |
|
| 27 |
+func (pm *Manager) Inspect(refOrID string) (tp types.Plugin, err error) {
|
|
| 28 |
+ // Even though plugin is not supported, we still want to return `not found` |
|
| 29 |
+ // error so that `docker inspect` (without `--type` specified) returns correct |
|
| 30 |
+ // `not found` message |
|
| 31 |
+ return tp, fmt.Errorf("no such plugin name or ID associated with %q", refOrID)
|
|
| 29 | 32 |
} |
| 30 | 33 |
|
| 31 | 34 |
// Privileges pulls a plugin config and computes the privileges required to install it. |