-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprepare.js
67 lines (61 loc) · 2.22 KB
/
prepare.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const WF = require('push2cloud-workflow-utils');
const waterfall = WF.waterfall;
const step = WF.step;
const map = WF.map;
const mapLimit = WF.mapLimit(Math.round(require('os').cpus().length / 2));
const mapSeries = WF.mapSeries;
const packageApp = WF.packageApp;
const desiredApps = (api, log, services) =>
waterfall(
[ step(log('prepare desired apps'))
, step(log('===================='))
, step(log('start deployment'))
, step(log('package apps'))
, mapLimit(packageApp, 'desired.apps')
, step(log('create service instances'))
, mapLimit(api.createServiceInstance, services || 'desired.services')
, step(log('create routes'))
, map(api.createRoute, 'desired.routes')
, step(log('push apps'))
, mapLimit(api.pushApp, 'desired.apps')
, step(log('set environement'))
, mapLimit(api.setEnv, 'desired.envVars')
, step(log('stage apps'))
, map(api.stageApp, 'desired.apps')
, step(log('wait for services to be ready to bind'))
, map(api.waitForServiceInstance, services || 'desired.services')
, step(log('bind services'))
, mapSeries(api.bindService, 'desired.serviceBindings')
, step(log('start apps and wait for instances'))
, step(log('desired apps prepared'))
]
);
const prepareApps = (api, log, what, services) =>
waterfall(
[ step(log('prepare apps'))
, step(log('===================='))
, step(log('start deployment'))
, step(log('package apps'))
, map(packageApp, what.apps)
, step(log('create service instances'))
, mapLimit(api.createServiceInstance, services || what.services)
, step(log('create routes'))
, map(api.createRoute, what.routes)
, step(log('push apps'))
, mapLimit(api.pushApp, what.apps)
, step(log('set environement'))
, mapLimit(api.setEnv, what.envVars)
, step(log('stage apps'))
, map(api.stageApp, what.apps)
, step(log('wait for services to be ready to bind'))
, map(api.waitForServiceInstance, services || what.services)
, step(log('bind services'))
, mapSeries(api.bindService, what.serviceBindings)
, step(log('start apps and wait for instances'))
, step(log('apps prepared'))
]
);
module.exports = {
desiredApps: desiredApps,
prepareApps: prepareApps
};