0
0
forked from toolshed/abra

feat: finish app run command

This commit is contained in:
2021-08-29 21:20:21 +02:00
parent 8cc691ab52
commit 440911f983
6 changed files with 44 additions and 114 deletions

View File

@ -7,7 +7,9 @@ import (
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/client"
"coopcloud.tech/abra/client/container"
"coopcloud.tech/abra/config"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/sirupsen/logrus"
@ -77,13 +79,14 @@ var appRunCommand = &cli.Command{
cmd := c.Args().Slice()[2:]
execCreateOpts := types.ExecConfig{
//AttachStderr: true,
AttachStdin: true,
//AttachStdout: true,
Cmd: cmd,
Detach: false,
Tty: true,
AttachStderr: true,
AttachStdin: true,
AttachStdout: true,
Cmd: cmd,
Detach: false,
Tty: true,
}
if user != "" {
execCreateOpts.User = user
}
@ -91,40 +94,19 @@ var appRunCommand = &cli.Command{
execCreateOpts.Tty = false
}
// container := containers[0]
// idResp, err := cl.ContainerExecCreate(ctx, container.ID, execCreateOpts)
// if err != nil {
// logrus.Fatal(err)
// }
// FIXME: an absolutely monumental hack to instantiate another command-line
// client withing our command-line client so that we pass something down
// the tubes that satisfies the necessary interface requirements. We should
// refactor our vendored container code to not require all this cruft. For
// now, It Works.
dcli, err := command.NewDockerCli()
if err != nil {
logrus.Fatal(err)
}
// execAttachOpts := types.ExecStartCheck{Detach: false, Tty: true}
// hResp, err := cl.ContainerExecAttach(ctx, idResp.ID, execAttachOpts)
// if err != nil {
// logrus.Fatal(err)
// }
// defer hResp.Close()
// var outBuf, errBuf bytes.Buffer
// outputDone := make(chan error)
// go func() {
// _, err = stdcopy.StdCopy(&outBuf, &errBuf, hResp.Reader)
// outputDone <- err
// }()
// select {
// case err := <-outputDone:
// if err != nil {
// logrus.Fatal(err)
// }
// break
// case <-ctx.Done():
// break
// }
// iresp, err := cl.ContainerExecInspect(ctx, idResp.ID)
// if err != nil {
// logrus.Fatal(err)
// }
if err := container.RunExec(dcli, cl, containers[0].ID, &execCreateOpts); err != nil {
logrus.Fatal(err)
}
return nil
},