-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
52 lines (45 loc) · 1.52 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
const crypto = require('crypto')
const docker = require('./lib/docker/index.js')
const dockerPrepare = require('./lib/prepare.js')
const dockerVerify = require('./lib/verify.js')
const dockerPublish = require('./lib/publish.js')
const buildConfig = require('./lib/build-config.js')
const dockerSuccess = require('./lib/success.js')
const dockerFail = require('./lib/fail.js')
const build_id = crypto.randomBytes(10).toString('hex')
let image
module.exports = {
buildConfig
, fail
, prepare
, publish
, success
, verifyConditions
}
/* istanbul ignore next */
async function fail(config, context) {
const opts = await buildConfig(build_id, config, context)
context.image = image || docker.Image.from(opts, context)
return dockerFail(opts, context)
}
async function prepare(config, context) {
const opts = await buildConfig(build_id, config, context)
image = await dockerPrepare(opts, context)
return image
}
async function publish(config, context) {
const opts = await buildConfig(build_id, config, context)
context.image = image || docker.Image.from(opts, context)
return dockerPublish(opts, context)
}
async function success(config, context) {
const opts = await buildConfig(build_id, config, context)
context.image = image || docker.Image.from(opts, context)
return dockerSuccess(opts, context)
}
async function verifyConditions(config, context) {
const opts = await buildConfig(build_id, config, context)
context.image = image || docker.Image.from(opts, context)
return dockerVerify(opts, context)
}