-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathvalue.js
More file actions
executable file
·38 lines (30 loc) · 831 Bytes
/
value.js
File metadata and controls
executable file
·38 lines (30 loc) · 831 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
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
const yaml = require('yaml');
const fs = require('fs');
const path = process.argv[2];
if (!path) {
console.error('missing path');
process.exit(1);
}
const segments = path.split('.');
function printProperty(file) {
let valuesYaml;
try {
valuesYaml = fs.readFileSync(file, 'utf-8');
} catch(error) {
return false;
}
const values = yaml.parse(valuesYaml);
let o = values;
for (let segment of segments) {
o = o[segment];
if (typeof o === "undefined" || o === null) return false;
}
if (typeof o === "object") {
console.log(JSON.stringify(o));
} else {
console.log(o);
}
return true;
}
printProperty('.values.yaml') || printProperty('values.yaml') || printProperty('chart/values.yaml') || process.exit(1);