зеркало из https://github.com/microsoft/docker.git
Remove deprecated -f flag on docker tag
The -f flag on docker tag has been deprecated in docker 1.10 and is expected to be removed in docker 1.12. This fix removed the -f flag on docker tag and also updated deprecated.md. NOTE: A separate pull request for engine-api has been opened to cover the related changes. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Родитель
1dab9af5d5
Коммит
4455ec14b8
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
Cli "github.com/docker/docker/cli"
|
Cli "github.com/docker/docker/cli"
|
||||||
flag "github.com/docker/docker/pkg/mflag"
|
flag "github.com/docker/docker/pkg/mflag"
|
||||||
"github.com/docker/engine-api/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CmdTag tags an image into a repository.
|
// CmdTag tags an image into a repository.
|
||||||
|
@ -13,14 +12,9 @@ import (
|
||||||
// Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
|
// Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
|
||||||
func (cli *DockerCli) CmdTag(args ...string) error {
|
func (cli *DockerCli) CmdTag(args ...string) error {
|
||||||
cmd := Cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, Cli.DockerCommands["tag"].Description, true)
|
cmd := Cli.Subcmd("tag", []string{"IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]"}, Cli.DockerCommands["tag"].Description, true)
|
||||||
force := cmd.Bool([]string{"#f", "#-force"}, false, "Force the tagging even if there's a conflict")
|
|
||||||
cmd.Require(flag.Exact, 2)
|
cmd.Require(flag.Exact, 2)
|
||||||
|
|
||||||
cmd.ParseFlags(args, true)
|
cmd.ParseFlags(args, true)
|
||||||
|
|
||||||
options := types.ImageTagOptions{
|
return cli.client.ImageTag(context.Background(), cmd.Arg(0), cmd.Arg(1))
|
||||||
Force: *force,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cli.client.ImageTag(context.Background(), cmd.Arg(0), cmd.Arg(1), options)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,11 +265,7 @@ func (cli *DockerCli) trustedReference(ctx context.Context, ref reference.NamedT
|
||||||
func (cli *DockerCli) tagTrusted(ctx context.Context, trustedRef reference.Canonical, ref reference.NamedTagged) error {
|
func (cli *DockerCli) tagTrusted(ctx context.Context, trustedRef reference.Canonical, ref reference.NamedTagged) error {
|
||||||
fmt.Fprintf(cli.out, "Tagging %s as %s\n", trustedRef.String(), ref.String())
|
fmt.Fprintf(cli.out, "Tagging %s as %s\n", trustedRef.String(), ref.String())
|
||||||
|
|
||||||
options := types.ImageTagOptions{
|
return cli.client.ImageTag(ctx, trustedRef.String(), ref.String())
|
||||||
Force: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
return cli.client.ImageTag(ctx, trustedRef.String(), ref.String(), options)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func notaryError(repoName string, err error) error {
|
func notaryError(repoName string, err error) error {
|
||||||
|
|
|
@ -35,9 +35,9 @@ The fields `ID`, `Status` and `From` in the events API have been deprecated in f
|
||||||
See the events API documentation for the new format.
|
See the events API documentation for the new format.
|
||||||
|
|
||||||
### `-f` flag on `docker tag`
|
### `-f` flag on `docker tag`
|
||||||
**Deprecated In Release: v1.10**
|
**Deprecated In Release: [v1.10.0](https://github.com/docker/docker/releases/tag/v1.10.0)**
|
||||||
|
|
||||||
**Target For Removal In Release: v1.12**
|
**Removed In Release: v1.12.0**
|
||||||
|
|
||||||
To make tagging consistent across the various `docker` commands, the `-f` flag on the `docker tag` command is deprecated. It is not longer necessary to specify `-f` to move a tag from one image to another. Nor will `docker` generate an error if the `-f` flag is missing and the specified tag is already in use.
|
To make tagging consistent across the various `docker` commands, the `-f` flag on the `docker tag` command is deprecated. It is not longer necessary to specify `-f` to move a tag from one image to another. Nor will `docker` generate an error if the `-f` flag is missing and the specified tag is already in use.
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *check.C) {
|
||||||
imageID := stringid.TruncateID(strings.TrimSpace(out))
|
imageID := stringid.TruncateID(strings.TrimSpace(out))
|
||||||
|
|
||||||
// overwrite the tag, making the previous image dangling
|
// overwrite the tag, making the previous image dangling
|
||||||
dockerCmd(c, "tag", "-f", "busybox", "foobox")
|
dockerCmd(c, "tag", "busybox", "foobox")
|
||||||
|
|
||||||
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=true")
|
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=true")
|
||||||
// Expect one dangling image
|
// Expect one dangling image
|
||||||
|
|
|
@ -658,7 +658,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) {
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
runCmd = exec.Command(dockerBinary, "tag", "-f", updatedImageName, originalImageName)
|
runCmd = exec.Command(dockerBinary, "tag", updatedImageName, originalImageName)
|
||||||
out, _, err = runCommandWithOutput(runCmd)
|
out, _, err = runCommandWithOutput(runCmd)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
|
|
@ -86,19 +86,6 @@ func (s *DockerSuite) TestTagExistedNameWithoutForce(c *check.C) {
|
||||||
dockerCmd(c, "tag", "busybox:latest", "busybox:test")
|
dockerCmd(c, "tag", "busybox:latest", "busybox:test")
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag an image with an existed tag name with -f option should work
|
|
||||||
func (s *DockerSuite) TestTagExistedNameWithForce(c *check.C) {
|
|
||||||
// Don't attempt to pull on Windows as not in hub. It's installed
|
|
||||||
// as an image through .ensure-frozen-images-windows
|
|
||||||
if daemonPlatform != "windows" {
|
|
||||||
if err := pullImageIfNotExist("busybox:latest"); err != nil {
|
|
||||||
c.Fatal("couldn't find the busybox:latest image locally and failed to pull it")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dockerCmd(c, "tag", "busybox:latest", "busybox:test")
|
|
||||||
dockerCmd(c, "tag", "-f", "busybox:latest", "busybox:test")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DockerSuite) TestTagWithPrefixHyphen(c *check.C) {
|
func (s *DockerSuite) TestTagWithPrefixHyphen(c *check.C) {
|
||||||
// Don't attempt to pull on Windows as not in hub. It's installed
|
// Don't attempt to pull on Windows as not in hub. It's installed
|
||||||
// as an image through .ensure-frozen-images-windows
|
// as an image through .ensure-frozen-images-windows
|
||||||
|
|
Загрузка…
Ссылка в новой задаче