mirror of https://github.com/docker/compose.git
Add default shellout to engine if no context specified
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
parent
a8403241e4
commit
f5aa9638af
36
cmd/main.go
36
cmd/main.go
|
@ -64,6 +64,24 @@ func main() {
|
|||
context.ContextFlag,
|
||||
}
|
||||
|
||||
/*cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {
|
||||
ctx, err := context.GetContext()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
fmt.Println(ctx.Metadata.Type)
|
||||
if ctx.Metadata.Type == "Moby" {
|
||||
err := shellOutToDefaultEngine()
|
||||
if err != nil {
|
||||
if exiterr, ok:= err.(*exec.ExitError); ok {
|
||||
os.Exit(exiterr.ExitCode())
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(w, templ, data)
|
||||
}
|
||||
}*/
|
||||
|
||||
app.Before = func(clix *cli.Context) error {
|
||||
if clix.GlobalBool("debug") {
|
||||
|
@ -74,7 +92,13 @@ func main() {
|
|||
logrus.Fatal(err)
|
||||
}
|
||||
if ctx.Metadata.Type == "Moby" {
|
||||
shellOutToDefaultEngine()
|
||||
err := shellOutToDefaultEngine()
|
||||
if err != nil {
|
||||
if exiterr, ok:= err.(*exec.ExitError); ok {
|
||||
os.Exit(exiterr.ExitCode())
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
// TODO select backend based on context.Metadata.Type
|
||||
|
@ -94,12 +118,14 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func shellOutToDefaultEngine() {
|
||||
cmd :=exec.Command("/Applications/Docker.app/Contents/Resources/bin/docker", os.Args[1:]...)
|
||||
func shellOutToDefaultEngine() error {
|
||||
cmd :=exec.Command(" /Applications/Docker.app/Contents/Resources/bin/docker", os.Args[1:]...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
logrus.Fatal(err)
|
||||
fmt.Println("Shellout")
|
||||
if err:= cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return cmd.Wait()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue