Skip to content

Commit d7b27fc

Browse files
committed
fix some carps
1 parent ff989ec commit d7b27fc

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed
File renamed without changes.

internal/command/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ type DebugCli struct {
6363
}
6464

6565
// NewDebugCli new DebugCli
66-
func NewDebugCli(ops ...DebugCliOption) (*DebugCli, error) {
67-
cli := &DebugCli{}
66+
func NewDebugCli(ctx context.Context, ops ...DebugCliOption) (*DebugCli, error) {
67+
cli := &DebugCli{ctx: ctx}
6868
if err := cli.Apply(ops...); err != nil {
6969
return nil, err
7070
}

internal/command/root.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,17 @@ func buildCli(ctx context.Context, options execOptions) (*DebugCli, error) {
9898
opts = append(opts, WithClientConfig(dockerConfig))
9999
} else {
100100
name := conf.DockerConfigDefault
101-
opt, ok := conf.DockerConfig[conf.DockerConfigDefault]
102101
if options.name != "" {
103102
name = options.name
104-
opt, ok = conf.DockerConfig[options.name]
105103
}
104+
opt, ok := conf.DockerConfig[name]
106105
if !ok {
107106
return nil, errors.Errorf("not find %s docker config", name)
108107
}
109108
opts = append(opts, WithClientConfig(opt))
110109
}
111110

112-
cli, err := NewDebugCli(opts...)
113-
if err != nil {
114-
return nil, err
115-
}
116-
cli.ctx = ctx
117-
return cli, err
111+
return NewDebugCli(ctx, opts...)
118112
}
119113

120114
func runExec(options execOptions) error {
@@ -184,9 +178,9 @@ func runExec(options execOptions) error {
184178
}
185179

186180
errCh := make(chan error, 1)
181+
defer close(errCh)
187182

188183
go func() {
189-
defer close(errCh)
190184
errCh <- func() error {
191185
return cli.ExecStart(options, resp.ID)
192186
}()
@@ -197,8 +191,7 @@ func runExec(options execOptions) error {
197191
}
198192
}
199193

200-
err = <-errCh
201-
if err != nil {
194+
if err = <-errCh; err != nil {
202195
logrus.Debugf("Error hijack: %s", err)
203196
return err
204197
}

0 commit comments

Comments
 (0)