getZipLogMap populates a logs struct with appropriate log fetchers based on the provided zip file and list of jobs. The structure of zip file is expected to be as: zip/ ├── jobname1/ │ ├── 1_stepname.txt │ ├── 2_anotherstepname.txt │ ├── 3_stepstepname.txt │ └── 4_laststepname.txt ├
(rlz *zip.Reader, jobs []shared.Job)
| 213 | // However, if it doesn't get the logs, it falls back to an old service |
| 214 | // where the ID can apparently be negative. |
| 215 | func getZipLogMap(rlz *zip.Reader, jobs []shared.Job) *zipLogMap { |
| 216 | zlm := newZipLogMap() |
| 217 | |
| 218 | for _, job := range jobs { |
| 219 | // So far we haven't yet encountered a ZIP containing both top-level job |
| 220 | // logs (i.e. the normal and the legacy .txt files). However, it's still |
| 221 | // possible. Therefore, we prioritise the normal log over the legacy one. |
| 222 | if zf := matchFileInZIPArchive(rlz, jobLogFilenameRegexp(job)); zf != nil { |
| 223 | zlm.addJob(job.ID, zf) |
| 224 | } else if zf := matchFileInZIPArchive(rlz, legacyJobLogFilenameRegexp(job)); zf != nil { |
| 225 | zlm.addJob(job.ID, zf) |
| 226 | } |
| 227 | |
| 228 | for _, step := range job.Steps { |
| 229 | if zf := matchFileInZIPArchive(rlz, stepLogFilenameRegexp(job, step)); zf != nil { |
| 230 | zlm.addStep(job.ID, step.Number, zf) |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | return zlm |
| 236 | } |
| 237 | |
| 238 | const JOB_NAME_MAX_LENGTH = 90 |
| 239 |