@@ -47,21 +47,23 @@ func NewKoolExec() *KoolExec {
4747
4848// Execute runs the exec logic with incoming arguments.
4949func (e * KoolExec ) Execute (args []string ) (err error ) {
50+ if ! e .IsTerminal () {
51+ e .composeExec .AppendArgs ("-T" )
52+ }
53+
5054 if asuser := e .env .Get ("KOOL_ASUSER" ); asuser != "" {
5155 // we have a KOOL_ASUSER env; now we need to know whether
5256 // the image of the target service have such user
53- passwd , _ := e .Exec (e .composeExec , args [0 ], "cat" , "/etc/passwd" )
54- // kool:x:UID
55- if strings .Contains (passwd , fmt .Sprintf ("kool:x:%s" , asuser )) {
56- // since user existing within the container, we use it
57+ var passwd string
58+ if passwd , err = e .Exec (e .composeExec , args [0 ], "cat" , "/etc/passwd" ); err != nil {
59+ e .Warning ("failed to check running container for kool user; not setting a user (err: %s)" , err .Error ())
60+ err = nil
61+ } else if strings .Contains (passwd , fmt .Sprintf ("kool:x:%s" , asuser )) {
62+ // since user (kool:x:UID) exists within the container, we set it
5763 e .composeExec .AppendArgs ("--user" , asuser )
5864 }
5965 }
6066
61- if ! e .IsTerminal () {
62- e .composeExec .AppendArgs ("-T" )
63- }
64-
6567 if aware , ok := e .composeExec .(compose.TtyAware ); ok {
6668 // let DockerCompose know about whether we are under TTY or not
6769 aware .SetIsTTY (e .IsTerminal ())
0 commit comments