MCPcopy Index your code
hub / github.com/cli/cli / getZipLogMap

Function getZipLogMap

pkg/cmd/run/view/logs.go:215–236  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

213// However, if it doesn't get the logs, it falls back to an old service
214// where the ID can apparently be negative.
215func 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
238const JOB_NAME_MAX_LENGTH = 90
239

Callers 2

TestGetZipLogMapFunction · 0.85
runViewFunction · 0.85

Calls 7

newZipLogMapFunction · 0.85
matchFileInZIPArchiveFunction · 0.85
jobLogFilenameRegexpFunction · 0.85
stepLogFilenameRegexpFunction · 0.85
addJobMethod · 0.80
addStepMethod · 0.80

Tested by 1

TestGetZipLogMapFunction · 0.68