Browse code

Moving Image{Push,Pull}Privileged to trust.go

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/06/10 19:07:32
Showing 7 changed files
... ...
@@ -11,7 +11,6 @@ func (cli *DockerCli) Command(name string) func(...string) error {
11 11
 		"login":   cli.CmdLogin,
12 12
 		"logout":  cli.CmdLogout,
13 13
 		"ps":      cli.CmdPs,
14
-		"push":    cli.CmdPush,
15 14
 		"update":  cli.CmdUpdate,
16 15
 	}[name]
17 16
 }
... ...
@@ -41,7 +41,6 @@ func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command {
41 41
 }
42 42
 
43 43
 func runPull(dockerCli *client.DockerCli, opts pullOptions) error {
44
-
45 44
 	distributionRef, err := reference.ParseNamed(opts.remote)
46 45
 	if err != nil {
47 46
 		return err
... ...
@@ -30,7 +30,6 @@ func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command {
30 30
 }
31 31
 
32 32
 func runPush(dockerCli *client.DockerCli, remote string) error {
33
-
34 33
 	ref, err := reference.ParseNamed(remote)
35 34
 	if err != nil {
36 35
 		return err
37 36
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-package client
2
-
3
-import (
4
-	"golang.org/x/net/context"
5
-
6
-	"github.com/docker/docker/pkg/jsonmessage"
7
-	"github.com/docker/engine-api/types"
8
-)
9
-
10
-// ImagePullPrivileged pulls the image and displays it to the output
11
-func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
12
-
13
-	encodedAuth, err := EncodeAuthToBase64(authConfig)
14
-	if err != nil {
15
-		return err
16
-	}
17
-	options := types.ImagePullOptions{
18
-		RegistryAuth:  encodedAuth,
19
-		PrivilegeFunc: requestPrivilege,
20
-		All:           all,
21
-	}
22
-
23
-	responseBody, err := cli.client.ImagePull(ctx, ref, options)
24
-	if err != nil {
25
-		return err
26
-	}
27
-	defer responseBody.Close()
28
-
29
-	return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
30
-}
31 1
deleted file mode 100644
... ...
@@ -1,23 +0,0 @@
1
-package client
2
-
3
-import (
4
-	"io"
5
-
6
-	"golang.org/x/net/context"
7
-
8
-	"github.com/docker/engine-api/types"
9
-)
10
-
11
-// ImagePushPrivileged push the image
12
-func (cli *DockerCli) ImagePushPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) (io.ReadCloser, error) {
13
-	encodedAuth, err := EncodeAuthToBase64(authConfig)
14
-	if err != nil {
15
-		return nil, err
16
-	}
17
-	options := types.ImagePushOptions{
18
-		RegistryAuth:  encodedAuth,
19
-		PrivilegeFunc: requestPrivilege,
20
-	}
21
-
22
-	return cli.client.ImagePush(ctx, ref, options)
23
-}
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"encoding/json"
6 6
 	"errors"
7 7
 	"fmt"
8
+	"io"
8 9
 	"net"
9 10
 	"net/http"
10 11
 	"net/url"
... ...
@@ -566,3 +567,39 @@ func (cli *DockerCli) addTargetToAllSignableRoles(repo *client.NotaryRepository,
566 566
 
567 567
 	return repo.AddTarget(target, signableRoles...)
568 568
 }
569
+
570
+// ImagePullPrivileged pulls the image and displays it to the output
571
+func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
572
+
573
+	encodedAuth, err := EncodeAuthToBase64(authConfig)
574
+	if err != nil {
575
+		return err
576
+	}
577
+	options := types.ImagePullOptions{
578
+		RegistryAuth:  encodedAuth,
579
+		PrivilegeFunc: requestPrivilege,
580
+		All:           all,
581
+	}
582
+
583
+	responseBody, err := cli.client.ImagePull(ctx, ref, options)
584
+	if err != nil {
585
+		return err
586
+	}
587
+	defer responseBody.Close()
588
+
589
+	return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
590
+}
591
+
592
+// ImagePushPrivileged push the image
593
+func (cli *DockerCli) ImagePushPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) (io.ReadCloser, error) {
594
+	encodedAuth, err := EncodeAuthToBase64(authConfig)
595
+	if err != nil {
596
+		return nil, err
597
+	}
598
+	options := types.ImagePushOptions{
599
+		RegistryAuth:  encodedAuth,
600
+		PrivilegeFunc: requestPrivilege,
601
+	}
602
+
603
+	return cli.client.ImagePush(ctx, ref, options)
604
+}
... ...
@@ -16,7 +16,6 @@ var DockerCommandUsage = []Command{
16 16
 	{"login", "Log in to a Docker registry"},
17 17
 	{"logout", "Log out from a Docker registry"},
18 18
 	{"ps", "List containers"},
19
-	{"push", "Push an image or a repository to a registry"},
20 19
 	{"update", "Update configuration of one or more containers"},
21 20
 }
22 21