MCPcopy
hub / github.com/cloudfoundry/cli / InteractiveSession

Method InteractiveSession

cf/ssh/ssh.go:212–314  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210}
211
212func (c *secureShell) InteractiveSession() error {
213 var err error
214
215 secureClient := c.secureClient
216 opts := c.opts
217
218 session, err := secureClient.NewSession()
219 if err != nil {
220 return fmt.Errorf("SSH session allocation failed: %s", err.Error())
221 }
222 defer session.Close()
223
224 stdin, stdout, stderr := c.terminalHelper.StdStreams()
225
226 inPipe, err := session.StdinPipe()
227 if err != nil {
228 return err
229 }
230
231 outPipe, err := session.StdoutPipe()
232 if err != nil {
233 return err
234 }
235
236 errPipe, err := session.StderrPipe()
237 if err != nil {
238 return err
239 }
240
241 stdinFd, stdinIsTerminal := c.terminalHelper.GetFdInfo(stdin)
242 stdoutFd, stdoutIsTerminal := c.terminalHelper.GetFdInfo(stdout)
243
244 if c.shouldAllocateTerminal(opts, stdinIsTerminal) {
245 modes := ssh.TerminalModes{
246 ssh.ECHO: 1,
247 ssh.TTY_OP_ISPEED: 115200,
248 ssh.TTY_OP_OSPEED: 115200,
249 }
250
251 width, height := c.getWindowDimensions(stdoutFd)
252
253 err = session.RequestPty(c.terminalType(), height, width, modes)
254 if err != nil {
255 return err
256 }
257
258 var state *term.State
259 state, err = c.terminalHelper.SetRawTerminal(stdinFd)
260 if err == nil {
261 defer c.terminalHelper.RestoreTerminal(stdinFd, state)
262 }
263 }
264
265 if len(opts.Command) != 0 {
266 cmd := strings.Join(opts.Command, " ")
267 err = session.Start(cmd)
268 if err != nil {
269 return err

Callers

nothing calls this directly

Calls 15

getWindowDimensionsMethod · 0.95
terminalTypeMethod · 0.95
resizeMethod · 0.95
SIGWINCHFunction · 0.92
copyAndCloseFunction · 0.70
copyAndDoneFunction · 0.70
keepaliveFunction · 0.70
NewSessionMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65
StdStreamsMethod · 0.65

Tested by

no test coverage detected