Skip to content

Commit

Permalink
fix(cli): proxy provider credential forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbreuninger committed May 14, 2024
1 parent 3ce4da5 commit cbdf469
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,11 @@ func (cmd *SSHCmd) startProxyServices(
ideName string,
log log.Logger,
) {
if cmd.User == "" {
gitCredentials := devPodConfig.ContextOption(config.ContextOptionSSHInjectGitCredentials) == "true"
if !gitCredentials || cmd.User == "" || cmd.GitUsername == "" || cmd.GitToken == "" {
return
}

gitCredentials := devPodConfig.ContextOption(config.ContextOptionSSHInjectGitCredentials) == "true"

stdoutReader, stdoutWriter, err := os.Pipe()
if err != nil {
log.Debugf("Error creating stdout pipe: %v", err)
Expand Down Expand Up @@ -485,11 +484,9 @@ func (cmd *SSHCmd) startProxyServices(
errChan <- devssh.Run(cancelCtx, containerClient, command, stdinReader, stdoutWriter, writer)
}()

opts := []tunnelserver.Option{}
if cmd.GitUsername != "" && cmd.GitToken != "" {
opts = append(opts, tunnelserver.WithGitCredentialsOverride(cmd.GitUsername, cmd.GitToken))
}
err = tunnelserver.RunServicesServer(ctx, stdoutReader, stdinWriter, true, true, nil, log, opts...)
err = tunnelserver.RunServicesServer(ctx, stdoutReader, stdinWriter, true, true, nil, log,
[]tunnelserver.Option{tunnelserver.WithGitCredentialsOverride(cmd.GitUsername, cmd.GitToken)}...,
)
if err != nil {
log.Debugf("Error running proxy server: %v", err)
return
Expand Down

0 comments on commit cbdf469

Please sign in to comment.