Skip to content

Commit

Permalink
support container in ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Feb 4, 2025
1 parent 3a67301 commit c86fcd2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"net"
"os"

"golang.org/x/crypto/ssh"
)
Expand Down Expand Up @@ -116,6 +117,11 @@ func (c *Client) Shell(ctx context.Context, sessIO *SessionIO, cmd string) error
return err
}
defer sess.Close()
if container := os.Getenv("FLY_SSH_CONTAINER"); container != "" {
if err := sess.Setenv("FLY_SSH_CONTAINER", container); err != nil {
return fmt.Errorf("could not set FLY_SSH_CONTAINER: %s", err)
}
}

return sessIO.attach(ctx, sess, cmd)
}

0 comments on commit c86fcd2

Please sign in to comment.