feat: multiple connect works well

This commit is contained in:
fengcaiwen
2023-10-25 20:56:36 +08:00
committed by naison
parent 1f4ea3ba87
commit d3640ec2d1
12 changed files with 176 additions and 86 deletions

View File

@@ -78,6 +78,9 @@ type Options struct {
// inner
Cli *client.Client
DockerCli *command.DockerCli
// rollback
RollbackFuncList []func()
}
func (d *Options) Main(ctx context.Context, tempContainerConfig *containerConfig) error {
@@ -124,7 +127,7 @@ func (d *Options) Main(ctx context.Context, tempContainerConfig *containerConfig
log.Errorf("get env from k8s: %v", err)
return err
}
volume, err := GetVolume(ctx, d.Factory, d.Namespace, pod)
volume, err := GetVolume(ctx, d.Factory, d.Namespace, pod, d)
if err != nil {
log.Errorf("get volume from k8s: %v", err)
return err
@@ -213,7 +216,7 @@ func (d *Options) Main(ctx context.Context, tempContainerConfig *containerConfig
}
}
handler.RollbackFuncList = append(handler.RollbackFuncList, func() {
d.RollbackFuncList = append(d.RollbackFuncList, func() {
_ = runConfigList.Remove(ctx, d.Cli)
})
err = runConfigList.Run(ctx, volume, d.Cli, d.DockerCli)
@@ -570,7 +573,7 @@ func (d *Options) doConnect(ctx context.Context, f cmdutil.Factory, conf *util.S
},
)
go h.Run(func() error { select {} })
handler.RollbackFuncList = append(handler.RollbackFuncList, func() {
d.RollbackFuncList = append(d.RollbackFuncList, func() {
h.Close()
})
err = runLogsWaitRunning(cancelCtx, d.DockerCli, id)