StartLogsWithWriter prints the logs and then attaches to the container with the given stdout and stderr
(ctx devspacecontext.Context, selector targetselector.TargetSelector, follow bool, tail int64, writer io.Writer)
| 14 | |
| 15 | // StartLogsWithWriter prints the logs and then attaches to the container with the given stdout and stderr |
| 16 | func StartLogsWithWriter(ctx devspacecontext.Context, selector targetselector.TargetSelector, follow bool, tail int64, writer io.Writer) error { |
| 17 | container, err := selector.SelectSingleContainer(ctx.Context(), ctx.KubeClient(), ctx.Log()) |
| 18 | if err != nil { |
| 19 | return err |
| 20 | } |
| 21 | |
| 22 | ctx.Log().Infof("Printing logs of pod:container %s:%s", ansi.Color(container.Pod.Name, "white+b"), ansi.Color(container.Container.Name, "white+b")) |
| 23 | reader, err := ctx.KubeClient().Logs(ctx.Context(), container.Pod.Namespace, container.Pod.Name, container.Container.Name, false, &tail, follow) |
| 24 | if err != nil { |
| 25 | return err |
| 26 | } |
| 27 | |
| 28 | _, err = io.Copy(writer, reader) |
| 29 | return err |
| 30 | } |
| 31 | |
| 32 | // StartLogs print the logs and then attaches to the container |
| 33 | func StartLogs( |
no test coverage detected