@@ -184,7 +184,6 @@ func scan(w http.ResponseWriter, req *http.Request) {
184
184
}
185
185
scanRequest .Authorization = req .Header .Get ("Authorization" )
186
186
187
- log .WithFields (log.Fields {"auth" : scanRequest .Authorization , "registry" : scanRequest .Registry , "artifact" : scanRequest .Artifact }).Debug ("Scan request received" )
188
187
//Add to resultmap with wait http code
189
188
w .WriteHeader (http .StatusAccepted )
190
189
@@ -193,13 +192,15 @@ func scan(w http.ResponseWriter, req *http.Request) {
193
192
scanId := ScanRequestReturn {ID : fmt .Sprintf ("%v" , workloadID .GetNoLock ())}
194
193
scanRequest .WorkloadID = scanId .ID
195
194
scanRequestQueue .Enqueue (scanRequest )
195
+ log .WithFields (log.Fields {"workloadid" : scanId , "auth" : scanRequest .Authorization , "registry" : scanRequest .Registry , "artifact" : scanRequest .Artifact }).Debug ("Scan request received" )
196
196
workloadID .Increment ()
197
197
scanRequestQueue .Unlock ()
198
198
workloadID .Unlock ()
199
199
200
200
reportCache .Lock ()
201
201
expirationTime := generateExpirationTime ()
202
- reportCache .ScanReports [scanId .ID ] = ScanReport {Status : http .StatusFound , ExpirationTime : expirationTime }
202
+ ScanReport := ScanReport {Status : http .StatusFound , ExpirationTime : expirationTime }
203
+ reportCache .ScanReports [scanId .ID ] = ScanReport
203
204
reportCache .Unlock ()
204
205
205
206
err = json .NewEncoder (w ).Encode (scanId )
@@ -350,7 +351,7 @@ func pruneOldEntries() {
350
351
for key , value := range reportCache .ScanReports {
351
352
if value .ExpirationTime .Before (time .Now ()) {
352
353
delete (reportCache .ScanReports , key )
353
- log .WithFields (log.Fields {"key " : key , "expires" : value .ExpirationTime , "now" : time .Now ()}).Debug ("Deleted entry due to expiration time" )
354
+ log .WithFields (log.Fields {"workloadid " : key , "expires" : value .ExpirationTime , "now" : time .Now ()}).Debug ("Deleted entry due to expiration time" )
354
355
}
355
356
}
356
357
reportCache .Unlock ()
@@ -404,6 +405,7 @@ func scanResult(w http.ResponseWriter, req *http.Request) {
404
405
}
405
406
} else {
406
407
w .Header ().Add ("Location" , req .URL .String ())
408
+ log .WithFields (log.Fields {"id" : id }).Debug ("Entry not found for scan report" )
407
409
w .WriteHeader (http .StatusNotFound )
408
410
}
409
411
reportCache .Unlock ()
0 commit comments