(k8sClient kubernetes.Interface, namespace string, pod string, container string, tailLines int64, follow bool, previous bool,timestamps bool,session LogSession)
| 119 | } |
| 120 | |
| 121 | func startLogProcess(k8sClient kubernetes.Interface, namespace string, pod string, container string, tailLines int64, follow bool, previous bool,timestamps bool,session LogSession) error { |
| 122 | reader, err := k8sClient.CoreV1(). |
| 123 | Pods(namespace). |
| 124 | GetLogs(pod, &v1.PodLogOptions{ |
| 125 | Container: container, |
| 126 | Follow: follow, |
| 127 | TailLines: &tailLines, |
| 128 | Previous : previous, |
| 129 | Timestamps:timestamps, |
| 130 | }).Stream(context.TODO()) |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | |
| 135 | ss := session.sockJSSession |
| 136 | for { |
| 137 | buf := make([]byte, 2048) |
| 138 | numBytes, err := reader.Read(buf) |
| 139 | if numBytes > 0 { |
| 140 | message := string(buf[:numBytes]) |
| 141 | for _, val := range strings.Split(message, "\n") { |
| 142 | if strings.TrimSpace(val) == "" { |
| 143 | continue |
| 144 | } |
| 145 | err = ss.Send(strings.TrimSpace(val) + "\r\n") |
| 146 | if err != nil { |
| 147 | fmt.Println(err) |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | } |
| 155 | } |
no test coverage detected