Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.

Commit 097f494

Browse files
stishkinstas
andauthored
add results when firing webhooks (#79)
Co-authored-by: stas <[email protected]>
1 parent 2b2cb59 commit 097f494

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

src/APIService/ApiService/Controllers/Webhook.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ type webhooksController(configuration : IConfiguration, telemetryClient : Teleme
400400
JobId = jobId
401401
AgentName = "1"
402402
Metadata = None
403+
ResultsUrl = Some "https://azure-storage/results"
403404
BugDetails =
404405
Some(
405406
Map.empty

src/Agent/RESTlerAgent/AgentMain.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ let main argv =
587587
AgentName = agentName
588588
Metadata = None
589589
BugDetails = Some bugDetails
590+
ResultsUrl = None
590591
} : Raft.JobEvents.BugFound)
591592
}
592593

src/Contracts/JobEvents.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type BugFound =
8585
AgentName : string
8686
Metadata : Map<string, string> option
8787
BugDetails : Map<string, string> option
88+
ResultsUrl : string option
8889
}
8990

9091
static member EventType = Events.JobEventTypes.BugFound.ToString()

src/Orchestrator/OrchestratorLogic/Orchestrator.fs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,21 +1330,37 @@ module ContainerInstances =
13301330
return None
13311331
}
13321332

1333+
let getResultsUrl jobId =
1334+
async {
1335+
match! JobStatus.getRow agentConfig (jobId, jobId) with
1336+
| Result.Error() -> return None
1337+
| Result.Ok(r) ->
1338+
match r with
1339+
| None -> return None
1340+
| Some row -> return (if String.IsNullOrWhiteSpace row.ResultsUrl then None else Some row.ResultsUrl)
1341+
}
1342+
13331343
let eventType = RaftEvent.getEventType message
13341344
if eventType = JobStatus.EventType then
13351345
let jobStatus : RaftEvent.RaftJobEvent<JobStatus> = RaftEvent.deserializeEvent message
13361346
let! metadata = getMetadata jobStatus.Message.JobId
1347+
let! resultsUrl = getResultsUrl jobStatus.Message.JobId
13371348
let updatedJobStatus = { jobStatus with
13381349
Message = { jobStatus.Message with
1339-
Metadata = metadata }
1350+
Metadata = metadata
1351+
ResultsUrl = resultsUrl
1352+
}
13401353
}
13411354
do! processMessage updatedJobStatus.Message.JobId updatedJobStatus
13421355
else if eventType = BugFound.EventType then
13431356
let bugFound : RaftEvent.RaftJobEvent<BugFound> = RaftEvent.deserializeEvent message
13441357
let! metadata = getMetadata bugFound.Message.JobId
1358+
let! resultsUrl = getResultsUrl bugFound.Message.JobId
13451359
let updatedBugFound = { bugFound with
13461360
Message = { bugFound.Message with
1347-
Metadata = metadata }
1361+
Metadata = metadata
1362+
ResultsUrl = resultsUrl
1363+
}
13481364
}
13491365

13501366
do! processMessage updatedBugFound.Message.JobId updatedBugFound

0 commit comments

Comments
 (0)