Browse Source

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

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Vincent Demeester 9 years ago
parent
commit
ad4e20cd92
7 changed files with 37 additions and 57 deletions
  1. 0 1
      api/client/commands.go
  2. 0 1
      api/client/image/pull.go
  3. 0 1
      api/client/image/push.go
  4. 0 30
      api/client/pull.go
  5. 0 23
      api/client/push.go
  6. 37 0
      api/client/trust.go
  7. 0 1
      cli/usage.go

+ 0 - 1
api/client/commands.go

@@ -11,7 +11,6 @@ func (cli *DockerCli) Command(name string) func(...string) error {
 		"login":   cli.CmdLogin,
 		"logout":  cli.CmdLogout,
 		"ps":      cli.CmdPs,
-		"push":    cli.CmdPush,
 		"update":  cli.CmdUpdate,
 	}[name]
 }

+ 0 - 1
api/client/image/pull.go

@@ -41,7 +41,6 @@ func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command {
 }
 
 func runPull(dockerCli *client.DockerCli, opts pullOptions) error {
-
 	distributionRef, err := reference.ParseNamed(opts.remote)
 	if err != nil {
 		return err

+ 0 - 1
api/client/image/push.go

@@ -30,7 +30,6 @@ func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command {
 }
 
 func runPush(dockerCli *client.DockerCli, remote string) error {
-
 	ref, err := reference.ParseNamed(remote)
 	if err != nil {
 		return err

+ 0 - 30
api/client/pull.go

@@ -1,30 +0,0 @@
-package client
-
-import (
-	"golang.org/x/net/context"
-
-	"github.com/docker/docker/pkg/jsonmessage"
-	"github.com/docker/engine-api/types"
-)
-
-// ImagePullPrivileged pulls the image and displays it to the output
-func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
-
-	encodedAuth, err := EncodeAuthToBase64(authConfig)
-	if err != nil {
-		return err
-	}
-	options := types.ImagePullOptions{
-		RegistryAuth:  encodedAuth,
-		PrivilegeFunc: requestPrivilege,
-		All:           all,
-	}
-
-	responseBody, err := cli.client.ImagePull(ctx, ref, options)
-	if err != nil {
-		return err
-	}
-	defer responseBody.Close()
-
-	return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
-}

+ 0 - 23
api/client/push.go

@@ -1,23 +0,0 @@
-package client
-
-import (
-	"io"
-
-	"golang.org/x/net/context"
-
-	"github.com/docker/engine-api/types"
-)
-
-// ImagePushPrivileged push the image
-func (cli *DockerCli) ImagePushPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) (io.ReadCloser, error) {
-	encodedAuth, err := EncodeAuthToBase64(authConfig)
-	if err != nil {
-		return nil, err
-	}
-	options := types.ImagePushOptions{
-		RegistryAuth:  encodedAuth,
-		PrivilegeFunc: requestPrivilege,
-	}
-
-	return cli.client.ImagePush(ctx, ref, options)
-}

+ 37 - 0
api/client/trust.go

@@ -5,6 +5,7 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	"io"
 	"net"
 	"net/http"
 	"net/url"
@@ -566,3 +567,39 @@ func (cli *DockerCli) addTargetToAllSignableRoles(repo *client.NotaryRepository,
 
 	return repo.AddTarget(target, signableRoles...)
 }
+
+// ImagePullPrivileged pulls the image and displays it to the output
+func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
+
+	encodedAuth, err := EncodeAuthToBase64(authConfig)
+	if err != nil {
+		return err
+	}
+	options := types.ImagePullOptions{
+		RegistryAuth:  encodedAuth,
+		PrivilegeFunc: requestPrivilege,
+		All:           all,
+	}
+
+	responseBody, err := cli.client.ImagePull(ctx, ref, options)
+	if err != nil {
+		return err
+	}
+	defer responseBody.Close()
+
+	return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
+}
+
+// ImagePushPrivileged push the image
+func (cli *DockerCli) ImagePushPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc) (io.ReadCloser, error) {
+	encodedAuth, err := EncodeAuthToBase64(authConfig)
+	if err != nil {
+		return nil, err
+	}
+	options := types.ImagePushOptions{
+		RegistryAuth:  encodedAuth,
+		PrivilegeFunc: requestPrivilege,
+	}
+
+	return cli.client.ImagePush(ctx, ref, options)
+}

+ 0 - 1
cli/usage.go

@@ -16,7 +16,6 @@ var DockerCommandUsage = []Command{
 	{"login", "Log in to a Docker registry"},
 	{"logout", "Log out from a Docker registry"},
 	{"ps", "List containers"},
-	{"push", "Push an image or a repository to a registry"},
 	{"update", "Update configuration of one or more containers"},
 }