Skip to content

Commit ad4e20c

Browse files
committed
Moving Image{Push,Pull}Privileged to trust.go
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 9640e3a commit ad4e20c

File tree

7 files changed

+37
-57
lines changed

7 files changed

+37
-57
lines changed

api/client/commands.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ func (cli *DockerCli) Command(name string) func(...string) error {
1111
"login": cli.CmdLogin,
1212
"logout": cli.CmdLogout,
1313
"ps": cli.CmdPs,
14-
"push": cli.CmdPush,
1514
"update": cli.CmdUpdate,
1615
}[name]
1716
}

api/client/image/pull.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command {
4141
}
4242

4343
func runPull(dockerCli *client.DockerCli, opts pullOptions) error {
44-
4544
distributionRef, err := reference.ParseNamed(opts.remote)
4645
if err != nil {
4746
return err

api/client/image/push.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command {
3030
}
3131

3232
func runPush(dockerCli *client.DockerCli, remote string) error {
33-
3433
ref, err := reference.ParseNamed(remote)
3534
if err != nil {
3635
return err

api/client/pull.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

api/client/push.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

api/client/trust.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"io"
89
"net"
910
"net/http"
1011
"net/url"
@@ -566,3 +567,39 @@ func (cli *DockerCli) addTargetToAllSignableRoles(repo *client.NotaryRepository,
566567

567568
return repo.AddTarget(target, signableRoles...)
568569
}
570+
571+
// ImagePullPrivileged pulls the image and displays it to the output
572+
func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
573+
574+
encodedAuth, err := EncodeAuthToBase64(authConfig)
575+
if err != nil {
576+
return err
577+
}
578+
options := types.ImagePullOptions{
579+
RegistryAuth: encodedAuth,
580+
PrivilegeFunc: requestPrivilege,
581+
All: all,
582+
}
583+
584+
responseBody, err := cli.client.ImagePull(ctx, ref, options)
585+
if err != nil {
586+
return err
587+
}
588+
defer responseBody.Close()
589+
590+
return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
591+
}
592+
593+
// ImagePushPrivileged push the image
594+
func (cli *DockerCli) ImagePushPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) (io.ReadCloser, error) {
595+
encodedAuth, err := EncodeAuthToBase64(authConfig)
596+
if err != nil {
597+
return nil, err
598+
}
599+
options := types.ImagePushOptions{
600+
RegistryAuth: encodedAuth,
601+
PrivilegeFunc: requestPrivilege,
602+
}
603+
604+
return cli.client.ImagePush(ctx, ref, options)
605+
}

cli/usage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var DockerCommandUsage = []Command{
1616
{"login", "Log in to a Docker registry"},
1717
{"logout", "Log out from a Docker registry"},
1818
{"ps", "List containers"},
19-
{"push", "Push an image or a repository to a registry"},
2019
{"update", "Update configuration of one or more containers"},
2120
}
2221

0 commit comments

Comments
 (0)