MCPcopy
hub / github.com/wavetermdev/waveterm / getConnUnion

Method getConnUnion

pkg/blockcontroller/shellcontroller.go:334–375  ·  view source on GitHub ↗
(logCtx context.Context, remoteName string, blockMeta waveobj.MetaMapType)

Source from the content-addressed store, hash-verified

332}
333
334func (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
377func (bc *ShellController) setupAndStartShellProcess(logCtx context.Context, rc *RunShellOpts, blockMeta waveobj.MetaMapType) (*shellexec.ShellProc, error) {
378 // create a circular blockfile for the output

Callers 1

Calls 7

GetWslConnFunction · 0.92
IsLocalConnNameFunction · 0.92
ParseOptsFunction · 0.92
MaybeGetConnFunction · 0.92
GetBoolMethod · 0.80
DeriveConnStatusMethod · 0.45

Tested by

no test coverage detected