Files
shields/services/docker/docker-cloud-build.service.js
dependabot-preview[bot] 294aa1e1df Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0; autofixes (#3671)
* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0

Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Autofixes
2019-07-08 12:13:46 -04:00

50 lines
1.2 KiB
JavaScript

'use strict'
const { dockerBlue, buildDockerUrl } = require('./docker-helpers')
const { fetchBuild } = require('./docker-cloud-common-fetch')
const { BaseJsonService } = require('..')
module.exports = class DockerCloudBuild extends BaseJsonService {
static get category() {
return 'build'
}
static get route() {
return buildDockerUrl('cloud/build')
}
static get examples() {
return [
{
title: 'Docker Cloud Build Status',
documentation:
'<p>For the new Docker Hub (https://cloud.docker.com)</p>',
namedParams: {
user: 'jrottenberg',
repo: 'ffmpeg',
},
staticPreview: this.render({ state: 'Success' }),
},
]
}
static get defaultBadgeData() {
return { label: 'docker build' }
}
static render({ state }) {
if (state === 'Success') {
return { message: 'passing', color: 'brightgreen' }
}
if (state === 'Failed') {
return { message: 'failing', color: 'red' }
}
return { message: 'building', color: dockerBlue }
}
async handle({ user, repo }) {
const data = await fetchBuild(this, { user, repo })
return this.constructor.render({ state: data.objects[0].state })
}
}