@@ -42,7 +42,7 @@ type ShellStore interface {
42
42
func NewCmdShell (t * terminal.Terminal , store ShellStore , noLoginStartStore ShellStore ) * cobra.Command {
43
43
var runRemoteCMD bool
44
44
var directory string
45
-
45
+ var host bool
46
46
cmd := & cobra.Command {
47
47
Annotations : map [string ]string {"ssh" : "" },
48
48
Use : "shell" ,
@@ -54,20 +54,21 @@ func NewCmdShell(t *terminal.Terminal, store ShellStore, noLoginStartStore Shell
54
54
Args : cmderrors .TransformToValidationError (cmderrors .TransformToValidationError (cobra .ExactArgs (1 ))),
55
55
ValidArgsFunction : completions .GetAllWorkspaceNameCompletionHandler (noLoginStartStore , t ),
56
56
RunE : func (cmd * cobra.Command , args []string ) error {
57
- err := runShellCommand (t , store , args [0 ], directory )
57
+ err := runShellCommand (t , store , args [0 ], directory , host )
58
58
if err != nil {
59
59
return breverrors .WrapAndTrace (err )
60
60
}
61
61
return nil
62
62
},
63
63
}
64
+ cmd .Flags ().BoolVarP (& host , "host" , "" , false , "ssh into the host machine instead of the container" )
64
65
cmd .Flags ().BoolVarP (& runRemoteCMD , "remote" , "r" , true , "run remote commands" )
65
66
cmd .Flags ().StringVarP (& directory , "dir" , "d" , "" , "override directory to launch shell" )
66
67
67
68
return cmd
68
69
}
69
70
70
- func runShellCommand (t * terminal.Terminal , sstore ShellStore , workspaceNameOrID , directory string ) error {
71
+ func runShellCommand (t * terminal.Terminal , sstore ShellStore , workspaceNameOrID , directory string , host bool ) error {
71
72
s := t .NewSpinner ()
72
73
workspace , err := util .GetUserWorkspaceByNameOrIDErr (sstore , workspaceNameOrID )
73
74
if err != nil {
@@ -93,7 +94,13 @@ func runShellCommand(t *terminal.Terminal, sstore ShellStore, workspaceNameOrID,
93
94
if workspace .Status != "RUNNING" {
94
95
return breverrors .New ("Workspace is not running" )
95
96
}
96
- sshName := string (workspace .GetLocalIdentifier ())
97
+
98
+ localIdentifier := workspace .GetLocalIdentifier ()
99
+ if host {
100
+ localIdentifier += "-host"
101
+ }
102
+
103
+ sshName := string (localIdentifier )
97
104
98
105
err = refreshRes .Await ()
99
106
if err != nil {
0 commit comments