* service: add obs service * service: obs: replaced replaceAll with replace and global regex * service: obs: added space between class members * service: obs: support for multiple instances * service: obs: removed user prefix from auth vars obs_userName is now called obs_user and obs_userPass is called obs_pass Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com> * service: obs: removed constructor hack in favour of serviceKey * service: obs: apply suggestions from @calebcartwright * service: obs: remove unneccesary http status mappings Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com> Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
78 lines
1.3 KiB
JavaScript
78 lines
1.3 KiB
JavaScript
import Joi from 'joi'
|
|
|
|
const greenStatuses = [
|
|
'fixed',
|
|
'passed',
|
|
'passing',
|
|
'succeeded',
|
|
'success',
|
|
'successful',
|
|
]
|
|
|
|
const orangeStatuses = ['partially succeeded', 'unstable', 'timeout']
|
|
|
|
const redStatuses = [
|
|
'broken',
|
|
'error',
|
|
'errored',
|
|
'failed',
|
|
'failing',
|
|
'failure',
|
|
'infrastructure_failure',
|
|
]
|
|
|
|
const otherStatuses = [
|
|
'aborted',
|
|
'building',
|
|
'canceled',
|
|
'cancelled',
|
|
'created',
|
|
'expired',
|
|
'initiated',
|
|
'no builds',
|
|
'no tests',
|
|
'not built',
|
|
'not run',
|
|
'pending',
|
|
'processing',
|
|
'queued',
|
|
'running',
|
|
'scheduled',
|
|
'skipped',
|
|
'starting',
|
|
'stopped',
|
|
'testing',
|
|
'waiting',
|
|
]
|
|
|
|
const allStatuses = greenStatuses
|
|
.concat(orangeStatuses)
|
|
.concat(redStatuses)
|
|
.concat(otherStatuses)
|
|
|
|
const isBuildStatus = Joi.equal(...allStatuses)
|
|
|
|
function renderBuildStatusBadge({ label, status }) {
|
|
let message
|
|
let color
|
|
if (greenStatuses.includes(status)) {
|
|
message = 'passing'
|
|
color = 'brightgreen'
|
|
} else if (orangeStatuses.includes(status)) {
|
|
message = status === 'partially succeeded' ? 'passing' : status
|
|
color = 'orange'
|
|
} else if (redStatuses.includes(status)) {
|
|
message = status === 'failed' ? 'failing' : status
|
|
color = 'red'
|
|
} else {
|
|
message = status
|
|
}
|
|
return {
|
|
label,
|
|
message,
|
|
color,
|
|
}
|
|
}
|
|
|
|
export { isBuildStatus, renderBuildStatusBadge }
|