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

Merge branch 'master' into simpler-build-upload

Conflicts:
	commands.go
This commit is contained in:
Solomon Hykes 2013-06-20 20:25:59 -07:00
commit 86e83186b5
6 changed files with 20 additions and 90 deletions

View file

@ -1,5 +1,8 @@
# Changelog # Changelog
## 0.4.4 (2013-06-19)
- Builder: fix a regression introduced in 0.4.3 which caused builds to fail on new clients.
## 0.4.3 (2013-06-19) ## 0.4.3 (2013-06-19)
+ Builder: ADD of a local file will detect tar archives and unpack them + Builder: ADD of a local file will detect tar archives and unpack them
* Runtime: Remove bsdtar dependency * Runtime: Remove bsdtar dependency

2
api.go
View file

@ -804,6 +804,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
localFct := fct localFct := fct
f := func(w http.ResponseWriter, r *http.Request) { f := func(w http.ResponseWriter, r *http.Request) {
utils.Debugf("Calling %s %s", localMethod, localRoute) utils.Debugf("Calling %s %s", localMethod, localRoute)
if logging { if logging {
log.Println(r.Method, r.RequestURI) log.Println(r.Method, r.RequestURI)
} }
@ -824,6 +825,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return return
} }
if err := localFct(srv, version, w, r, mux.Vars(r)); err != nil { if err := localFct(srv, version, w, r, mux.Vars(r)); err != nil {
httpError(w, err) httpError(w, err)
} }

View file

@ -28,7 +28,7 @@ import (
"unicode" "unicode"
) )
const VERSION = "0.4.3" const VERSION = "0.4.4"
var ( var (
GITCOMMIT string GITCOMMIT string
@ -192,7 +192,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
// Upload the build context // Upload the build context
v := &url.Values{} v := &url.Values{}
v.Set("t", *tag) v.Set("t", *tag)
req, err := http.NewRequest("POST", fmt.Sprintf("http://%s:%d%s?%s", cli.host, cli.port, "/build", v.Encode()), body) req, err := http.NewRequest("POST", fmt.Sprintf("/v%g/build?%s", APIVERSION, v.Encode()), body)
if err != nil { if err != nil {
return err return err
} }
@ -1021,10 +1021,10 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
return nil return nil
} }
if err := cli.stream("POST", "/containers/"+cmd.Arg(0)+"/attach?logs=1&stdout=1", nil, os.Stdout); err != nil { if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?logs=1&stdout=1", false, nil, os.Stdout); err != nil {
return err return err
} }
if err := cli.stream("POST", "/containers/"+cmd.Arg(0)+"/attach?logs=1&stderr=1", nil, os.Stderr); err != nil { if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?logs=1&stderr=1", false, nil, os.Stderr); err != nil {
return err return err
} }
return nil return nil
@ -1355,6 +1355,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 400 { if resp.StatusCode < 200 || resp.StatusCode >= 400 {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
@ -1392,19 +1393,24 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e
} }
func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in *os.File, out io.Writer) error { func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in *os.File, out io.Writer) error {
req, err := http.NewRequest(method, fmt.Sprintf("/v%g%s", APIVERSION, path), nil) req, err := http.NewRequest(method, fmt.Sprintf("/v%g%s", APIVERSION, path), nil)
if err != nil { if err != nil {
return err return err
} }
req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
req.Header.Set("Content-Type", "plain/text") req.Header.Set("Content-Type", "plain/text")
dial, err := net.Dial(cli.proto, cli.addr) dial, err := net.Dial(cli.proto, cli.addr)
if err != nil { if err != nil {
return err return err
} }
clientconn := httputil.NewClientConn(dial, nil) clientconn := httputil.NewClientConn(dial, nil)
clientconn.Do(req)
defer clientconn.Close() defer clientconn.Close()
// Server hijacks the connection, error 'connection closed' expected
clientconn.Do(req)
rwc, br := clientconn.Hijack() rwc, br := clientconn.Hijack()
defer rwc.Close() defer rwc.Close()

View file

@ -1,10 +0,0 @@
package docker
import (
"fmt"
"github.com/dotcloud/docker/utils"
)
func getKernelVersion() (*utils.KernelVersionInfo, error) {
return nil, fmt.Errorf("Kernel version detection is not available on darwin")
}

View file

@ -1,71 +0,0 @@
package docker
import (
"bytes"
"github.com/dotcloud/docker/utils"
"strconv"
"strings"
"syscall"
)
// FIXME: Move this to utils package
func getKernelVersion() (*utils.KernelVersionInfo, error) {
var (
uts syscall.Utsname
flavor string
kernel, major, minor int
err error
)
if err := syscall.Uname(&uts); err != nil {
return nil, err
}
release := make([]byte, len(uts.Release))
i := 0
for _, c := range uts.Release {
release[i] = byte(c)
i++
}
// Remove the \x00 from the release for Atoi to parse correctly
release = release[:bytes.IndexByte(release, 0)]
tmp := strings.SplitN(string(release), "-", 2)
tmp2 := strings.SplitN(tmp[0], ".", 3)
if len(tmp2) > 0 {
kernel, err = strconv.Atoi(tmp2[0])
if err != nil {
return nil, err
}
}
if len(tmp2) > 1 {
major, err = strconv.Atoi(tmp2[1])
if err != nil {
return nil, err
}
}
if len(tmp2) > 2 {
minor, err = strconv.Atoi(tmp2[2])
if err != nil {
return nil, err
}
}
if len(tmp) == 2 {
flavor = tmp[1]
} else {
flavor = ""
}
return &utils.KernelVersionInfo{
Kernel: kernel,
Major: major,
Minor: minor,
Flavor: flavor,
}, nil
}

View file

@ -979,17 +979,17 @@ func (srv *Server) ContainerAttach(name string, logs, stream, stdin, stdout, std
if stdout { if stdout {
cLog, err := container.ReadLog("stdout") cLog, err := container.ReadLog("stdout")
if err != nil { if err != nil {
utils.Debugf(err.Error()) utils.Debugf("Error reading logs (stdout): %s", err)
} else if _, err := io.Copy(out, cLog); err != nil { } else if _, err := io.Copy(out, cLog); err != nil {
utils.Debugf(err.Error()) utils.Debugf("Error streaming logs (stdout): %s", err)
} }
} }
if stderr { if stderr {
cLog, err := container.ReadLog("stderr") cLog, err := container.ReadLog("stderr")
if err != nil { if err != nil {
utils.Debugf(err.Error()) utils.Debugf("Error reading logs (stderr): %s", err)
} else if _, err := io.Copy(out, cLog); err != nil { } else if _, err := io.Copy(out, cLog); err != nil {
utils.Debugf(err.Error()) utils.Debugf("Error streaming logs (stderr): %s", err)
} }
} }
} }