-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparsetargets
More file actions
executable file
·29 lines (22 loc) · 904 Bytes
/
parsetargets
File metadata and controls
executable file
·29 lines (22 loc) · 904 Bytes
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
#!/usr/bin/env node
const yamljs = require('yamljs');
const fs = require('fs');
const TARGET_LABEL = 'com.yolean.build-target';
// Let's not push anything where we don't want it!
const VALID_PUSH_RE = /^(localhost|[^\/]+\.local)/;
// Matches two different approaches:
// $REGISTRY_HOST/group/name:$PUSH_TAG
// localhost:5000/group/name:$PUSH_TAG
// $REGISTRY_HOST/group/name:${PUSH_TAG}
// localhost:5000/group/name:${PUSH_TAG}
const { services } = yamljs.parse(fs.readFileSync('/dev/stdin', 'UTF-8'));
for (let key in services) {
const service = services[key];
const labels = service.labels || [];
if (TARGET_LABEL in labels ||
(Array.isArray(labels) && labels.indexOf(TARGET_LABEL) !== -1)) {
if (!VALID_PUSH_RE.test(service.image))
throw new Error('build-contract only wants to push to "localhost..."! Not a valid image name: ' + service.image);
console.log(key);
}
}