1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Reactivated CmdPush in commands.go

This commit is contained in:
shin- 2013-04-23 12:02:16 -07:00
parent e179c66400
commit 6644a3c78a
2 changed files with 53 additions and 52 deletions

View file

@ -492,64 +492,65 @@ func (srv *Server) CmdImport(stdin io.ReadCloser, stdout rcli.DockerConn, args .
return nil return nil
} }
// func (srv *Server) CmdPush(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error { func (srv *Server) CmdPush(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error {
// cmd := rcli.Subcmd(stdout, "push", "NAME", "Push an image or a repository to the registry") cmd := rcli.Subcmd(stdout, "push", "NAME", "Push an image or a repository to the registry")
// if err := cmd.Parse(args); err != nil { registry := cmd.String("registry", "", "Registry host to push the image to")
// return nil if err := cmd.Parse(args); err != nil {
// } return nil
// local := cmd.Arg(0) }
local := cmd.Arg(0)
// if local == "" { if local == "" {
// cmd.Usage() cmd.Usage()
// return nil return nil
// } }
// // If the login failed, abort // If the login failed AND we're using the index, abort
// if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" { if *registry == "" && (srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "") {
// if err := srv.CmdLogin(stdin, stdout, args...); err != nil { if err := srv.CmdLogin(stdin, stdout, args...); err != nil {
// return err return err
// } }
// if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" { if srv.runtime.authConfig == nil || srv.runtime.authConfig.Username == "" {
// return fmt.Errorf("Please login prior to push. ('docker login')") return fmt.Errorf("Please login prior to push. ('docker login')")
// } }
// } }
// var remote string var remote string
// tmp := strings.SplitN(local, "/", 2) tmp := strings.SplitN(local, "/", 2)
// if len(tmp) == 1 { if len(tmp) == 1 {
// return fmt.Errorf( return fmt.Errorf(
// "Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)", "Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)",
// srv.runtime.authConfig.Username, local) srv.runtime.authConfig.Username, local)
// } else { } else {
// remote = local remote = local
// } }
// Debugf("Pushing [%s] to [%s]\n", local, remote) Debugf("Pushing [%s] to [%s]\n", local, remote)
// // Try to get the image // Try to get the image
// // FIXME: Handle lookup // FIXME: Handle lookup
// // FIXME: Also push the tags in case of ./docker push myrepo:mytag // FIXME: Also push the tags in case of ./docker push myrepo:mytag
// // img, err := srv.runtime.LookupImage(cmd.Arg(0)) // img, err := srv.runtime.LookupImage(cmd.Arg(0))
// img, err := srv.runtime.graph.Get(local) img, err := srv.runtime.graph.Get(local)
// if err != nil { if err != nil {
// Debugf("The push refers to a repository [%s] (len: %d)\n", local, len(srv.runtime.repositories.Repositories[local])) Debugf("The push refers to a repository [%s] (len: %d)\n", local, len(srv.runtime.repositories.Repositories[local]))
// // If it fails, try to get the repository // If it fails, try to get the repository
// if localRepo, exists := srv.runtime.repositories.Repositories[local]; exists { if localRepo, exists := srv.runtime.repositories.Repositories[local]; exists {
// if err := srv.runtime.graph.PushRepository(stdout, remote, localRepo, srv.runtime.authConfig); err != nil { if err := srv.runtime.graph.PushRepository(stdout, remote, localRepo, srv.runtime.authConfig); err != nil {
// return err return err
// } }
// return nil return nil
// } }
// return err return err
// } }
// err = srv.runtime.graph.PushImage(stdout, img, srv.runtime.authConfig) err = srv.runtime.graph.PushImage(stdout, img, *registry, nil)
// if err != nil { if err != nil {
// return err return err
// } }
// return nil return nil
// } }
func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string) error { func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
cmd := rcli.Subcmd(stdout, "pull", "NAME", "Pull an image or a repository from the registry") cmd := rcli.Subcmd(stdout, "pull", "NAME", "Pull an image or a repository from the registry")

View file

@ -312,7 +312,7 @@ func (graph *Graph) Checksums(repo Repository) ([]map[string]string, error) {
i := 0 i := 0
for id, sum := range checksums { for id, sum := range checksums {
result[i] = map[string]string{ result[i] = map[string]string{
"id": id, "id": id,
"checksum": sum, "checksum": sum,
} }
i++ i++