Upstream-commit: 333abbf85a8db9578e34c340032e32de3c8fefe8
Component: engine
This commit is contained in:
Andrea Luzzardi
2013-01-28 14:30:05 -08:00
parent 4deb0e4193
commit a499fea2e5
4 changed files with 20 additions and 22 deletions
+9 -12
View File
@@ -1,6 +1,7 @@
package docker
import (
"bytes"
"encoding/json"
"errors"
"io"
@@ -9,10 +10,9 @@ import (
"os"
"os/exec"
"path"
"strings"
"syscall"
"time"
"strings"
"bytes"
)
type Container struct {
@@ -33,8 +33,8 @@ type Container struct {
stdout *writeBroadcaster
stderr *writeBroadcaster
stdoutLog *bytes.Buffer
stderrLog *bytes.Buffer
stdoutLog *bytes.Buffer
stderrLog *bytes.Buffer
}
type Config struct {
@@ -56,8 +56,8 @@ func createContainer(id string, root string, command string, args []string, laye
lxcConfigPath: path.Join(root, "config.lxc"),
stdout: newWriteBroadcaster(),
stderr: newWriteBroadcaster(),
stdoutLog: new(bytes.Buffer),
stderrLog: new(bytes.Buffer),
stdoutLog: new(bytes.Buffer),
stderrLog: new(bytes.Buffer),
}
container.stdout.AddWriter(NopWriteCloser(container.stdoutLog))
container.stderr.AddWriter(NopWriteCloser(container.stderrLog))
@@ -83,8 +83,8 @@ func loadContainer(containerPath string) (*Container, error) {
return nil, err
}
container := &Container{
stdout: newWriteBroadcaster(),
stderr: newWriteBroadcaster(),
stdout: newWriteBroadcaster(),
stderr: newWriteBroadcaster(),
stdoutLog: new(bytes.Buffer),
stderrLog: new(bytes.Buffer),
}
@@ -98,7 +98,6 @@ func loadContainer(containerPath string) (*Container, error) {
return container, nil
}
func (container *Container) Cmd() *exec.Cmd {
return container.cmd
}
@@ -135,7 +134,7 @@ func (container *Container) SetUserData(key, value string) error {
return container.saveUserData(data)
}
func (container *Container) GetUserData(key string) (string) {
func (container *Container) GetUserData(key string) string {
data, err := container.loadUserData()
if err != nil {
return ""
@@ -146,7 +145,6 @@ func (container *Container) GetUserData(key string) (string) {
return ""
}
func (container *Container) save() (err error) {
data, err := json.Marshal(container)
if err != nil {
@@ -226,7 +224,6 @@ func (container *Container) StdoutLog() io.Reader {
return strings.NewReader(container.stdoutLog.String())
}
func (container *Container) StderrPipe() (io.ReadCloser, error) {
reader, writer := io.Pipe()
container.stderr.AddWriter(writer)
+8 -6
View File
@@ -3,13 +3,13 @@ package docker
import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"syscall"
"time"
"io"
"io/ioutil"
)
type Filesystem struct {
@@ -104,7 +104,6 @@ func (fs *Filesystem) Tar() (io.Reader, error) {
return Tar(fs.RootFS)
}
func (fs *Filesystem) EnsureMounted() error {
if !fs.IsMounted() {
if err := fs.Mount(); err != nil {
@@ -130,9 +129,12 @@ type Change struct {
func (change *Change) String() string {
var kind string
switch change.Kind {
case ChangeModify: kind = "C"
case ChangeAdd: kind = "A"
case ChangeDelete: kind = "D"
case ChangeModify:
kind = "C"
case ChangeAdd:
kind = "A"
case ChangeDelete:
kind = "D"
}
return fmt.Sprintf("%s %s", kind, change.Path)
}
+2 -3
View File
@@ -1,10 +1,10 @@
package docker
import (
"sync"
"time"
"fmt"
"github.com/dotcloud/docker/future"
"sync"
"time"
)
type State struct {
@@ -17,7 +17,6 @@ type State struct {
stateChangeCond *sync.Cond
}
func newState() *State {
lock := new(sync.Mutex)
return &State{
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"bytes"
"container/list"
"io"
"sync"
"os/exec"
"sync"
)
// Tar generates a tar archive from a filesystem path, and returns it as a stream.