MCPcopy
hub / github.com/microsoft/retina / attachToShell

Function attachToShell

shell/attach.go:19–45  ·  view source on GitHub ↗
(restConfig *rest.Config, namespace, podName, containerName string, pod *v1.Pod)

Source from the content-addressed store, hash-verified

17)
18
19func attachToShell(restConfig *rest.Config, namespace, podName, containerName string, pod *v1.Pod) error {
20 attachOpts := &attach.AttachOptions{
21 Config: restConfig,
22 StreamOptions: exec.StreamOptions{
23 Namespace: namespace,
24 PodName: podName,
25 ContainerName: containerName,
26 IOStreams: genericiooptions.IOStreams{
27 In: os.Stdin,
28 Out: os.Stdout,
29 ErrOut: os.Stderr,
30 },
31 Stdin: true,
32 TTY: true,
33 Quiet: true,
34 },
35 Attach: &attach.DefaultRemoteAttach{},
36 AttachFunc: attach.DefaultAttachFunc,
37 Pod: pod,
38 }
39
40 if err := attachOpts.Run(); err != nil {
41 return fmt.Errorf("error attaching to shell container: %w", err)
42 }
43
44 return nil
45}
46
47func waitForContainerRunning(ctx context.Context, timeout time.Duration, clientset *kubernetes.Clientset, namespace, podName, containerName string) error {
48 ctx, cancel := context.WithTimeout(ctx, timeout)

Callers 2

RunInPodFunction · 0.85
RunInNodeFunction · 0.85

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected