MCPcopy Create free account
hub / github.com/cli/cli / getZipLogMap

Function getZipLogMap

pkg/cmd/run/view/logs.go:221–242  ·  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

219// However, if it doesn't get the logs, it falls back to an old service
220// where the ID can apparently be negative.
221func getZipLogMap(rlz *zip.Reader, jobs []shared.Job) *zipLogMap {
222 zlm := newZipLogMap()
223
224 for _, job := range jobs {
225 // So far we haven't yet encountered a ZIP containing both top-level job
226 // logs (i.e. the normal and the legacy .txt files). However, it's still
227 // possible. Therefore, we prioritise the normal log over the legacy one.
228 if zf := matchFileInZIPArchive(rlz, jobLogFilenameRegexp(job)); zf != nil {
229 zlm.addJob(job.ID, zf)
230 } else if zf := matchFileInZIPArchive(rlz, legacyJobLogFilenameRegexp(job)); zf != nil {
231 zlm.addJob(job.ID, zf)
232 }
233
234 for _, step := range job.Steps {
235 if zf := matchFileInZIPArchive(rlz, stepLogFilenameRegexp(job, step)); zf != nil {
236 zlm.addStep(job.ID, step.Number, zf)
237 }
238 }
239 }
240
241 return zlm
242}
243
244const JOB_NAME_MAX_LENGTH = 90
245

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