Skip to content

Commit

Permalink
Move SSHAuthSockID to CLi options
Browse files Browse the repository at this point in the history
  • Loading branch information
bkneis committed Dec 18, 2024
1 parent 9e40c61 commit 990cb47
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cmd/agent/container_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func startDevContainer(ctx context.Context, workspaceConfig *provider2.AgentWork

func StartContainer(ctx context.Context, runner devcontainer.Runner, log log.Logger, workspaceConfig *provider2.AgentWorkspaceInfo) (*config.Result, error) {
log.Debugf("Starting DevPod container...")
result, err := runner.Up(ctx, devcontainer.UpOptions{NoBuild: true, AuthSockID: workspaceConfig.AuthSockID}, workspaceConfig.InjectTimeout)
result, err := runner.Up(ctx, devcontainer.UpOptions{NoBuild: true}, workspaceConfig.InjectTimeout)
if err != nil {
return result, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/workspace/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (cmd *UpCmd) Run(ctx context.Context) error {
}

func (cmd *UpCmd) up(ctx context.Context, workspaceInfo *provider2.AgentWorkspaceInfo, tunnelClient tunnel.TunnelClient, logger log.Logger) error {

Check failure on line 101 in cmd/agent/workspace/up.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

// create devcontainer
result, err := cmd.devPodUp(ctx, workspaceInfo, logger)
if err != nil {
Expand Down Expand Up @@ -128,7 +129,6 @@ func (cmd *UpCmd) devPodUp(ctx context.Context, workspaceInfo *provider2.AgentWo
result, err := runner.Up(ctx, devcontainer.UpOptions{
CLIOptions: workspaceInfo.CLIOptions,
RegistryCache: workspaceInfo.RegistryCache,
AuthSockID: workspaceInfo.AuthSockID,
}, workspaceInfo.InjectTimeout)
if err != nil {
return nil, err
Expand Down
15 changes: 9 additions & 6 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ func (cmd *UpCmd) Run(
if cmd.IDE != "" {
targetIDE = cmd.IDE
}
if ide.ReusesAuthSock(targetIDE) {
cmd.AuthSockID = RandStringBytes(10)
if !cmd.Proxy && ide.ReusesAuthSock(targetIDE) {
cmd.SSHAuthSockID = RandStringBytes(10)
log.Debug("Reusing SSH_AUTH_SOCK", cmd.SSHAuthSockID)
} else if cmd.Proxy && ide.ReusesAuthSock(targetIDE) {
log.Info("Reusing SSH_AUTH_SOCK is not supported with proxy mode, consider launching the IDE from the platform UI")
}

// run devpod agent up
Expand Down Expand Up @@ -296,7 +299,7 @@ func (cmd *UpCmd) Run(
ideConfig.Options,
cmd.GitUsername,
cmd.GitToken,
cmd.AuthSockID,
cmd.SSHAuthSockID,
log,
)
case string(config.IDERustRover):
Expand Down Expand Up @@ -333,7 +336,7 @@ func (cmd *UpCmd) Run(
ideConfig.Options,
cmd.GitUsername,
cmd.GitToken,
cmd.AuthSockID,
cmd.SSHAuthSockID,
log,
)
case string(config.IDEJupyterDesktop):
Expand All @@ -346,7 +349,7 @@ func (cmd *UpCmd) Run(
ideConfig.Options,
cmd.GitUsername,
cmd.GitToken,
cmd.AuthSockID,
cmd.SSHAuthSockID,
log)
case string(config.IDEMarimo):
return startMarimoInBrowser(
Expand All @@ -358,7 +361,7 @@ func (cmd *UpCmd) Run(
ideConfig.Options,
cmd.GitUsername,
cmd.GitToken,
cmd.AuthSockID,
cmd.SSHAuthSockID,
log)
}
}
Expand Down
23 changes: 0 additions & 23 deletions docs/internal/networking.md

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/client/clientimplementation/workspace_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ func (s *workspaceClient) agentInfo(cliOptions provider.CLIOptions) (string, *pr
// Set registry cache from context option
agentInfo.RegistryCache = s.devPodConfig.ContextOption(config.ContextOptionRegistryCache)

if cliOptions.AuthSockID != "" {
agentInfo.AuthSockID = cliOptions.AuthSockID
}

// marshal config
out, err := json.Marshal(agentInfo)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/devcontainer/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ type UpOptions struct {
NoBuild bool
ForceBuild bool
RegistryCache string
AuthSockID string
}

func (r *runner) Up(ctx context.Context, options UpOptions, timeout time.Duration) (*config.Result, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/devcontainer/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r *runner) setupContainer(
// ssh tunnel
sshTunnelCmd := fmt.Sprintf("'%s' helper ssh-server --stdio", agent.ContainerDevPodHelperLocation)
if ide.ReusesAuthSock(r.WorkspaceConfig.Workspace.IDE.Name) {
sshTunnelCmd += fmt.Sprintf(" --reuse-sock=%s", r.WorkspaceConfig.AuthSockID)
sshTunnelCmd += fmt.Sprintf(" --reuse-sock=%s", r.WorkspaceConfig.CLIOptions.SSHAuthSockID)
}
if r.Log.GetLevel() == logrus.DebugLevel {
sshTunnelCmd += " --debug"
Expand Down
5 changes: 1 addition & 4 deletions pkg/provider/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ type AgentWorkspaceInfo struct {

// RegistryCache defines the registry to use for caching builds
RegistryCache string `json:"registryCache,omitempty"`

// ID to use when looking for SSH_AUTH_SOCK, defaults to a new random ID if not set (only used for browser IDEs)
AuthSockID string `json:"authSockID,omitempty"`
}

type CLIOptions struct {
Expand All @@ -220,6 +217,7 @@ type CLIOptions struct {
GitCloneStrategy git.CloneStrategy `json:"gitCloneStrategy,omitempty"`
FallbackImage string `json:"fallbackImage,omitempty"`
GitSSHSigningKey string `json:"gitSshSigningKey,omitempty"`
SSHAuthSockID string `json:"sshAuthSockID,omitempty"` // ID to use when looking for SSH_AUTH_SOCK, defaults to a new random ID if not set (only used for browser IDEs)

// build options
Repository string `json:"repository,omitempty"`
Expand All @@ -231,7 +229,6 @@ type CLIOptions struct {
ForceDockerless bool `json:"forceDockerless,omitempty"`
ForceInternalBuildKit bool `json:"forceInternalBuildKit,omitempty"`
SSHKey string `json:"sshkey,omitempty"`
AuthSockID string `json:"authSockID,omitempty"`
}

type BuildOptions struct {
Expand Down

0 comments on commit 990cb47

Please sign in to comment.