Logs prints the container logs
(ctx context.Context, namespace, podName, containerName string, lastContainerLog bool, tail *int64, follow bool)
| 25 | |
| 26 | // Logs prints the container logs |
| 27 | func (client *client) Logs(ctx context.Context, namespace, podName, containerName string, lastContainerLog bool, tail *int64, follow bool) (io.ReadCloser, error) { |
| 28 | lines := int64(500) |
| 29 | if tail != nil { |
| 30 | lines = *tail |
| 31 | } |
| 32 | |
| 33 | request := client.KubeClient().CoreV1().RESTClient().Get().Namespace(namespace).Name(podName).Resource("pods").SubResource("log").VersionedParams(&v1.PodLogOptions{ |
| 34 | Container: containerName, |
| 35 | TailLines: &lines, |
| 36 | Previous: lastContainerLog, |
| 37 | Follow: follow, |
| 38 | }, scheme.ParameterCodec) |
| 39 | if request.URL().String() == "" { |
| 40 | return nil, errors.New("Request url is empty") |
| 41 | } |
| 42 | |
| 43 | return request.Stream(ctx) |
| 44 | } |