(ctx context.Context, logURL string, tailLines int, maxLines int)
| 166 | } |
| 167 | |
| 168 | func downloadLogContent(ctx context.Context, logURL string, tailLines int, maxLines int) (string, int, *http.Response, error) { |
| 169 | prof := profiler.New(nil, profiler.IsProfilingEnabled()) |
| 170 | finish := prof.Start(ctx, "log_buffer_processing") |
| 171 | |
| 172 | httpResp, err := http.Get(logURL) //nolint:gosec |
| 173 | if err != nil { |
| 174 | return "", 0, httpResp, fmt.Errorf("failed to download logs: %w", err) |
| 175 | } |
| 176 | defer func() { _ = httpResp.Body.Close() }() |
| 177 | |
| 178 | if httpResp.StatusCode != http.StatusOK { |
| 179 | return "", 0, httpResp, fmt.Errorf("failed to download logs: HTTP %d", httpResp.StatusCode) |
| 180 | } |
| 181 | |
| 182 | bufferSize := min(tailLines, maxLines) |
| 183 | |
| 184 | processedInput, totalLines, httpResp, err := buffer.ProcessResponseAsRingBufferToEnd(httpResp, bufferSize) |
| 185 | if err != nil { |
| 186 | return "", 0, httpResp, fmt.Errorf("failed to process log content: %w", err) |
| 187 | } |
| 188 | |
| 189 | lines := strings.Split(processedInput, "\n") |
| 190 | if len(lines) > tailLines { |
| 191 | lines = lines[len(lines)-tailLines:] |
| 192 | } |
| 193 | finalResult := strings.Join(lines, "\n") |
| 194 | |
| 195 | _ = finish(len(lines), int64(len(finalResult))) |
| 196 | |
| 197 | return finalResult, totalLines, httpResp, nil |
| 198 | } |
| 199 | |
| 200 | // ActionsList returns the tool and handler for listing GitHub Actions resources. |
| 201 | func ActionsList(t translations.TranslationHelperFunc) inventory.ServerTool { |
no test coverage detected