MCPcopy Index your code
hub / github.com/loft-sh/devpod / jumpLocalProxyContainer

Method jumpLocalProxyContainer

cmd/ssh.go:685–774  ·  view source on GitHub ↗

jumpLocalProxyContainer is a shortcut we can take if we have a local provider and we're in proxy mode. This completely skips the agent. WARN: This is considered experimental for the time being!

(ctx context.Context, devPodConfig *config.Config, workspaceInfo *provider.AgentWorkspaceInfo, log log.Logger, exec func(ctx context.Context, command string, sshClient *ssh.Client) error)

Source from the content-addressed store, hash-verified

683//
684// WARN: This is considered experimental for the time being!
685func (cmd *SSHCmd) jumpLocalProxyContainer(ctx context.Context, devPodConfig *config.Config, workspaceInfo *provider.AgentWorkspaceInfo, log log.Logger, exec func(ctx context.Context, command string, sshClient *ssh.Client) error) error {
686 _, err := workspace.InitContentFolder(workspaceInfo, log)
687 if err != nil {
688 return err
689 }
690
691 runner, err := workspace.CreateRunner(workspaceInfo, nil, log)
692 if err != nil {
693 return err
694 }
695
696 containerDetails, err := runner.Find(ctx)
697 if err != nil {
698 return err
699 }
700
701 if containerDetails == nil || containerDetails.State.Status != "running" {
702 log.Info("Workspace isn't running, starting up...")
703 _, err := runner.Up(ctx, devcontainer.UpOptions{NoBuild: true}, workspaceInfo.InjectTimeout)
704 if err != nil {
705 return err
706 }
707 log.Info("Successfully started workspace")
708 }
709
710 // create readers
711 stdoutReader, stdoutWriter, err := os.Pipe()
712 if err != nil {
713 return err
714 }
715 stdinReader, stdinWriter, err := os.Pipe()
716 if err != nil {
717 return err
718 }
719 defer stdoutWriter.Close()
720 defer stdinWriter.Close()
721
722 cancelCtx, cancel := context.WithCancel(ctx)
723 defer cancel()
724
725 errChan := make(chan error, 1)
726 go func() {
727 writer := log.Writer(logrus.InfoLevel, false)
728 command := fmt.Sprintf("'%s' helper ssh-server --stdio", agent.ContainerDevPodHelperLocation)
729 if log.GetLevel() == logrus.DebugLevel {
730 command += " --debug"
731 }
732
733 err := runner.Command(cancelCtx, "root", command, stdinReader, stdoutWriter, writer)
734 if err != nil {
735 errChan <- err
736 }
737 }()
738
739 containerClient, err := devssh.StdioClient(stdoutReader, stdinWriter, false)
740 if err != nil {
741 return err
742 }

Callers 1

jumpContainerMethod · 0.95

Calls 13

forwardPortsMethod · 0.95
reverseForwardPortsMethod · 0.95
setupPlatformAccessMethod · 0.95
startRunnerServicesMethod · 0.95
startSSHKeepAliveFunction · 0.85
FindMethod · 0.65
UpMethod · 0.65
CommandMethod · 0.65
InfoMethod · 0.45
CloseMethod · 0.45
WriterMethod · 0.45
GetLevelMethod · 0.45

Tested by

no test coverage detected