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

Method ConnUpdateWshCommand

pkg/wshrpc/wshserver/wshserver.go:683–724  ·  view source on GitHub ↗
(ctx context.Context, remoteInfo wshrpc.RemoteInfo)

Source from the content-addressed store, hash-verified

681}
682
683func (ws *WshServer) ConnUpdateWshCommand(ctx context.Context, remoteInfo wshrpc.RemoteInfo) (bool, error) {
684 handler := wshutil.GetRpcResponseHandlerFromContext(ctx)
685 if handler == nil {
686 return false, fmt.Errorf("could not determine handler from context")
687 }
688 connName := handler.GetRpcContext().Conn
689 if connName == "" {
690 return false, fmt.Errorf("invalid remote info: missing connection name")
691 }
692
693 log.Printf("checking wsh version for connection %s (current: %s)", connName, remoteInfo.ClientVersion)
694 upToDate, _, _, err := conncontroller.IsWshVersionUpToDate(ctx, remoteInfo.ClientVersion)
695 if err != nil {
696 return false, fmt.Errorf("unable to compare wsh version: %w", err)
697 }
698 if upToDate {
699 // no need to update
700 log.Printf("wsh is already up to date for connection %s", connName)
701 return false, nil
702 }
703
704 // todo: need to add user input code here for validation
705
706 if strings.HasPrefix(connName, "wsl://") {
707 return false, fmt.Errorf("connupdatewshcommand is not supported for wsl connections")
708 }
709 connOpts, err := remote.ParseOpts(connName)
710 if err != nil {
711 return false, fmt.Errorf("error parsing connection name: %w", err)
712 }
713 conn := conncontroller.GetConn(connOpts)
714 if conn == nil {
715 return false, fmt.Errorf("connection not found: %s", connName)
716 }
717 err = conn.UpdateWsh(ctx, connName, &remoteInfo)
718 if err != nil {
719 return false, fmt.Errorf("wsh update failed for connection %s: %w", connName, err)
720 }
721
722 // todo: need to add code for modifying configs?
723 return true, nil
724}
725
726func (ws *WshServer) ConnListCommand(ctx context.Context) ([]string, error) {
727 return conncontroller.GetConnectionsList()

Callers

nothing calls this directly

Calls 6

IsWshVersionUpToDateFunction · 0.92
ParseOptsFunction · 0.92
GetConnFunction · 0.92
GetRpcContextMethod · 0.45
UpdateWshMethod · 0.45

Tested by

no test coverage detected