-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
report installation progress to codefresh to support idiomatic instal… (
#459) * report installation progress to codefresh to support idiomatic installation * report failures
- Loading branch information
Oleg Sucharevich
authored
May 18, 2020
1 parent
779b013
commit de16efa
Showing
5 changed files
with
232 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
async function create(installer, event) { | ||
const res = await installer.createNewInstallationProgress(event); | ||
return res.progress; | ||
} | ||
|
||
function buildReporter(installer, progress) { | ||
return { | ||
report: (event, status, options = {}) => { | ||
const data = { | ||
event, | ||
content: { | ||
status, | ||
...options, | ||
}, | ||
}; | ||
return installer.reportInstallationProgressEvent({ id: progress.id }, data); | ||
}, | ||
}; | ||
} | ||
|
||
module.exports = { | ||
create, | ||
buildReporter, | ||
events: { | ||
RUNNER_INSTALLED: 'runner-installed', | ||
MONITOR_INSTALLED: 'monitor-installed', | ||
PIPELINE_EXECUTED: 'demo-pipeline-executed', | ||
PIPELINE_CREATED: 'demo-pipeline-created', | ||
FINISHED: 'finished', | ||
}, | ||
status: { | ||
SUCCESS: 'success', | ||
FAILURE: 'failure', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
async function to(fn) { | ||
try { | ||
let res; | ||
if (typeof fn === 'function') { | ||
res = await fn(); | ||
} else { | ||
res = await fn; | ||
} | ||
return [null, res]; | ||
} catch (err) { | ||
return [err, null]; | ||
} | ||
} | ||
module.exports = { | ||
to, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters