浏览代码

Merge pull request #4308 from vbatts/vbatts-seperate_driver_term

seperate out the terminal functions from lxc
unclejack 11 年之前
父节点
当前提交
d8b60cb592
共有 2 个文件被更改,包括 8 次插入9 次删除
  1. 1 1
      execdriver/lxc/driver.go
  2. 7 8
      execdriver/termconsole.go

+ 1 - 1
execdriver/lxc/driver.go

@@ -77,7 +77,7 @@ func (d *driver) Name() string {
 }
 
 func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
-	if err := SetTerminal(c, pipes); err != nil {
+	if err := execdriver.SetTerminal(c, pipes); err != nil {
 		return -1, err
 	}
 	configPath, err := d.generateLXCConfig(c)

+ 7 - 8
execdriver/lxc/term.go → execdriver/termconsole.go

@@ -1,16 +1,15 @@
-package lxc
+package execdriver
 
 import (
-	"github.com/dotcloud/docker/execdriver"
 	"github.com/dotcloud/docker/pkg/term"
 	"github.com/kr/pty"
 	"io"
 	"os"
 )
 
-func SetTerminal(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func SetTerminal(command *Command, pipes *Pipes) error {
 	var (
-		term execdriver.Terminal
+		term Terminal
 		err  error
 	)
 	if command.Tty {
@@ -30,7 +29,7 @@ type TtyConsole struct {
 	slave  *os.File
 }
 
-func NewTtyConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*TtyConsole, error) {
+func NewTtyConsole(command *Command, pipes *Pipes) (*TtyConsole, error) {
 	ptyMaster, ptySlave, err := pty.Open()
 	if err != nil {
 		return nil, err
@@ -54,7 +53,7 @@ func (t *TtyConsole) Resize(h, w int) error {
 	return term.SetWinsize(t.master.Fd(), &term.Winsize{Height: uint16(h), Width: uint16(w)})
 }
 
-func (t *TtyConsole) attach(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func (t *TtyConsole) attach(command *Command, pipes *Pipes) error {
 	command.Stdout = t.slave
 	command.Stderr = t.slave
 	command.Console = t.slave.Name()
@@ -88,7 +87,7 @@ func (t *TtyConsole) Close() error {
 type StdConsole struct {
 }
 
-func NewStdConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*StdConsole, error) {
+func NewStdConsole(command *Command, pipes *Pipes) (*StdConsole, error) {
 	std := &StdConsole{}
 
 	if err := std.attach(command, pipes); err != nil {
@@ -97,7 +96,7 @@ func NewStdConsole(command *execdriver.Command, pipes *execdriver.Pipes) (*StdCo
 	return std, nil
 }
 
-func (s *StdConsole) attach(command *execdriver.Command, pipes *execdriver.Pipes) error {
+func (s *StdConsole) attach(command *Command, pipes *Pipes) error {
 	command.Stdout = pipes.Stdout
 	command.Stderr = pipes.Stderr