Browse Source

Fix inspect object by invalid reference

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 8 years ago
parent
commit
3cd39aaeab
2 changed files with 9 additions and 1 deletions
  1. 8 0
      integration-cli/docker_cli_inspect_test.go
  2. 1 1
      plugin/store.go

+ 8 - 0
integration-cli/docker_cli_inspect_test.go

@@ -456,3 +456,11 @@ func (s *DockerSuite) TestInspectUnknownObject(c *check.C) {
 	c.Assert(out, checker.Contains, "Error: No such object: foobar")
 	c.Assert(out, checker.Contains, "Error: No such object: foobar")
 	c.Assert(err.Error(), checker.Contains, "Error: No such object: foobar")
 	c.Assert(err.Error(), checker.Contains, "Error: No such object: foobar")
 }
 }
+
+func (s *DockerSuite) TestInpectInvalidReference(c *check.C) {
+	// This test should work on both Windows and Linux
+	out, _, err := dockerCmdWithError("inspect", "FooBar")
+	c.Assert(err, checker.NotNil)
+	c.Assert(out, checker.Contains, "Error: No such object: FooBar")
+	c.Assert(err.Error(), checker.Contains, "Error: No such object: FooBar")
+}

+ 1 - 1
plugin/store.go

@@ -232,7 +232,7 @@ func (ps *Store) resolvePluginID(idOrName string) (string, error) {
 
 
 	ref, err := reference.ParseNamed(idOrName)
 	ref, err := reference.ParseNamed(idOrName)
 	if err != nil {
 	if err != nil {
-		return "", errors.Wrapf(err, "failed to parse %v", idOrName)
+		return "", errors.WithStack(ErrNotFound(idOrName))
 	}
 	}
 	if _, ok := ref.(reference.Canonical); ok {
 	if _, ok := ref.(reference.Canonical); ok {
 		logrus.Warnf("canonical references cannot be resolved: %v", ref.String())
 		logrus.Warnf("canonical references cannot be resolved: %v", ref.String())