| 12 | const segments = path.split('.'); |
| 13 | |
| 14 | function printProperty(file) { |
| 15 | let valuesYaml; |
| 16 | try { |
| 17 | valuesYaml = fs.readFileSync(file, 'utf-8'); |
| 18 | } catch(error) { |
| 19 | return false; |
| 20 | } |
| 21 | const values = yaml.parse(valuesYaml); |
| 22 | |
| 23 | let o = values; |
| 24 | for (let segment of segments) { |
| 25 | o = o[segment]; |
| 26 | if (typeof o === "undefined" || o === null) return false; |
| 27 | } |
| 28 | |
| 29 | if (typeof o === "object") { |
| 30 | console.log(JSON.stringify(o)); |
| 31 | } else { |
| 32 | console.log(o); |
| 33 | } |
| 34 | |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | printProperty('.values.yaml') || printProperty('values.yaml') || printProperty('chart/values.yaml') || process.exit(1); |