-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate dockbit service - discontinued (#2410)
Ref: #2344
- Loading branch information
1 parent
2045489
commit 8829456
Showing
4 changed files
with
23 additions
and
129 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,78 +1,12 @@ | ||
'use strict' | ||
|
||
const LegacyService = require('../legacy-service') | ||
const { makeBadgeData: getBadgeData } = require('../../lib/badge-data') | ||
|
||
module.exports = class Dockbit extends LegacyService { | ||
static get category() { | ||
return 'build' | ||
} | ||
|
||
static get route() { | ||
return { | ||
base: 'dockbit', | ||
} | ||
} | ||
|
||
static get examples() { | ||
return [ | ||
{ | ||
title: 'Dockbit', | ||
previewUrl: 'DockbitStatus/health?token=TvavttxFHJ4qhnKstDxrvBXM', | ||
pattern: ':organisation/:pipeline?token=:token', | ||
exampleUrl: 'DockbitStatus/health?token=TvavttxFHJ4qhnKstDxrvBXM', | ||
}, | ||
] | ||
} | ||
|
||
static registerLegacyRouteHandler({ camp, cache }) { | ||
camp.route( | ||
/^\/dockbit\/([A-Za-z0-9-_]+)\/([A-Za-z0-9-_]+)\.(svg|png|gif|jpg|json)$/, | ||
cache({ | ||
queryParams: ['token'], | ||
handler: (data, match, sendBadge, request) => { | ||
const org = match[1] | ||
const pipeline = match[2] | ||
const format = match[3] | ||
|
||
const token = data.token | ||
const badgeData = getBadgeData('deploy', data) | ||
const apiUrl = `https://dockbit.com/${org}/${pipeline}/status/${token}` | ||
|
||
const dockbitStates = { | ||
success: '#72BC37', | ||
failure: '#F55C51', | ||
error: '#F55C51', | ||
working: '#FCBC41', | ||
pending: '#CFD0D7', | ||
rejected: '#CFD0D7', | ||
} | ||
|
||
request(apiUrl, { json: true }, (err, res, data) => { | ||
try { | ||
if (res && (res.statusCode === 404 || data.state === null)) { | ||
badgeData.text[1] = 'not found' | ||
sendBadge(format, badgeData) | ||
return | ||
} | ||
|
||
if (!res || err !== null || res.statusCode !== 200) { | ||
badgeData.text[1] = 'inaccessible' | ||
sendBadge(format, badgeData) | ||
return | ||
} | ||
|
||
badgeData.text[1] = data.state | ||
badgeData.colorB = dockbitStates[data.state] | ||
|
||
sendBadge(format, badgeData) | ||
} catch (e) { | ||
badgeData.text[1] = 'invalid' | ||
sendBadge(format, badgeData) | ||
} | ||
}) | ||
}, | ||
}) | ||
) | ||
} | ||
} | ||
const deprecatedService = require('../deprecated-service') | ||
// dockbit integration - deprecated as of December 2017. | ||
module.exports = deprecatedService({ | ||
category: 'build', | ||
url: { | ||
base: 'dockbit', | ||
format: '(?:.+)', | ||
}, | ||
label: 'dockbit', | ||
}) |
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 |
---|---|---|
@@ -1,50 +1,20 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const ServiceTester = require('../service-tester') | ||
|
||
const t = new ServiceTester({ id: 'dockbit', title: 'Dockbit' }) | ||
module.exports = t | ||
|
||
t.create('deploy status') | ||
.get('/DockbitStatus/health.json?token=TvavttxFHJ4qhnKstDxrvBXM') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'deploy', | ||
value: Joi.equal( | ||
'success', | ||
'failure', | ||
'error', | ||
'working', | ||
'pending', | ||
'rejected' | ||
), | ||
}) | ||
) | ||
t.create('no longer available (previously image size)') | ||
.get('/image-size/_/ubuntu/latest.json') | ||
.expectJSON({ | ||
name: 'dockbit', | ||
value: 'no longer available', | ||
}) | ||
|
||
t.create('unknown pipeline') | ||
.get('/DockbitStatus/unknown.json') | ||
.expectJSON({ name: 'deploy', value: 'not found' }) | ||
|
||
t.create('no deploy status') | ||
.get('/foo/bar.json?token=123') | ||
.intercept(nock => | ||
nock('https://dockbit.com/') | ||
.get('/foo/bar/status/123') | ||
.reply(200, { state: null }) | ||
) | ||
.expectJSON({ name: 'deploy', value: 'not found' }) | ||
|
||
t.create('server error') | ||
.get('/foo/bar.json?token=123') | ||
.intercept(nock => | ||
nock('https://dockbit.com/') | ||
.get('/foo/bar/status/123') | ||
.reply(500, 'Something went wrong') | ||
) | ||
.expectJSON({ name: 'deploy', value: 'inaccessible' }) | ||
|
||
t.create('connection error') | ||
.get('/foo/bar.json') | ||
.networkOff() | ||
.expectJSON({ name: 'deploy', value: 'inaccessible' }) | ||
t.create('no longer available (previously number of layers)') | ||
.get('/layers/_/ubuntu/latest.json') | ||
.expectJSON({ | ||
name: 'dockbit', | ||
value: 'no longer available', | ||
}) |