Browse code

daemon: update: check len inside public function

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/03/16 01:12:20
Showing 3 changed files
... ...
@@ -527,11 +527,9 @@ func (b *Builder) create() (string, error) {
527 527
 	b.tmpContainers[c.ID] = struct{}{}
528 528
 	fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
529 529
 
530
-	if len(config.Cmd) > 0 {
531
-		// override the entry point that may have been picked up from the base image
532
-		if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, config.Cmd); err != nil {
533
-			return "", err
534
-		}
530
+	// override the entry point that may have been picked up from the base image
531
+	if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, config.Cmd); err != nil {
532
+		return "", err
535 533
 	}
536 534
 
537 535
 	return c.ID, nil
... ...
@@ -25,6 +25,9 @@ func (daemon *Daemon) ContainerUpdate(name string, hostConfig *container.HostCon
25 25
 
26 26
 // ContainerUpdateCmdOnBuild updates Path and Args for the container with ID cID.
27 27
 func (daemon *Daemon) ContainerUpdateCmdOnBuild(cID string, cmd []string) error {
28
+	if len(cmd) == 0 {
29
+		return nil
30
+	}
28 31
 	c, err := daemon.GetContainer(cID)
29 32
 	if err != nil {
30 33
 		return err
... ...
@@ -171,7 +171,7 @@ func TestGetRemoteImageJSON(t *testing.T) {
171 171
 		t.Fatal(err)
172 172
 	}
173 173
 	assertEqual(t, size, int64(154), "Expected size 154")
174
-	if len(json) <= 0 {
174
+	if len(json) == 0 {
175 175
 		t.Fatal("Expected non-empty json")
176 176
 	}
177 177