Skip to content

Commit 8a9f851

Browse files
fix(cli): forward git credentials even on vscode
1 parent 043aadf commit 8a9f851

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

cmd/ssh.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ type SSHCmd struct {
4444
AgentForwarding bool
4545
GPGAgentForwarding bool
4646

47-
StartServices bool
48-
ForceGitCredentialForwarding bool
47+
StartServices bool
4948

5049
Proxy bool
5150

@@ -94,8 +93,6 @@ func NewSSHCmd(flags *flags.GlobalFlags) *cobra.Command {
9493
sshCmd.Flags().BoolVar(&cmd.GPGAgentForwarding, "gpg-agent-forwarding", false, "If true forward the local gpg-agent to the remote machine")
9594
sshCmd.Flags().BoolVar(&cmd.Stdio, "stdio", false, "If true will tunnel connection through stdout and stdin")
9695
sshCmd.Flags().BoolVar(&cmd.StartServices, "start-services", true, "If false will not start any port-forwarding or git / docker credentials helper")
97-
sshCmd.Flags().BoolVar(&cmd.ForceGitCredentialForwarding, "force-git-credential-forwarding", false, "Forces git credential forwarding")
98-
_ = sshCmd.Flags().MarkHidden("force-git-credential-forwarding")
9996
return sshCmd
10097
}
10198

@@ -156,7 +153,7 @@ func (cmd *SSHCmd) startProxyTunnel(
156153
})
157154
},
158155
func(ctx context.Context, containerClient *ssh.Client) error {
159-
return cmd.startTunnel(ctx, devPodConfig, containerClient, client.Workspace(), client.WorkspaceConfig().IDE.Name, log)
156+
return cmd.startTunnel(ctx, devPodConfig, containerClient, client.Workspace(), log)
160157
},
161158
)
162159
}
@@ -234,7 +231,7 @@ func (cmd *SSHCmd) jumpContainer(
234231
unlockOnce.Do(client.Unlock)
235232

236233
// start ssh tunnel
237-
return cmd.startTunnel(ctx, devPodConfig, containerClient, client.Workspace(), client.WorkspaceConfig().IDE.Name, log)
234+
return cmd.startTunnel(ctx, devPodConfig, containerClient, client.Workspace(), log)
238235
})
239236
}
240237

@@ -342,7 +339,7 @@ func (cmd *SSHCmd) forwardPorts(
342339
return <-errChan
343340
}
344341

345-
func (cmd *SSHCmd) startTunnel(ctx context.Context, devPodConfig *config.Config, containerClient *ssh.Client, workspaceName string, ideName string, log log.Logger) error {
342+
func (cmd *SSHCmd) startTunnel(ctx context.Context, devPodConfig *config.Config, containerClient *ssh.Client, workspaceName string, log log.Logger) error {
346343
// check if we should forward ports
347344
if len(cmd.ForwardPorts) > 0 {
348345
return cmd.forwardPorts(ctx, containerClient, log)
@@ -355,7 +352,7 @@ func (cmd *SSHCmd) startTunnel(ctx context.Context, devPodConfig *config.Config,
355352

356353
// start port-forwarding etc.
357354
if !cmd.Proxy && cmd.StartServices {
358-
go cmd.startServices(ctx, devPodConfig, containerClient, ideName, cmd.GitUsername, cmd.GitToken, log)
355+
go cmd.startServices(ctx, devPodConfig, containerClient, cmd.GitUsername, cmd.GitToken, log)
359356
}
360357

361358
// start ssh
@@ -393,7 +390,7 @@ func (cmd *SSHCmd) startTunnel(ctx context.Context, devPodConfig *config.Config,
393390
// Traffic is coming in from the outside, we need to forward it to the container
394391
if cmd.Proxy || cmd.Stdio {
395392
if cmd.Proxy {
396-
go cmd.startProxyServices(ctx, devPodConfig, containerClient, ideName, log)
393+
go cmd.startProxyServices(ctx, devPodConfig, containerClient, log)
397394
}
398395

399396
return devssh.Run(ctx, containerClient, command, os.Stdin, os.Stdout, writer)
@@ -416,23 +413,18 @@ func (cmd *SSHCmd) startServices(
416413
ctx context.Context,
417414
devPodConfig *config.Config,
418415
containerClient *ssh.Client,
419-
ideName string,
420416
gitUsername,
421417
gitToken string,
422418
log log.Logger,
423419
) {
424420
if cmd.User != "" {
425-
gitCredentials := ideName != string(config.IDEVSCode)
426-
if cmd.ForceGitCredentialForwarding {
427-
gitCredentials = true
428-
}
429421
err := tunnel.RunInContainer(
430422
ctx,
431423
devPodConfig,
432424
containerClient,
433425
cmd.User,
434426
false,
435-
gitCredentials,
427+
true,
436428
true,
437429
nil,
438430
gitUsername,
@@ -449,7 +441,6 @@ func (cmd *SSHCmd) startProxyServices(
449441
ctx context.Context,
450442
devPodConfig *config.Config,
451443
containerClient *ssh.Client,
452-
ideName string,
453444
log log.Logger,
454445
) {
455446
gitCredentials := devPodConfig.ContextOption(config.ContextOptionSSHInjectGitCredentials) == "true"

cmd/up.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ func setupDotfiles(
886886
"ssh",
887887
"--agent-forwarding=true",
888888
"--start-services=true",
889-
"--force-git-credential-forwarding",
890889
"--user",
891890
remoteUser,
892891
"--context",

0 commit comments

Comments
 (0)