Skip to content

Commit

Permalink
Rename Destroy to Rm to be consistent with CLI.
Browse files Browse the repository at this point in the history
Signed-off-by: Rik Nijessen <[email protected]>
  • Loading branch information
Rik Nijessen committed Feb 23, 2015
1 parent 7d2188f commit ba93f83
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion builder/internals.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func (b *Builder) clearTmp() {
fmt.Fprint(b.OutStream, err.Error())
}

if err := b.Daemon.Destroy(tmp); err != nil {
if err := b.Daemon.Rm(tmp); err != nil {
fmt.Fprintf(b.OutStream, "Error removing intermediate container %s: %s\n", utils.TruncateID(c), err.Error())
return
}
Expand Down
5 changes: 2 additions & 3 deletions daemon/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status {
return job.Errorf("Conflict, You cannot remove a running container. Stop the container before attempting removal or use -f")
}
}
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
return job.Errorf("Cannot destroy container %s: %s", name, err)
}
container.LogEvent("destroy")
Expand All @@ -82,8 +82,7 @@ func (daemon *Daemon) DeleteVolumes(volumeIDs map[string]struct{}) {
}

// Destroy unregisters a container from the daemon and cleanly removes its contents from the filesystem.
// FIXME: rename to Rm for consistency with the CLI command
func (daemon *Daemon) Destroy(container *Container) error {
func (daemon *Daemon) Rm(container *Container) error {
if container == nil {
return fmt.Errorf("The given container is <nil>")
}
Expand Down
14 changes: 7 additions & 7 deletions integration/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestRestartStdin(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer daemon.Destroy(container)
defer daemon.Rm(container)

stdin := container.StdinPipe()
stdout := container.StdoutPipe()
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestStdin(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer daemon.Destroy(container)
defer daemon.Rm(container)

stdin := container.StdinPipe()
stdout := container.StdoutPipe()
Expand Down Expand Up @@ -129,7 +129,7 @@ func TestTty(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer daemon.Destroy(container)
defer daemon.Rm(container)

stdin := container.StdinPipe()
stdout := container.StdoutPipe()
Expand Down Expand Up @@ -168,15 +168,15 @@ func BenchmarkRunSequential(b *testing.B) {
if err != nil {
b.Fatal(err)
}
defer daemon.Destroy(container)
defer daemon.Rm(container)
output, err := container.Output()
if err != nil {
b.Fatal(err)
}
if string(output) != "foo" {
b.Fatalf("Unexpected output: %s", output)
}
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
b.Fatal(err)
}
}
Expand All @@ -203,7 +203,7 @@ func BenchmarkRunParallel(b *testing.B) {
complete <- err
return
}
defer daemon.Destroy(container)
defer daemon.Rm(container)
if err := container.Start(); err != nil {
complete <- err
return
Expand All @@ -215,7 +215,7 @@ func BenchmarkRunParallel(b *testing.B) {
// if string(output) != "foo" {
// complete <- fmt.Errorf("Unexecpted output: %v", string(output))
// }
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
complete <- err
return
}
Expand Down
20 changes: 10 additions & 10 deletions integration/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func cleanup(eng *engine.Engine, t *testing.T) error {
daemon := mkDaemonFromEngine(eng, t)
for _, container := range daemon.List() {
container.Kill()
daemon.Destroy(container)
daemon.Rm(container)
}
job := eng.Job("images")
images, err := job.Stdout.AddTable()
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestDaemonCreate(t *testing.T) {
}

defer func() {
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
t.Error(err)
}
}()
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestDestroy(t *testing.T) {
t.Fatal(err)
}
// Destroy
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
t.Error(err)
}

Expand All @@ -388,7 +388,7 @@ func TestDestroy(t *testing.T) {
}

// Test double destroy
if err := daemon.Destroy(container); err == nil {
if err := daemon.Rm(container); err == nil {
// It should have failed
t.Errorf("Double destroy did not fail")
}
Expand All @@ -399,13 +399,13 @@ func TestGet(t *testing.T) {
defer nuke(daemon)

container1, _, _ := mkContainer(daemon, []string{"_", "ls", "-al"}, t)
defer daemon.Destroy(container1)
defer daemon.Rm(container1)

container2, _, _ := mkContainer(daemon, []string{"_", "ls", "-al"}, t)
defer daemon.Destroy(container2)
defer daemon.Rm(container2)

container3, _, _ := mkContainer(daemon, []string{"_", "ls", "-al"}, t)
defer daemon.Destroy(container3)
defer daemon.Rm(container3)

if c, _ := daemon.Get(container1.ID); c != container1 {
t.Errorf("Get(test1) returned %v while expecting %v", c, container1)
Expand Down Expand Up @@ -594,11 +594,11 @@ func TestRestore(t *testing.T) {
defer daemon1.Nuke()
// Create a container with one instance of docker
container1, _, _ := mkContainer(daemon1, []string{"_", "ls", "-al"}, t)
defer daemon1.Destroy(container1)
defer daemon1.Rm(container1)

// Create a second container meant to be killed
container2, _, _ := mkContainer(daemon1, []string{"-i", "_", "/bin/cat"}, t)
defer daemon1.Destroy(container2)
defer daemon1.Rm(container2)

// Start the container non blocking
if err := container2.Start(); err != nil {
Expand Down Expand Up @@ -886,7 +886,7 @@ func TestDestroyWithInitLayer(t *testing.T) {
t.Fatal(err)
}
// Destroy
if err := daemon.Destroy(container); err != nil {
if err := daemon.Rm(container); err != nil {
t.Fatal(err)
}

Expand Down
4 changes: 2 additions & 2 deletions integration/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestMergeConfigOnCommit(t *testing.T) {
defer runtime.Nuke()

container1, _, _ := mkContainer(runtime, []string{"-e", "FOO=bar", unitTestImageID, "echo test > /tmp/foo"}, t)
defer runtime.Destroy(container1)
defer runtime.Rm(container1)

config, _, _, err := parseRun([]string{container1.ID, "cat /tmp/foo"})
if err != nil {
Expand All @@ -64,7 +64,7 @@ func TestMergeConfigOnCommit(t *testing.T) {
}

container2, _, _ := mkContainer(runtime, []string{engine.Tail(outputBuffer, 1)}, t)
defer runtime.Destroy(container2)
defer runtime.Rm(container2)

job = eng.Job("container_inspect", container1.Name)
baseContainer, _ := job.Stdout.AddEnv()
Expand Down
2 changes: 1 addition & 1 deletion integration/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func runContainer(eng *engine.Engine, r *daemon.Daemon, args []string, t *testin
if err != nil {
return "", err
}
defer r.Destroy(container)
defer r.Rm(container)
stdout := container.StdoutPipe()
defer stdout.Close()

Expand Down

0 comments on commit ba93f83

Please sign in to comment.