Multiple streams the pod logs, sending each container's stream to a separate writer
( ctx context.Context, opts *corev1.PodLogOptions, writerConstructor writerConstructor, filePathGenerator func(string) string, )
| 94 | |
| 95 | // Multiple streams the pod logs, sending each container's stream to a separate writer |
| 96 | func (spl *Writer) Multiple( |
| 97 | ctx context.Context, |
| 98 | opts *corev1.PodLogOptions, |
| 99 | writerConstructor writerConstructor, |
| 100 | filePathGenerator func(string) string, |
| 101 | ) error { |
| 102 | if opts.Container != "" { |
| 103 | return fmt.Errorf("use Single method to handle a single container output") |
| 104 | } |
| 105 | |
| 106 | for _, container := range spl.Pod.Spec.Containers { |
| 107 | writer, err := writerConstructor.Create(filePathGenerator(container.Name)) |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | containerOpts := opts.DeepCopy() |
| 112 | containerOpts.Container = container.Name |
| 113 | |
| 114 | if err := spl.sendLogsToWriter(ctx, writer, containerOpts); err != nil { |
| 115 | return err |
| 116 | } |
| 117 | } |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | func executeGetLogRequest(ctx context.Context, logRequest *rest.Request, writer io.Writer) error { |
| 122 | logStream, err := logRequest.Stream(ctx) |
no test coverage detected