(logCtx context.Context, remoteName string, blockMeta waveobj.MetaMapType)
| 332 | } |
| 333 | |
| 334 | func (bc *ShellController) getConnUnion(logCtx context.Context, remoteName string, blockMeta waveobj.MetaMapType) (ConnUnion, error) { |
| 335 | rtn := ConnUnion{ConnName: remoteName} |
| 336 | wshEnabled := !blockMeta.GetBool(waveobj.MetaKey_CmdNoWsh, false) |
| 337 | if strings.HasPrefix(remoteName, "wsl://") { |
| 338 | wslName := strings.TrimPrefix(remoteName, "wsl://") |
| 339 | wslConn := wslconn.GetWslConn(wslName) |
| 340 | if wslConn == nil { |
| 341 | return ConnUnion{}, fmt.Errorf("wsl connection not found: %s", remoteName) |
| 342 | } |
| 343 | connStatus := wslConn.DeriveConnStatus() |
| 344 | if connStatus.Status != conncontroller.Status_Connected { |
| 345 | return ConnUnion{}, fmt.Errorf("wsl connection %s not connected, cannot start shellproc", remoteName) |
| 346 | } |
| 347 | rtn.ConnType = ConnType_Wsl |
| 348 | rtn.WslConn = wslConn |
| 349 | rtn.WshEnabled = wshEnabled && wslConn.WshEnabled.Load() |
| 350 | } else if conncontroller.IsLocalConnName(remoteName) { |
| 351 | rtn.ConnType = ConnType_Local |
| 352 | rtn.WshEnabled = wshEnabled |
| 353 | } else { |
| 354 | opts, err := remote.ParseOpts(remoteName) |
| 355 | if err != nil { |
| 356 | return ConnUnion{}, fmt.Errorf("invalid ssh remote name (%s): %w", remoteName, err) |
| 357 | } |
| 358 | conn := conncontroller.MaybeGetConn(opts) |
| 359 | if conn == nil { |
| 360 | return ConnUnion{}, fmt.Errorf("ssh connection not found: %s", remoteName) |
| 361 | } |
| 362 | connStatus := conn.DeriveConnStatus() |
| 363 | if connStatus.Status != conncontroller.Status_Connected { |
| 364 | return ConnUnion{}, fmt.Errorf("ssh connection %s not connected, cannot start shellproc", remoteName) |
| 365 | } |
| 366 | rtn.ConnType = ConnType_Ssh |
| 367 | rtn.SshConn = conn |
| 368 | rtn.WshEnabled = wshEnabled && conn.WshEnabled.Load() |
| 369 | } |
| 370 | err := rtn.getRemoteInfoAndShellType(blockMeta) |
| 371 | if err != nil { |
| 372 | return ConnUnion{}, err |
| 373 | } |
| 374 | return rtn, nil |
| 375 | } |
| 376 | |
| 377 | func (bc *ShellController) setupAndStartShellProcess(logCtx context.Context, rc *RunShellOpts, blockMeta waveobj.MetaMapType) (*shellexec.ShellProc, error) { |
| 378 | // create a circular blockfile for the output |
no test coverage detected