Browse code

Merge pull request #30047 from duglin/distError

Add the mediaType to the error

Tibor Vass authored on 2017/03/11 09:44:49
Showing 4 changed files
... ...
@@ -76,7 +76,7 @@ func runPull(dockerCli *command.DockerCli, opts pullOptions) error {
76 76
 		err = imagePullPrivileged(ctx, dockerCli, authConfig, reference.FamiliarString(distributionRef), requestPrivilege, opts.all)
77 77
 	}
78 78
 	if err != nil {
79
-		if strings.Contains(err.Error(), "target is plugin") {
79
+		if strings.Contains(err.Error(), "when fetching 'plugin'") {
80 80
 			return errors.New(err.Error() + " - Use `docker plugin install`")
81 81
 		}
82 82
 		return err
... ...
@@ -144,7 +144,7 @@ func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error {
144 144
 	}
145 145
 	responseBody, err := dockerCli.Client().PluginInstall(ctx, localName, options)
146 146
 	if err != nil {
147
-		if strings.Contains(err.Error(), "target is image") {
147
+		if strings.Contains(err.Error(), "(image) when fetching") {
148 148
 			return errors.New(err.Error() + " - Use `docker image pull`")
149 149
 		}
150 150
 		return err
... ...
@@ -363,7 +363,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat
363 363
 			if configClass == "" {
364 364
 				configClass = "unknown"
365 365
 			}
366
-			return false, fmt.Errorf("target is %s", configClass)
366
+			return false, fmt.Errorf("Encountered remote %q(%s) when fetching", m.Manifest.Config.MediaType, configClass)
367 367
 		}
368 368
 	}
369 369
 
... ...
@@ -181,7 +181,7 @@ func (s *DockerRegistrySuite) TestPluginInstallImage(c *check.C) {
181 181
 
182 182
 	out, _, err := dockerCmdWithError("plugin", "install", repoName)
183 183
 	c.Assert(err, checker.NotNil)
184
-	c.Assert(out, checker.Contains, "target is image")
184
+	c.Assert(out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
185 185
 }
186 186
 
187 187
 func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {