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

Function getZipLogMap

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

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

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