kubectl -f PATH: the manifest, a directory's manifests, a glob's. */
| 1186 | |
| 1187 | /* kubectl -f PATH: the manifest, a directory's manifests, a glob's. */ |
| 1188 | static int sh_t_files(sh_t *s, const char *path, const sh_find_t *f, sh_targets_t *out) { |
| 1189 | const sh_paths_t *m = &s->ix->manifests; |
| 1190 | char key[CBM_SZ_4K]; |
| 1191 | int lo = 0; |
| 1192 | int hi = 0; |
| 1193 | int added = 0; |
| 1194 | if (strpbrk(path, "*?[")) { |
| 1195 | if (strchr(path, '[')) { |
| 1196 | return 0; |
| 1197 | } |
| 1198 | const char *g = strpbrk(path, "*?"); |
| 1199 | size_t dl = (size_t)(g - path); |
| 1200 | while (dl > 0 && path[dl - SKIP_ONE] != '/') { |
| 1201 | dl--; |
| 1202 | } |
| 1203 | char dir[CBM_SZ_4K]; |
| 1204 | snprintf(dir, sizeof(dir), "%.*s", (int)(dl ? dl - SKIP_ONE : 0), path); |
| 1205 | sh_range(m, dir, key, sizeof(key), &lo, &hi); |
| 1206 | for (int i = lo; i < hi; i++) { |
| 1207 | atomic_fetch_add_explicit(&g_sh_candidates, SKIP_ONE, memory_order_relaxed); |
| 1208 | if (sh_glob_path(path, m->items[i])) { |
| 1209 | added += sh_add_manifest(s, m->items[i], out); |
| 1210 | } |
| 1211 | } |
| 1212 | return added; |
| 1213 | } |
| 1214 | if (sh_paths_has(m, path)) { |
| 1215 | return sh_add_manifest(s, path, out); |
| 1216 | } |
| 1217 | sh_range(m, path, key, sizeof(key), &lo, &hi); |
| 1218 | size_t kl = strlen(key); |
| 1219 | for (int i = lo; i < hi; i++) { |
| 1220 | atomic_fetch_add_explicit(&g_sh_candidates, SKIP_ONE, memory_order_relaxed); |
| 1221 | if (f->recursive || !strchr(m->items[i] + kl, '/')) { |
| 1222 | added += sh_add_manifest(s, m->items[i], out); |
| 1223 | } |
| 1224 | } |
| 1225 | return added; |
| 1226 | } |
| 1227 | |
| 1228 | /* find DIR -name G: DIR's manifests (to -maxdepth) whose name matches. */ |
| 1229 | static int sh_t_found(sh_t *s, const char *dir, const sh_find_t *f, sh_targets_t *out) { |
nothing calls this directly
no test coverage detected