Skip to content

Commit

Permalink
Remove the open from CmdBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
creack committed May 1, 2013
1 parent 59b6a93 commit 3c9ed5c
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions commands.go
Expand Up @@ -10,7 +10,6 @@ import (
"log"
"net/http"
"net/url"
"os"
"runtime"
"strconv"
"strings"
Expand All @@ -34,7 +33,7 @@ func (srv *Server) Help() string {
help := "Usage: docker COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nCommands:\n"
for _, cmd := range [][]string{
{"attach", "Attach to a running container"},
{"build", "Build a container from Dockerfile"},
{"build", "Build a container from Dockerfile via stdin"},
{"commit", "Create a new image from a container's changes"},
{"diff", "Inspect changes on a container's filesystem"},
{"export", "Stream the contents of a container as a tar archive"},
Expand Down Expand Up @@ -115,28 +114,11 @@ func (srv *Server) CmdInsert(stdin io.ReadCloser, stdout rcli.DockerConn, args .

func (srv *Server) CmdBuild(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error {
stdout.Flush()
cmd := rcli.Subcmd(stdout, "build", "[Dockerfile|-]", "Build a container from Dockerfile")
cmd := rcli.Subcmd(stdout, "build", "-", "Build a container from Dockerfile via stdin")
if err := cmd.Parse(args); err != nil {
return nil
}
dockerfile := cmd.Arg(0)
if dockerfile == "" {
dockerfile = "Dockerfile"
}

var file io.Reader

if dockerfile != "-" {
f, err := os.Open(dockerfile)
if err != nil {
return err
}
defer f.Close()
file = f
} else {
file = stdin
}
img, err := NewBuilder(srv.runtime).Build(file, stdout)
img, err := NewBuilder(srv.runtime).Build(stdin, stdout)
if err != nil {
return err
}
Expand Down

0 comments on commit 3c9ed5c

Please sign in to comment.