mirror of https://github.com/docker/docs.git
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
|
|
@ -11,7 +11,6 @@ func (cli *DockerCli) Command(name string) func(...string) error {
|
||||||
"login": cli.CmdLogin,
|
"login": cli.CmdLogin,
|
||||||
"logout": cli.CmdLogout,
|
"logout": cli.CmdLogout,
|
||||||
"ps": cli.CmdPs,
|
"ps": cli.CmdPs,
|
||||||
"push": cli.CmdPush,
|
|
||||||
"update": cli.CmdUpdate,
|
"update": cli.CmdUpdate,
|
||||||
}[name]
|
}[name]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ func NewPullCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPull(dockerCli *client.DockerCli, opts pullOptions) error {
|
func runPull(dockerCli *client.DockerCli, opts pullOptions) error {
|
||||||
|
|
||||||
distributionRef, err := reference.ParseNamed(opts.remote)
|
distributionRef, err := reference.ParseNamed(opts.remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ func NewPushCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPush(dockerCli *client.DockerCli, remote string) error {
|
func runPush(dockerCli *client.DockerCli, remote string) error {
|
||||||
|
|
||||||
ref, err := reference.ParseNamed(remote)
|
ref, err := reference.ParseNamed(remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -566,3 +567,39 @@ func (cli *DockerCli) addTargetToAllSignableRoles(repo *client.NotaryRepository,
|
||||||
|
|
||||||
return repo.AddTarget(target, signableRoles...)
|
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"},
|
{"login", "Log in to a Docker registry"},
|
||||||
{"logout", "Log out from a Docker registry"},
|
{"logout", "Log out from a Docker registry"},
|
||||||
{"ps", "List containers"},
|
{"ps", "List containers"},
|
||||||
{"push", "Push an image or a repository to a registry"},
|
|
||||||
{"update", "Update configuration of one or more containers"},
|
{"update", "Update configuration of one or more containers"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue