diff --git a/graph/service.go b/graph/service.go index 80ab6de3fd..2776d65968 100644 --- a/graph/service.go +++ b/graph/service.go @@ -5,13 +5,13 @@ import ( "github.com/docker/docker/engine" "github.com/docker/docker/image" - "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/utils" ) func (s *TagStore) Install(eng *engine.Engine) error { eng.Register("image_set", s.CmdSet) eng.Register("image_tag", s.CmdTag) + eng.Register("tag", s.CmdTagLegacy) // FIXME merge with "image_tag" eng.Register("image_get", s.CmdGet) eng.Register("image_inspect", s.CmdLookup) eng.Register("image_tarlayer", s.CmdTarLayer) @@ -71,29 +71,6 @@ func (s *TagStore) CmdSet(job *engine.Job) engine.Status { return engine.StatusOK } -// CmdTag assigns a new name and tag to an existing image. If the tag already exists, -// it is changed and the image previously referenced by the tag loses that reference. -// This may cause the old image to be garbage-collected if its reference count reaches zero. -// -// Syntax: image_tag NEWNAME OLDNAME -// Example: image_tag shykes/myapp:latest shykes/myapp:1.42.0 -func (s *TagStore) CmdTag(job *engine.Job) engine.Status { - if len(job.Args) != 2 { - return job.Errorf("usage: %s NEWNAME OLDNAME", job.Name) - } - var ( - newName = job.Args[0] - oldName = job.Args[1] - ) - newRepo, newTag := parsers.ParseRepositoryTag(newName) - // FIXME: Set should either parse both old and new name, or neither. - // the current prototype is inconsistent. - if err := s.Set(newRepo, newTag, oldName, true); err != nil { - return job.Error(err) - } - return engine.StatusOK -} - // CmdGet returns information about an image. // If the image doesn't exist, an empty object is returned, to allow // checking for an image's existence. diff --git a/graph/tag.go b/graph/tag.go new file mode 100644 index 0000000000..3d89422f9d --- /dev/null +++ b/graph/tag.go @@ -0,0 +1,44 @@ +package graph + +import ( + "github.com/docker/docker/engine" + "github.com/docker/docker/pkg/parsers" +) + +// CmdTag assigns a new name and tag to an existing image. If the tag already exists, +// it is changed and the image previously referenced by the tag loses that reference. +// This may cause the old image to be garbage-collected if its reference count reaches zero. +// +// Syntax: image_tag NEWNAME OLDNAME +// Example: image_tag shykes/myapp:latest shykes/myapp:1.42.0 +func (s *TagStore) CmdTag(job *engine.Job) engine.Status { + if len(job.Args) != 2 { + return job.Errorf("usage: %s NEWNAME OLDNAME", job.Name) + } + var ( + newName = job.Args[0] + oldName = job.Args[1] + ) + newRepo, newTag := parsers.ParseRepositoryTag(newName) + // FIXME: Set should either parse both old and new name, or neither. + // the current prototype is inconsistent. + if err := s.Set(newRepo, newTag, oldName, true); err != nil { + return job.Error(err) + } + return engine.StatusOK +} + +// FIXME: merge into CmdTag above, and merge "image_tag" and "tag" into a single job. +func (s *TagStore) CmdTagLegacy(job *engine.Job) engine.Status { + if len(job.Args) != 2 && len(job.Args) != 3 { + return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name) + } + var tag string + if len(job.Args) == 3 { + tag = job.Args[2] + } + if err := s.Set(job.Args[1], tag, job.Args[0], job.GetenvBool("force")); err != nil { + return job.Error(err) + } + return engine.StatusOK +} diff --git a/server/image.go b/server/image.go index 3260611f3f..5cde8dd63e 100644 --- a/server/image.go +++ b/server/image.go @@ -105,20 +105,6 @@ func (srv *Server) Build(job *engine.Job) engine.Status { return engine.StatusOK } -func (srv *Server) ImageTag(job *engine.Job) engine.Status { - if len(job.Args) != 2 && len(job.Args) != 3 { - return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name) - } - var tag string - if len(job.Args) == 3 { - tag = job.Args[2] - } - if err := srv.daemon.Repositories().Set(job.Args[1], tag, job.Args[0], job.GetenvBool("force")); err != nil { - return job.Error(err) - } - return engine.StatusOK -} - func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoint string, token []string, sf *utils.StreamFormatter) error { history, err := r.GetRemoteHistory(imgID, endpoint, token) if err != nil { diff --git a/server/init.go b/server/init.go index 102e3ddf22..a3866e7bef 100644 --- a/server/init.go +++ b/server/init.go @@ -86,7 +86,6 @@ func InitServer(job *engine.Job) engine.Status { job.Eng.Hack_SetGlobalVar("httpapi.daemon", srv.daemon) for name, handler := range map[string]engine.Handler{ - "tag": srv.ImageTag, // FIXME merge with "image_tag" "info": srv.DockerInfo, "log": srv.Log, "build": srv.Build,