Browse code

Remove the open from CmdBuild

Guillaume J. Charmes authored on 2013/05/01 10:03:15
Showing 1 changed files
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"log"
11 11
 	"net/http"
12 12
 	"net/url"
13
-	"os"
14 13
 	"runtime"
15 14
 	"strconv"
16 15
 	"strings"
... ...
@@ -34,7 +33,7 @@ func (srv *Server) Help() string {
34 34
 	help := "Usage: docker COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n"
35 35
 	for _, cmd := range [][]string{
36 36
 		{"attach", "Attach to a running container"},
37
-		{"build", "Build a container from Dockerfile"},
37
+		{"build", "Build a container from Dockerfile via stdin"},
38 38
 		{"commit", "Create a new image from a container's changes"},
39 39
 		{"diff", "Inspect changes on a container's filesystem"},
40 40
 		{"export", "Stream the contents of a container as a tar archive"},
... ...
@@ -115,28 +114,11 @@ func (srv *Server) CmdInsert(stdin io.ReadCloser, stdout rcli.DockerConn, args .
115 115
 
116 116
 func (srv *Server) CmdBuild(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error {
117 117
 	stdout.Flush()
118
-	cmd := rcli.Subcmd(stdout, "build", "[Dockerfile|-]", "Build a container from Dockerfile")
118
+	cmd := rcli.Subcmd(stdout, "build", "-", "Build a container from Dockerfile via stdin")
119 119
 	if err := cmd.Parse(args); err != nil {
120 120
 		return nil
121 121
 	}
122
-	dockerfile := cmd.Arg(0)
123
-	if dockerfile == "" {
124
-		dockerfile = "Dockerfile"
125
-	}
126
-
127
-	var file io.Reader
128
-
129
-	if dockerfile != "-" {
130
-		f, err := os.Open(dockerfile)
131
-		if err != nil {
132
-			return err
133
-		}
134
-		defer f.Close()
135
-		file = f
136
-	} else {
137
-		file = stdin
138
-	}
139
-	img, err := NewBuilder(srv.runtime).Build(file, stdout)
122
+	img, err := NewBuilder(srv.runtime).Build(stdin, stdout)
140 123
 	if err != nil {
141 124
 		return err
142 125
 	}