-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 839 Bytes
/
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
const program = require('commander');
const fs = require('fs');
const yaml = require('js-yaml');
const log = require('loglevel');
const Entity = require('./Entity');
const FetchHelper = require('./FetchHelper');
const main = async(schema, desiredState, headers, targetUrl, verbosity, testForChanges) => {
log.setLevel(verbosity || 'INFO', false);
const fetchHelper = new FetchHelper(targetUrl, headers);
for (rootNode of desiredState) {
if (!rootNode.type) {
throw new Error(`Field "type" is undefined on entity: ${JSON.stringify(rootNode, null, 2)}`);
}
const rootEntity = new Entity(
rootNode.type,
rootNode.properties,
rootNode.children,
rootNode.absent,
[],
schema,
testForChanges,
fetchHelper);
await rootEntity.process();
}
}
module.exports = main;