Merge pull request #10320 from shishir-a412ed/cleanup_cmd_tag
cleanup of docker tag command code
This commit is contained in:
commit
81f74caee8
2 changed files with 1 additions and 27 deletions
|
@ -12,8 +12,7 @@ import (
|
||||||
func (s *TagStore) Install(eng *engine.Engine) error {
|
func (s *TagStore) Install(eng *engine.Engine) error {
|
||||||
for name, handler := range map[string]engine.Handler{
|
for name, handler := range map[string]engine.Handler{
|
||||||
"image_set": s.CmdSet,
|
"image_set": s.CmdSet,
|
||||||
"image_tag": s.CmdTag,
|
"tag": s.CmdTag,
|
||||||
"tag": s.CmdTagLegacy, // FIXME merge with "image_tag"
|
|
||||||
"image_get": s.CmdGet,
|
"image_get": s.CmdGet,
|
||||||
"image_inspect": s.CmdLookup,
|
"image_inspect": s.CmdLookup,
|
||||||
"image_tarlayer": s.CmdTarLayer,
|
"image_tarlayer": s.CmdTarLayer,
|
||||||
|
|
25
graph/tag.go
25
graph/tag.go
|
@ -2,34 +2,9 @@ package graph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/engine"
|
"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 {
|
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 {
|
if len(job.Args) != 2 && len(job.Args) != 3 {
|
||||||
return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name)
|
return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue