| 45 | // [START cloudrun_system_package_exec] |
| 46 | // Generate a diagram based on a graphviz DOT diagram description. |
| 47 | const createDiagram = dot => { |
| 48 | if (!dot) { |
| 49 | throw new Error('syntax: no graphviz definition provided'); |
| 50 | } |
| 51 | |
| 52 | // Adds a watermark to the dot graphic. |
| 53 | const dotFlags = [ |
| 54 | '-Glabel="Made on Cloud Run"', |
| 55 | '-Gfontsize=10', |
| 56 | '-Glabeljust=right', |
| 57 | '-Glabelloc=bottom', |
| 58 | '-Gfontcolor=gray', |
| 59 | ].join(' '); |
| 60 | |
| 61 | const image = execSync(`/usr/bin/dot ${dotFlags} -Tpng`, { |
| 62 | input: dot, |
| 63 | }); |
| 64 | return image; |
| 65 | }; |
| 66 | // [END cloudrun_system_package_exec] |
| 67 | |
| 68 | module.exports = app; |