Every edge from a compose service as " -> (TYPE * via|ref)", sorted: an Image by repository, a Module by path. */
| 2221 | /* Every edge from a compose service as "<service> -> <target> (TYPE |
| 2222 | * via|ref)", sorted: an Image by repository, a Module by path. */ |
| 2223 | static char *gpf_compose(const GpfFile *files, int nfiles) { |
| 2224 | GpfProj lp; |
| 2225 | cbm_store_t *store = gpf_index_files(&lp, files, nfiles); |
| 2226 | char *out = NULL; |
| 2227 | if (store) { |
| 2228 | sqlite3_stmt *st = NULL; |
| 2229 | const char *sql = |
| 2230 | "SELECT coalesce(group_concat(x, char(10)), '') FROM (SELECT s.name || ' -> ' || " |
| 2231 | "CASE t.label WHEN 'Image' THEN 'Image:' || t.name WHEN 'Module' THEN 'Module:' || " |
| 2232 | "t.file_path ELSE t.name END || ' (' || e.type || ' ' || " |
| 2233 | "coalesce(json_extract(e.properties,'$.via'), json_extract(e.properties,'$.ref')) || " |
| 2234 | "')' AS x FROM edges e JOIN nodes s ON s.id=e.source_id JOIN nodes t ON " |
| 2235 | "t.id=e.target_id WHERE e.project=?1 AND s.label='Resource' AND " |
| 2236 | "json_extract(s.properties,'$.ecosystem')='compose' ORDER BY x)"; |
| 2237 | if (sqlite3_prepare_v2(cbm_store_get_db(store), sql, -1, &st, NULL) == SQLITE_OK) { |
| 2238 | sqlite3_bind_text(st, 1, lp.project, -1, SQLITE_STATIC); |
| 2239 | if (sqlite3_step(st) == SQLITE_ROW) { |
| 2240 | out = strdup((const char *)sqlite3_column_text(st, 0)); |
| 2241 | } |
| 2242 | } |
| 2243 | sqlite3_finalize(st); |
| 2244 | } |
| 2245 | gpf_cleanup(&lp, store); |
| 2246 | return out; |
| 2247 | } |
| 2248 | |
| 2249 | /* A compose service is a Resource {ecosystem:compose}: it DEPENDS_ON the |
| 2250 | * services its depends_on (a list or a mapping) and links name, USAGE |
no test coverage detected