Add a GetPtyMaster() method to container to retrieve the pty from an other package.

We could also have put ptyMaster public, but then we need to ignore it in json
otherwise the Marshalling fails. I think it is cleaner that way.
This commit is contained in:
Guillaume J. Charmes
2013-11-29 07:40:44 -08:00
parent e535f544c7
commit fbebe20bc6
+15
View File
@@ -24,6 +24,11 @@ import (
"time"
)
var (
ErrNotATTY = errors.New("The PTY is not a file")
ErrNoTTY = errors.New("No PTY found")
)
type Container struct {
sync.Mutex
root string // Path to the "home" of the container, including metadata.
@@ -1405,3 +1410,13 @@ func (container *Container) Exposes(p Port) bool {
_, exists := container.Config.ExposedPorts[p]
return exists
}
func (container *Container) GetPtyMaster() (*os.File, error) {
if container.ptyMaster == nil {
return nil, ErrNoTTY
}
if pty, ok := container.ptyMaster.(*os.File); ok {
return pty, nil
}
return nil, ErrNotATTY
}