| 17 | ) |
| 18 | |
| 19 | func 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 | |
| 47 | func waitForContainerRunning(ctx context.Context, timeout time.Duration, clientset *kubernetes.Clientset, namespace, podName, containerName string) error { |
| 48 | ctx, cancel := context.WithTimeout(ctx, timeout) |