loadFirstGeneratedImage reads the first existing image path into an OutboundImage. Returns nil when there is nothing to send or it is unreadable.
(paths []string)
| 451 | // loadFirstGeneratedImage reads the first existing image path into an |
| 452 | // OutboundImage. Returns nil when there is nothing to send or it is unreadable. |
| 453 | func loadFirstGeneratedImage(paths []string) *gateway.OutboundImage { |
| 454 | for _, p := range paths { |
| 455 | data, err := os.ReadFile(p) //#nosec G304 -- path written by the @image tool during this run, not external input |
| 456 | if err != nil || len(data) == 0 { |
| 457 | continue |
| 458 | } |
| 459 | mime, ok := models.DetectImageMediaType(data) |
| 460 | if !ok { |
| 461 | mime = "image/png" |
| 462 | } |
| 463 | return &gateway.OutboundImage{Data: data, Mime: mime, FileName: filepath.Base(p)} |
| 464 | } |
| 465 | return nil |
| 466 | } |
| 467 | |
| 468 | // teeLoggerToGatewayLog adds a JSON sink at gatewayStatePath("gateway.log") to |
| 469 | // cli.logger so the daemon's structured logs land in the file /gateway start |
no test coverage detected