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

Remove -run flag from commit command.

This flag has been deprecated in version below 1.10 so it's safe to
remove now, according to our deprecation policy.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2016-08-19 13:14:03 +02:00
parent 2c224e4fc0
commit 54ed156879
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
4 changed files with 10 additions and 125 deletions

View file

@ -1,7 +1,6 @@
package container
import (
"encoding/json"
"fmt"
"golang.org/x/net/context"
@ -10,7 +9,6 @@ import (
"github.com/docker/docker/cli"
dockeropts "github.com/docker/docker/opts"
"github.com/docker/engine-api/types"
containertypes "github.com/docker/engine-api/types/container"
"github.com/spf13/cobra"
)
@ -22,7 +20,6 @@ type commitOptions struct {
comment string
author string
changes dockeropts.ListOpts
config string
}
// NewCommitCommand creates a new cobra.Command for `docker commit`
@ -53,10 +50,6 @@ func NewCommitCommand(dockerCli *client.DockerCli) *cobra.Command {
opts.changes = dockeropts.NewListOpts(nil)
flags.VarP(&opts.changes, "change", "c", "Apply Dockerfile instruction to the created image")
// FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands.
flags.StringVar(&opts.config, "run", "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands")
flags.MarkDeprecated("run", "it will be replaced with inline Dockerfile commands.")
return cmd
}
@ -66,21 +59,12 @@ func runCommit(dockerCli *client.DockerCli, opts *commitOptions) error {
name := opts.container
reference := opts.reference
var config *containertypes.Config
if opts.config != "" {
config = &containertypes.Config{}
if err := json.Unmarshal([]byte(opts.config), config); err != nil {
return err
}
}
options := types.ContainerCommitOptions{
Reference: reference,
Comment: opts.comment,
Author: opts.author,
Changes: opts.changes.GetAll(),
Pause: opts.pause,
Config: config,
}
response, err := dockerCli.Client().ContainerCommit(ctx, name, options)

View file

@ -172,6 +172,15 @@ The single-dash (`-help`) was removed, in favor of the double-dash `--help`
docker -help
docker [COMMAND] -help
### `--run` flag on docker commit
**Deprecated In Release: [v0.10.0](https://github.com/docker/docker/releases/tag/v0.10.0)**
**Removed In Release: [v1.13.0](https://github.com/docker/docker/releases/)**
The flag `--run` of the docker commit (and its short version `-run`) were deprecated in favor
of the `--changes` flag that allows to pass `Dockerfile` commands.
### Interacting with V1 registries
@ -186,3 +195,4 @@ Since 1.9, Docker Content Trust Offline key has been renamed to Root key and the
- DOCKER_CONTENT_TRUST_OFFLINE_PASSPHRASE is now named DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE
- DOCKER_CONTENT_TRUST_TAGGING_PASSPHRASE is now named DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE

View file

@ -438,72 +438,6 @@ func (s *DockerSuite) TestBuildEnvOverwrite(c *check.C) {
}
func (s *DockerSuite) TestBuildOnBuildForbiddenMaintainerInSourceImage(c *check.C) {
name := "testbuildonbuildforbiddenmaintainerinsourceimage"
out, _ := dockerCmd(c, "create", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out)
dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"MAINTAINER docker.io\"]}", cleanedContainerID, "onbuild")
_, err := buildImage(name,
`FROM onbuild`,
true)
if err != nil {
if !strings.Contains(err.Error(), "maintainer isn't allowed as an ONBUILD trigger") {
c.Fatalf("Wrong error %v, must be about MAINTAINER and ONBUILD in source image", err)
}
} else {
c.Fatal("Error must not be nil")
}
}
func (s *DockerSuite) TestBuildOnBuildForbiddenFromInSourceImage(c *check.C) {
name := "testbuildonbuildforbiddenfrominsourceimage"
out, _ := dockerCmd(c, "create", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out)
dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"FROM busybox\"]}", cleanedContainerID, "onbuild")
_, err := buildImage(name,
`FROM onbuild`,
true)
if err != nil {
if !strings.Contains(err.Error(), "from isn't allowed as an ONBUILD trigger") {
c.Fatalf("Wrong error %v, must be about FROM and ONBUILD in source image", err)
}
} else {
c.Fatal("Error must not be nil")
}
}
func (s *DockerSuite) TestBuildOnBuildForbiddenChainedInSourceImage(c *check.C) {
name := "testbuildonbuildforbiddenchainedinsourceimage"
out, _ := dockerCmd(c, "create", "busybox", "true")
cleanedContainerID := strings.TrimSpace(out)
dockerCmd(c, "commit", "--run", "{\"OnBuild\":[\"ONBUILD RUN ls\"]}", cleanedContainerID, "onbuild")
_, err := buildImage(name,
`FROM onbuild`,
true)
if err != nil {
if !strings.Contains(err.Error(), "Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed") {
c.Fatalf("Wrong error %v, must be about chaining ONBUILD in source image", err)
}
} else {
c.Fatal("Error must not be nil")
}
}
func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) {
name1 := "onbuildcmd"
name2 := "onbuildgenerated"

View file

@ -144,46 +144,3 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
}
}
}
// TODO: commit --run is deprecated, remove this once --run is removed
func (s *DockerSuite) TestCommitMergeConfigRun(c *check.C) {
testRequires(c, DaemonIsLinux)
name := "commit-test"
out, _ := dockerCmd(c, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo")
id := strings.TrimSpace(out)
dockerCmd(c, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test")
out, _ = dockerCmd(c, "run", "--name", name, "commit-test")
//run config in committed container was not merged
c.Assert(strings.TrimSpace(out), checker.Equals, "testing")
type cfg struct {
Env []string
Cmd []string
}
config1 := cfg{}
inspectFieldAndMarshall(c, id, "Config", &config1)
config2 := cfg{}
inspectFieldAndMarshall(c, name, "Config", &config2)
// Env has at least PATH loaded as well here, so let's just grab the FOO one
var env1, env2 string
for _, e := range config1.Env {
if strings.HasPrefix(e, "FOO") {
env1 = e
break
}
}
for _, e := range config2.Env {
if strings.HasPrefix(e, "FOO") {
env2 = e
break
}
}
if len(config1.Env) != len(config2.Env) || env1 != env2 && env2 != "" {
c.Fatalf("expected envs to match: %v - %v", config1.Env, config2.Env)
}
}