From e5361f1d31da9022ddf1a7d305993481677a6e63 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Tue, 10 Jan 2017 19:27:55 -0800 Subject: [PATCH] Add the mediaType to the error Without this fix the error the client might see is: target is unknown which wasn't helpful to me when I saw this today. With this fix I now see: MediaType is unknown: 'text/html' which helped me track down the issue to the registry I was talking to. Signed-off-by: Doug Davis Upstream-commit: c127d9614f5b30bd73861877f8540a63e7d869e9 Component: engine --- components/engine/cli/command/image/pull.go | 2 +- components/engine/cli/command/plugin/install.go | 2 +- components/engine/distribution/pull_v2.go | 2 +- components/engine/integration-cli/docker_cli_plugins_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/engine/cli/command/image/pull.go b/components/engine/cli/command/image/pull.go index 967beca86f..08e2e8b7e5 100644 --- a/components/engine/cli/command/image/pull.go +++ b/components/engine/cli/command/image/pull.go @@ -76,7 +76,7 @@ func runPull(dockerCli *command.DockerCli, opts pullOptions) error { err = imagePullPrivileged(ctx, dockerCli, authConfig, reference.FamiliarString(distributionRef), requestPrivilege, opts.all) } if err != nil { - if strings.Contains(err.Error(), "target is plugin") { + if strings.Contains(err.Error(), "when fetching 'plugin'") { return errors.New(err.Error() + " - Use `docker plugin install`") } return err diff --git a/components/engine/cli/command/plugin/install.go b/components/engine/cli/command/plugin/install.go index ebfe1f1eec..d15784f03f 100644 --- a/components/engine/cli/command/plugin/install.go +++ b/components/engine/cli/command/plugin/install.go @@ -152,7 +152,7 @@ func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error { responseBody, err := dockerCli.Client().PluginInstall(ctx, alias, options) if err != nil { - if strings.Contains(err.Error(), "target is image") { + if strings.Contains(err.Error(), "(image) when fetching") { return errors.New(err.Error() + " - Use `docker image pull`") } return err diff --git a/components/engine/distribution/pull_v2.go b/components/engine/distribution/pull_v2.go index e707e7d3b6..b02388651a 100644 --- a/components/engine/distribution/pull_v2.go +++ b/components/engine/distribution/pull_v2.go @@ -363,7 +363,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat if configClass == "" { configClass = "unknown" } - return false, fmt.Errorf("target is %s", configClass) + return false, fmt.Errorf("Encountered remote %q(%s) when fetching", m.Manifest.Config.MediaType, configClass) } } diff --git a/components/engine/integration-cli/docker_cli_plugins_test.go b/components/engine/integration-cli/docker_cli_plugins_test.go index e294fffd19..c9c0fb6cf1 100644 --- a/components/engine/integration-cli/docker_cli_plugins_test.go +++ b/components/engine/integration-cli/docker_cli_plugins_test.go @@ -181,7 +181,7 @@ func (s *DockerRegistrySuite) TestPluginInstallImage(c *check.C) { out, _, err := dockerCmdWithError("plugin", "install", repoName) c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "target is image") + c.Assert(out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`) } func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {