Deleting the only Dockerfile naming an image leaves no Image node behind; * the image another Dockerfile still names stays. `legacy`: through the * full-load route, else the closure-repair route. Returns the Image count * after the deletion, or -1; *route: the route taken. */
| 3875 | * full-load route, else the closure-repair route. Returns the Image count |
| 3876 | * after the deletion, or -1; *route: the route taken. */ |
| 3877 | static int incremental_dockerfile_delete(bool legacy, cbm_incremental_route_t *route) { |
| 3878 | char tmp[256]; |
| 3879 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_imagegc_XXXXXX"); |
| 3880 | if (!cbm_mkdtemp(tmp)) { |
| 3881 | return -1; |
| 3882 | } |
| 3883 | write_temp_file(tmp, "a/Dockerfile", |
| 3884 | "FROM alpine:3.20\nCOPY --from=docker.io/bitnami/kubectl:1.30 /k /k\n"); |
| 3885 | write_temp_file(tmp, "b/Dockerfile", "FROM alpine:3.19\n"); |
| 3886 | char db_path[512]; |
| 3887 | snprintf(db_path, sizeof(db_path), "%s/imagegc.db", tmp); |
| 3888 | static const char images[] = "SELECT COUNT(*) FROM nodes WHERE label='Image'"; |
| 3889 | int full = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, images) : -1; |
| 3890 | char path[512]; |
| 3891 | snprintf(path, sizeof(path), "%s/a/Dockerfile", tmp); |
| 3892 | (void)remove(path); |
| 3893 | #if defined(CBM_INCREMENTAL_TEST_API) && CBM_INCREMENTAL_TEST_API |
| 3894 | if (legacy) { |
| 3895 | cbm_pipeline_incremental_test_force_legacy_partial_once(); |
| 3896 | } |
| 3897 | #else |
| 3898 | (void)legacy; |
| 3899 | #endif |
| 3900 | int after = k8s_inc_index(tmp, db_path) == 0 ? k8s_inc_count(db_path, images) : -1; |
| 3901 | *route = cbm_pipeline_incremental_test_last_route(); |
| 3902 | th_rmtree(tmp); |
| 3903 | return full == 2 ? after : -1; |
| 3904 | } |
| 3905 | |
| 3906 | /* Editing one Dockerfile keeps every image's build edge -- also the one |
| 3907 | * between nodes that both pre-existed (Image -> the unchanged Dockerfile), |
no test coverage detected