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)
| 683 | // |
| 684 | // WARN: This is considered experimental for the time being! |
| 685 | func (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 | } |
no test coverage detected