mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Moving Image{Push,Pull}Privileged to trust.go
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
9640e3a451
commit
ad4e20cd92
7 changed files with 37 additions and 57 deletions
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
|
@ -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)
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue