Skip to content

Commit

Permalink
Deprecate dockbit service - discontinued (#2410)
Browse files Browse the repository at this point in the history
Ref: #2344
  • Loading branch information
assimovt authored and paulmelnikow committed Dec 2, 2018
1 parent 2045489 commit 8829456
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 129 deletions.
1 change: 1 addition & 0 deletions lib/deprecated-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const deprecatedServices = {
issuestats: new Date('2018-09-01'),
libscore: new Date('2018-09-22'),
imagelayers: new Date('2018-11-18'),
dockbit: new Date('2017-12-31'),
}

module.exports = {
Expand Down
11 changes: 0 additions & 11 deletions logo/dockbit.svg

This file was deleted.

86 changes: 10 additions & 76 deletions services/dockbit/dockbit.service.js
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',
})
54 changes: 12 additions & 42 deletions services/dockbit/dockbit.tester.js
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',
})

0 comments on commit 8829456

Please sign in to comment.