mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
96ce3a194a
This patch creates a new cli package that allows to combine both client and daemon commands (there is only one daemon command: docker daemon). The `-d` and `--daemon` top-level flags are deprecated and a special message is added to prompt the user to use `docker daemon`. Providing top-level daemon-specific flags for client commands result in an error message prompting the user to use `docker daemon`. This patch does not break any old but correct usages. This also makes `-d` and `--daemon` flags, as well as the `daemon` command illegal in client-only binaries. Signed-off-by: Tibor Vass <tibor@docker.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package client
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
Cli "github.com/docker/docker/cli"
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
"github.com/docker/docker/pkg/parsers"
|
|
"github.com/docker/docker/registry"
|
|
)
|
|
|
|
// CmdTag tags an image into a repository.
|
|
//
|
|
// Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
|
|
func (cli *DockerCli) CmdTag(args ...string) error {
|
|
cmd := Cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, "Tag an image into a repository", true)
|
|
force := cmd.Bool([]string{"f", "#force", "-force"}, false, "Force")
|
|
cmd.Require(flag.Exact, 2)
|
|
|
|
cmd.ParseFlags(args, true)
|
|
|
|
var (
|
|
repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1))
|
|
v = url.Values{}
|
|
)
|
|
|
|
//Check if the given image name can be resolved
|
|
if err := registry.ValidateRepositoryName(repository); err != nil {
|
|
return err
|
|
}
|
|
v.Set("repo", repository)
|
|
v.Set("tag", tag)
|
|
|
|
if *force {
|
|
v.Set("force", "1")
|
|
}
|
|
|
|
if _, _, err := readBody(cli.call("POST", "/images/"+cmd.Arg(0)+"/tag?"+v.Encode(), nil, nil)); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|