Skip to content

Commit

Permalink
push: wrap some errors so the error message has more context.
Browse files Browse the repository at this point in the history
Turns:

    denied: requested access to the resource is denied

into:

    pushing to "docker.io/library/hello-world:0.1.0-invoc": denied: requested access to the resource is denied

Signed-off-by: Ian Campbell <ijc@docker.com>
  • Loading branch information
Ian Campbell committed May 13, 2019
1 parent 96d4d9b commit 8d7750b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
RegistryAuth: encodedAuth,
})
if err != nil {
return err
return errors.Wrapf(err, "starting push of %q", retag.invocationImageRef.String())
}
defer reader.Close()
if err = jsonmessage.DisplayJSONMessagesStream(reader, ioutil.Discard, 0, false, nil); err != nil {
return err
return errors.Wrapf(err, "pushing to %q", retag.invocationImageRef.String())
}

resolverConfig := remotes.NewResolverConfigFromDockerConfigFile(dockerCli.ConfigFile(), opts.registry.insecureRegistries...)
Expand All @@ -107,12 +107,12 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, fixupOptions...)

if err != nil {
return err
return errors.Wrapf(err, "fixing up %q for push", retag.cnabRef)
}
// push bundle manifest
descriptor, err := remotes.Push(context.Background(), bndl, retag.cnabRef, resolverConfig.Resolver, true)
if err != nil {
return err
return errors.Wrapf(err, "pushing to %q", retag.cnabRef)
}
fmt.Printf("Successfully pushed bundle to %s. Digest is %s.\n", retag.cnabRef.String(), descriptor.Digest)
return nil
Expand Down

0 comments on commit 8d7750b

Please sign in to comment.