MCPcopy Index your code
hub / github.com/devspace-sh/devspace / execStreamWithTransport

Method execStreamWithTransport

pkg/devspace/kubectl/exec.go:29–122  ·  view source on GitHub ↗

execStreamWithTransport executes a kubectl exec with given transport round tripper and upgrader

(ctx context.Context, options *ExecStreamOptions)

Source from the content-addressed store, hash-verified

27
28// execStreamWithTransport executes a kubectl exec with given transport round tripper and upgrader
29func (client *client) execStreamWithTransport(ctx context.Context, options *ExecStreamOptions) error {
30 var (
31 t term.TTY
32 sizeQueue remotecommand.TerminalSizeQueue
33 streamOptions remotecommand.StreamOptions
34 tty = options.TTY
35 )
36
37 if options.SubResource == "" {
38 options.SubResource = SubResourceExec
39 }
40
41 wrapper, upgradeRoundTripper, err := GetUpgraderWrapper(client)
42 if err != nil {
43 return err
44 }
45
46 execRequest := client.KubeClient().CoreV1().RESTClient().Post().
47 Resource("pods").
48 Name(options.Pod.Name).
49 Namespace(options.Pod.Namespace).
50 SubResource(string(options.SubResource))
51
52 if tty {
53 tty, t = terminal.SetupTTY(options.Stdin, options.Stdout)
54 if options.ForceTTY || tty {
55 tty = true
56 if t.Raw && options.TerminalSizeQueue == nil {
57 // this call spawns a goroutine to monitor/update the terminal size
58 sizeQueue = t.MonitorSize(t.GetSize())
59 } else if options.TerminalSizeQueue != nil {
60 sizeQueue = options.TerminalSizeQueue
61 t.Raw = true
62 }
63
64 // unset options.Stderr if it was previously set because both stdout and stderr
65 // go over t.Out when tty is true
66 options.Stderr = nil
67 streamOptions = remotecommand.StreamOptions{
68 Stdin: t.In,
69 Stdout: t.Out,
70 Tty: t.Raw,
71 TerminalSizeQueue: sizeQueue,
72 }
73 }
74 }
75 if !tty {
76 streamOptions = remotecommand.StreamOptions{
77 Stdin: options.Stdin,
78 Stdout: options.Stdout,
79 Stderr: options.Stderr,
80 }
81 }
82
83 if options.SubResource == SubResourceExec {
84 execRequest.VersionedParams(&corev1.PodExecOptions{
85 Container: options.Container,
86 Command: options.Command,

Callers 1

ExecStreamMethod · 0.95

Calls 8

KubeClientMethod · 0.95
SetupTTYFunction · 0.92
GetUpgraderWrapperFunction · 0.85
GetSizeMethod · 0.80
NamespaceMethod · 0.65
NameMethod · 0.65
DoneMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected