-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathindex.js
More file actions
62 lines (54 loc) · 1.98 KB
/
index.js
File metadata and controls
62 lines (54 loc) · 1.98 KB
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
53
54
55
56
57
58
59
60
61
'use strict'
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')
// map multiple images to a unique sha
const IMAGES = new Map()
module.exports = {
buildConfig
, fail
, prepare
, publish
, success
, verifyConditions
}
/* c8 ignore start */
async function fail(config, context) {
const opts = await buildConfig(null, config, context)
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
context.image = image // eslint-disable-line require-atomic-updates
IMAGES.set(opts.build, image)
return dockerFail(opts, context)
}
/* c8 ignore start */
async function prepare(config, context) {
const opts = await buildConfig(null, config, context)
const image = await dockerPrepare(opts, context)
IMAGES.set(opts.build, image)
return image
}
async function publish(config, context) {
const opts = await buildConfig(null, config, context)
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
context.image = image // eslint-disable-line require-atomic-updates
IMAGES.set(opts.build, image)
return dockerPublish(opts, context)
}
async function success(config, context) {
const opts = await buildConfig(null, config, context)
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
context.image = image // eslint-disable-line require-atomic-updates
IMAGES.set(opts.build, image)
return dockerSuccess(opts, context)
}
async function verifyConditions(config, context) {
const opts = await buildConfig(null, config, context)
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
context.image = image // eslint-disable-line require-atomic-updates
IMAGES.set(opts.build, image)
return dockerVerify(opts, context)
}