@@ -48,8 +48,7 @@ func newExecCommand() *cobra.Command {
4848 RunE : func (cmd * cobra.Command , args []string ) error {
4949 options .container = args [0 ]
5050 options .command = args [1 :]
51- _ = runExec (options )
52- return nil
51+ return runExec (options )
5352 },
5453 }
5554
@@ -98,23 +97,17 @@ func buildCli(ctx context.Context, options execOptions) (*DebugCli, error) {
9897 opts = append (opts , WithClientConfig (dockerConfig ))
9998 } else {
10099 name := conf .DockerConfigDefault
101- opt , ok := conf .DockerConfig [conf .DockerConfigDefault ]
102100 if options .name != "" {
103101 name = options .name
104- opt , ok = conf .DockerConfig [options .name ]
105102 }
103+ opt , ok := conf .DockerConfig [name ]
106104 if ! ok {
107105 return nil , errors .Errorf ("not find %s docker config" , name )
108106 }
109107 opts = append (opts , WithClientConfig (opt ))
110108 }
111109
112- cli , err := NewDebugCli (opts ... )
113- if err != nil {
114- return nil , err
115- }
116- cli .ctx = ctx
117- return cli , err
110+ return NewDebugCli (ctx , opts ... )
118111}
119112
120113func runExec (options execOptions ) error {
@@ -184,9 +177,9 @@ func runExec(options execOptions) error {
184177 }
185178
186179 errCh := make (chan error , 1 )
180+ defer close (errCh )
187181
188182 go func () {
189- defer close (errCh )
190183 errCh <- func () error {
191184 return cli .ExecStart (options , resp .ID )
192185 }()
@@ -197,8 +190,7 @@ func runExec(options execOptions) error {
197190 }
198191 }
199192
200- err = <- errCh
201- if err != nil {
193+ if err = <- errCh ; err != nil {
202194 logrus .Debugf ("Error hijack: %s" , err )
203195 return err
204196 }
0 commit comments