Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
feat(infra): an object a kustomization renames has a variant Resource
Martin Vogel166962619d28
diff --git a/README.md b/README.mdindex 45e61a46d..f99cd963a 100644--- a/README.md+++ b/README.md@@ -256,6 +256,7 @@ The install script placed beside the binary is **reported, not deleted** — uni- `DEPENDS_ON` — a Helm chart to the charts it declares (the local chart for a resolvable `file://` repository, otherwise an external `Chart`; the edge keeps `repository`), and a `go.mod` / `requirements.txt` file to an external `Package`; a Dockerfile to the `Image`s it builds on (`via: from`, `copy-from`); an `Image` to the Dockerfile it is built from (`via: build`; `tool`: `skaffold`, `compose`, `docker-build` for `docker` / `podman` / `nerdctl` / `buildah` build commands in scripts, Make and CI); a compose service to the services its `depends_on` / `links` name- `CONFIGURES` — code reading an environment variable to the shared `EnvVar` of that name (`strategy: env_access`); a Kubernetes container, compose service or Dockerfile (`ENV` of the image) setting one to that container's own `EnvVar` (`strategy: env_set`, with `source`: `value`, `configMapKeyRef`, `secretKeyRef`, `fieldRef`, ..., `compose`, `dockerfile` — values are never stored); and that container's `EnvVar` to the code reading the name inside the files its image is built from (`strategy: env_read`, with `dockerfile`) — the image's files are the sources its Dockerfile's `COPY` / `ADD` put into it, less the context's `.dockerignore`- `OVERRIDE` with `via: patch` — a Kustomize patch to each object of its kustomization's build it changes (child → base): a patch file's documents to the object of the same kind and name; an inline patch (from the kustomization) or a JSON6902 operation file to what its `target` selects (group, version, kind, name, namespace, label selector); a component's in the build of each kustomization including it. The edge keeps `kustomization`, `patch` and `line`; a patch file is an `IMPORTS` (`local_name: patches`) of its kustomization, never a member of the build+- `OVERRIDE` with `via: namePrefix` / `nameSuffix` — an object a kustomization renames, from its variant: a `Resource` named with the deployed name (`capi-` + `controller-manager`; the prefixes of nested kustomizations outermost first, suffixes innermost first) in the namespace that build gives it, `ecosystem: kustomize`, which the kustomization's file `DEFINES`. CRDs, Namespaces and API services keep their names, as kustomize does. The edge keeps `kustomization` and `line`- `USAGE` with `via: terraform` — a Terraform / OpenTofu reference (`var.X`, `local.X`, `module.X`, `data.T.N`, `T.N`) from the top-level block holding it to the block of its module — the `.tf` / `.tofu` files of its directory — that declares it (a `locals` entry: its `locals` block); an entry of the block's `depends_on` list is a `DEPENDS_ON` instead. The edge keeps `ref` (`var`, `local`, `module`, `data`, `resource`) and `line`; a name only mentioned in string text is no reference. A module call with a local source (`module "net" { source = "./modules/net" }`) `IMPORTS` (`local_name`: the module's name) the `Folder` of that directory (the root directory: the `Project`), and `module.net.id` (also `module.net[0].id`, `module.net[*].id`) `USAGE`s (`ref: output`) the `output "id"` there, beside `module.net`- `OVERRIDE` with `via: tfvars` — a `.tfvars` assignment to a variable the module of its own directory declares, from the file's `Variable` to that `variable` block (the edge keeps `line`); a `.tfvars` file whose own directory declares none of its names sets the nearest ancestor module's that does, the edge marked `inferred` (such a file is applied by a `-var-file` the repository does not state)- Terragrunt (`via: terragrunt`) — a unit (`terragrunt.hcl`), evaluated in its own context: an `include` `IMPORTS` (`local_name`) the file its `path` names; a `read_terragrunt_config` `IMPORTS` (`read`: the file holding the call) the file it names, from the block holding the call or, for a call in an included file, from the unit's `include` block that brings it in; a `dependency` `DEPENDS_ON` the other unit; a local `terraform` `source` `IMPORTS` its `Folder`. Paths may use `find_in_parent_folders`, `dirname` and `get_terragrunt_dir`; anything else is unknown and links nothingdiff --git a/src/pipeline/pass_k8s.c b/src/pipeline/pass_k8s.cindex a8702948d..67bbb37f8 100644--- a/src/pipeline/pass_k8s.c+++ b/src/pipeline/pass_k8s.c@@ -733,6 +733,9 @@ typedef struct {int file_cap;bool referenced; /* included by another kustomization */bool component; /* `kind: Component`: patches the build including it */+ char *prefix; /* its `namePrefix:`, NULL when unset */+ char *suffix; /* its `nameSuffix:`, NULL when unset */+ int rename_line; /* the line of its namePrefix, else nameSuffix; 0: neither */} k8s_kust_t;typedef struct {@@ -776,25 +779,35 @@ static bool k8s_grow(void **items, int *cap, int count, size_t elem) {return true;}-/* The value of a kustomization's top-level `key:` line into `val`; false- * when it has none, or an empty one. */-static bool k8s_kustomize_top(const char *source, const char *key, char *val, size_t val_sz) {+/* The value of a kustomization's top-level `key:` line into `val`, its+ * 1-based line into `*line` (when not NULL); false when it has none, or an+ * empty one. */+static bool k8s_kustomize_top_at(const char *source, const char *key, char *val, size_t val_sz,+ int *line) {char head[CBM_SZ_64];int hl = snprintf(head, sizeof(head), "%s:", key);- for (const char *p = source; p && *p && hl > 0;) {+ int at = SKIP_ONE;+ for (const char *p = source; p && *p && hl > 0; at++) {const char *eol = strchr(p, '\n');size_t len = eol ? (size_t)(eol - p) : strlen(p);if (strncmp(p, head, (size_t)hl) == 0) {- char line[CBM_SZ_512];- snprintf(line, sizeof(line), "%.*s", (int)len, p);+ char text[CBM_SZ_512];+ snprintf(text, sizeof(text), "%.*s", (int)len, p);char k[CBM_SZ_64];- return k8s_split_kv(line, k, sizeof(k), val, val_sz) && val[0];+ if (line) {+ *line = at;+ }+ return k8s_split_kv(text, k, sizeof(k), val, val_sz) && val[0];}p = eol ? eol + SKIP_ONE : NULL;}return false;}+static bool k8s_kustomize_top(const char *source, const char *key, char *val, size_t val_sz) {+ return k8s_kustomize_top_at(source, key, val, val_sz, NULL);+}+/* The top-level `namespace:` of a kustomization, NULL when it sets none. */static char *k8s_kustomize_namespace(const char *source) {char val[K8S_LABEL_LEN];@@ -810,19 +823,39 @@ static bool k8s_kustomize_component(const char *source) {return k8s_kustomize_top(source, "kind", val, sizeof(val)) && strcmp(val, "Component") == 0;}-static void k8s_kusts_push(k8s_kusts_t *ks, const char *path, char *ns, bool component) {+/* A kustomization's `namePrefix:` / `nameSuffix:` (`key`), NULL when it+ * sets none -- or one with `/` or a blank in it, which is no name part; its+ * line into `*line` when that is still 0. */+static char *k8s_kustomize_name_part(const char *source, const char *key, int *line) {+ char val[K8S_LABEL_LEN];+ int at = 0;+ if (!k8s_kustomize_top_at(source, key, val, sizeof(val), &at) || strpbrk(val, "/ \t")) {+ return NULL;+ }+ if (*line == 0) {+ *line = at;+ }+ return cbm_mem_strdup(CBM_MEM_CLASS_OTHER, val);+}++static void k8s_kusts_push(k8s_kusts_t *ks, const char *path, const char *source) {if (!k8s_grow((void **)&ks->items, &ks->cap, ks->count, sizeof(*ks->items))) {- cbm_free(CBM_MEM_CLASS_OTHER, ns);return;}- ks->items[ks->count++] = (k8s_kust_t){- .path = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, path), .ns = ns, .component = component};+ k8s_kust_t k = {.path = cbm_mem_strdup(CBM_MEM_CLASS_OTHER, path),+ .ns = k8s_kustomize_namespace(source),+ .component = k8s_kustomize_component(source)};+ k.prefix = k8s_kustomize_name_part(source, "namePrefix", &k.rename_line);+ k.suffix = k8s_kustomize_name_part(source, "nameSuffix", &k.rename_line);+ ks->items[ks->count++] = k;}static void k8s_kusts_free(k8s_kusts_t *ks) {for (int i = 0; i < ks->count; i++) {cbm_free(CBM_MEM_CLASS_OTHER, ks->items[i].path);cbm_free(CBM_MEM_CLASS_OTHER, ks->items[i].ns);+ cbm_free(CBM_MEM_CLASS_OTHER, ks->items[i].prefix);+ cbm_free(CBM_MEM_CLASS_OTHER, ks->items[i].suffix);cbm_free(CBM_MEM_CLASS_OTHER, ks->items[i].kids);cbm_free(CBM_MEM_CLASS_OTHER, (void *)ks->items[i].files);}@@ -3960,6 +3993,174 @@ static void k8s_link_patches(cbm_pipeline_ctx_t *ctx, const k8s_kusts_t *ks, k8s}}+/* kustomize's prefix / suffix transformers leave these names alone+ * (api/internal/builtins/PrefixTransformer.go prefixFieldSpecsToSkip, the+ * same list in SuffixTransformer.go). */+static bool k8s_rename_skips(const char *group, const char *kind) {+ return strcmp(kind, "CustomResourceDefinition") == 0 || strcmp(kind, "Namespace") == 0 ||+ (strcmp(kind, "APIService") == 0 && strcmp(group, "apiregistration.k8s.io") == 0);+}++/* A kustomization on the way down a renaming build: the prefix and suffix+ * the levels above and its own put around its objects' names, and the+ * namespace the outermost level setting one gives them (NULL: their own). */+typedef struct {+ int kust;+ const char *ns;+ char pre[K8S_LABEL_LEN];+ char suf[K8S_LABEL_LEN];+} k8s_rename_frame_t;++/* The variant of object `obj` the renaming build of `root` deploys: a+ * Resource `Kind/<deployed name>` declared by the kustomization (`base`:+ * its File QN without `.__file__`), ecosystem kustomize; the kustomization+ * DEFINES it and it OVERRIDEs {via: namePrefix | nameSuffix, kustomization,+ * line} the object. */+static void k8s_rename_variant(cbm_pipeline_ctx_t *ctx, const k8s_kust_t *root, const char *base,+ int64_t kust_file, const k8s_rename_frame_t *f,+ const cbm_gbuf_node_t *obj) {+ char kind[K8S_LABEL_LEN];+ char group[K8S_LABEL_LEN];+ char version[K8S_LABEL_LEN];+ char declared[K8S_LABEL_LEN];+ const char *name = NULL;+ if (!k8s_kind_name(obj, kind, sizeof(kind), &name)) {+ return;+ }+ k8s_node_prop(obj, "group", group, sizeof(group));+ if (!group[0] || k8s_rename_skips(group, kind)) {+ return;+ }+ k8s_node_prop(obj, "version", version, sizeof(version));+ k8s_declared_ns(obj->qualified_name, declared, sizeof(declared));+ const char *ns = k8s_cluster_scoped(kind) || !f->ns ? declared : f->ns;+ char deployed[K8S_LABEL_LEN];+ int dl = snprintf(deployed, sizeof(deployed), "%s%s%s", f->pre, name, f->suf);+ char qn[CBM_SZ_2K];+ char rname[CBM_SZ_256];+ if (dl <= 0 || (size_t)dl >= sizeof(deployed) ||+ snprintf(qn, sizeof(qn), "%s::%s/%s/%s/%s", base, group, kind, ns[0] ? ns : "-",+ deployed) >= (int)sizeof(qn) ||+ snprintf(rname, sizeof(rname), "%s/%s", kind, deployed) >= (int)sizeof(rname)) {+ return;+ }+ char *props = k8s_resource_props(qn, NULL, version, NULL, "kustomize");+ int64_t id = props ? cbm_gbuf_upsert_node(ctx->gbuf, "Resource", rname, qn, root->path,+ root->rename_line, root->rename_line, props)+ : 0;+ cbm_free(CBM_MEM_CLASS_OTHER, props);+ if (id <= 0 || id == obj->id) {+ return;+ }+ if (kust_file > 0) {+ cbm_gbuf_insert_edge(ctx->gbuf, kust_file, id, "DEFINES", "{}");+ }+ char ek[CBM_SZ_2K];+ cbm_json_escape(ek, (int)sizeof(ek), root->path);+ char eprops[CBM_SZ_2K + CBM_SZ_256];+ snprintf(eprops, sizeof(eprops), "{\"via\":\"%s\",\"kustomization\":\"%s\",\"line\":%d}",+ root->prefix ? "namePrefix" : "nameSuffix", ek, root->rename_line);+ cbm_gbuf_insert_edge(ctx->gbuf, id, obj->id, "OVERRIDE", eprops);+}++/* Every object the build of renaming kustomization `root` reaches gets its+ * variant: down the kustomizations it includes, each level's prefix inside+ * the ones above, its namespace where none above sets one (a component's+ * own transforms are not followed). `by_file`: Resource ids by manifest. */+static void k8s_rename_build(cbm_pipeline_ctx_t *ctx, const k8s_kusts_t *ks, int root,+ CBMHashTable *by_file, int *seen, int mark) {+ static const char FILE_SUFFIX[] = ".__file__";+ const k8s_kust_t *r = &ks->items[root];+ const cbm_gbuf_node_t *kf = cbm_pipeline_file_node(ctx->gbuf, ctx->project_name, r->path);+ size_t ql = kf && kf->qualified_name ? strlen(kf->qualified_name) : 0;+ size_t sl = sizeof(FILE_SUFFIX) - SKIP_ONE;+ char base[CBM_SZ_1K];+ if (ql <= sl || strcmp(kf->qualified_name + ql - sl, FILE_SUFFIX) != 0 ||+ ql - sl >= sizeof(base)) {+ return;+ }+ snprintf(base, sizeof(base), "%.*s", (int)(ql - sl), kf->qualified_name);+ k8s_rename_frame_t *stack = NULL;+ int depth = 0;+ int cap = 0;+ if (!k8s_grow((void **)&stack, &cap, depth, sizeof(*stack))) {+ return;+ }+ stack[depth] = (k8s_rename_frame_t){.kust = root, .ns = r->ns};+ snprintf(stack[depth].pre, sizeof(stack[depth].pre), "%s", r->prefix ? r->prefix : "");+ snprintf(stack[depth].suf, sizeof(stack[depth].suf), "%s", r->suffix ? r->suffix : "");+ depth++;+ while (depth > 0) {+ k8s_rename_frame_t f = stack[--depth];+ if (seen[f.kust] == mark) {+ continue;+ }+ seen[f.kust] = mark;+ const k8s_kust_t *k = &ks->items[f.kust];+ for (int i = 0; i < k->file_n; i++) {+ const k8s_ids_t *objs = cbm_ht_get(by_file, k->files[i]);+ for (int o = 0; objs && o < objs->count; o++) {+ const cbm_gbuf_node_t *n = cbm_gbuf_find_by_id(ctx->gbuf, objs->items[o]);+ if (n) {+ k8s_rename_variant(ctx, r, base, kf->id, &f, n);+ }+ }+ }+ for (int i = 0; i < k->kid_n; i++) {+ const k8s_kust_t *kid = &ks->items[k->kids[i]];+ const char *kp = kid->component || !kid->prefix ? "" : kid->prefix;+ const char *kx = kid->component || !kid->suffix ? "" : kid->suffix;+ if (!k8s_grow((void **)&stack, &cap, depth, sizeof(*stack))) {+ break;+ }+ k8s_rename_frame_t *c = &stack[depth];+ *c = (k8s_rename_frame_t){.kust = k->kids[i],+ .ns = f.ns || kid->component ? f.ns : kid->ns};+ if (snprintf(c->pre, sizeof(c->pre), "%s%s", f.pre, kp) < (int)sizeof(c->pre) &&+ snprintf(c->suf, sizeof(c->suf), "%s%s", kx, f.suf) < (int)sizeof(c->suf)) {+ depth++;+ }+ }+ }+ cbm_free(CBM_MEM_CLASS_OTHER, stack);+}++/* Kustomize namePrefix / nameSuffix -> a variant Resource per object a+ * kustomization renames, with its deployed name, OVERRIDE -> the object.+ * Minted after the joins: references inside a build use the declared names+ * (kustomize rewrites them), so nothing joins a variant. */+static void k8s_link_renames(cbm_pipeline_ctx_t *ctx, const k8s_kusts_t *ks) {+ bool any = false;+ for (int i = 0; i < ks->count && !any; i++) {+ any = !ks->items[i].component && (ks->items[i].prefix || ks->items[i].suffix);+ }+ if (!any) {+ return;+ }+ CBMHashTable *by_file = cbm_ht_create(0);+ int *seen = cbm_calloc(CBM_MEM_CLASS_OTHER, (size_t)ks->count * sizeof(int));+ const cbm_gbuf_node_t **res = NULL;+ int res_n = 0;+ if (by_file && seen && cbm_gbuf_find_by_label(ctx->gbuf, "Resource", &res, &res_n) == 0) {+ for (int i = 0; i < res_n; i++) {+ if (res[i]->file_path) {+ k8s_index_add(by_file, res[i]->file_path, res[i]->id);+ }+ }+ int mark = 0;+ for (int i = 0; i < ks->count; i++) {+ if (!ks->items[i].component && (ks->items[i].prefix || ks->items[i].suffix)) {+ k8s_rename_build(ctx, ks, i, by_file, seen, ++mark);+ }+ }+ }+ cbm_free(CBM_MEM_CLASS_OTHER, seen);+ if (by_file) {+ cbm_ht_foreach(by_file, k8s_free_ids_entry, NULL);+ cbm_ht_free(by_file);+ }+}+static void k8s_link_deploys(cbm_pipeline_ctx_t *ctx, k8s_kusts_t *ks, k8s_bundles_t *b,const k8s_facts_t *f) {if (f->dep_n == 0 && f->hr_n == 0 && f->src_n == 0 && f->kchart_n == 0) {@@ -4114,8 +4315,7 @@ int cbm_pipeline_pass_k8s(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,helm_count++;break;case K8S_KUSTOMIZE:- k8s_kusts_push(&kusts, rel, k8s_kustomize_namespace(p->source),- k8s_kustomize_component(p->source));+ k8s_kusts_push(&kusts, rel, p->source);k8s_kustomize_keep(&facts, rel, p->res);break;case K8S_MANIFEST:@@ -4160,6 +4360,7 @@ int cbm_pipeline_pass_k8s(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files,k8s_link_images(ctx, &facts);k8s_link_envs(ctx, &facts);k8s_link_patches(ctx, &kusts, &facts);+ k8s_link_renames(ctx, &kusts);k8s_facts_free(&facts);k8s_records_free(&recs);/* Link `file://` chart dependencies now that every Chart.yaml is read,diff --git a/src/pipeline/pipeline_internal.h b/src/pipeline/pipeline_internal.hindex 22bcc85c5..207ba9382 100644--- a/src/pipeline/pipeline_internal.h+++ b/src/pipeline/pipeline_internal.h@@ -1521,7 +1521,10 @@ int cbm_pipeline_build_fresh_semantic_manifest(cbm_pipeline_t *p, const char *pr* A kustomize patch OVERRIDEs the objects of its build it changes, its* file an IMPORTS of the kustomization; a Resource keeps the version of* its apiVersion and its labels; a kustomization DEPLOYS the charts it inflates- * (helmCharts) (extract_k8s.c, pass_k8s.c). A Terraform reference+ * (helmCharts); an object a namePrefix / nameSuffix renames has a+ * variant Resource {ecosystem:kustomize} with its deployed name, which+ * OVERRIDEs {via:namePrefix|nameSuffix} it (extract_k8s.c,+ * pass_k8s.c). A Terraform reference* USAGEs {ref, via:terraform}, from its block, the block of its module* (directory) declaring it (one in depends_on: DEPENDS_ON), instead of* the generic name matcher's USAGE / CALLS; a bare block label namesdiff --git a/tests/test_grammar_probe_f.c b/tests/test_grammar_probe_f.cindex 9e0af6a09..2e9d7e4bc 100644--- a/tests/test_grammar_probe_f.c+++ b/tests/test_grammar_probe_f.c@@ -3276,6 +3276,103 @@ TEST(probe_terraform_kubernetes_objects_are_resources) {PASS();}+/* Every kustomize variant as "<variant> <QN key> <- <base file>:<base>+ * via=<via> kust=<kustomization>:<line>", then "variants <n> defined <m>":+ * the Resources marked ecosystem kustomize, and the DEFINES edges into+ * them. */+static char *gpf_kust_variants(const GpfFile *files, int nfiles) {+ GpfProj lp;+ cbm_store_t *store = gpf_index_files(&lp, files, nfiles);+ char *out = NULL;+ if (store) {+ sqlite3_stmt *st = NULL;+ const char *sql =+ "SELECT coalesce((SELECT group_concat(x, char(10)) FROM (SELECT v.name || ' ' || "+ "substr(v.qualified_name, instr(v.qualified_name, '::') + 2) || ' <- ' || "+ "b.file_path || ':' || b.name || ' via=' || json_extract(e.properties,'$.via') || "+ "' kust=' || json_extract(e.properties,'$.kustomization') || ':' || "+ "json_extract(e.properties,'$.line') AS x FROM edges e JOIN nodes v ON "+ "v.id=e.source_id JOIN nodes b ON b.id=e.target_id WHERE e.project=?1 AND "+ "e.type='OVERRIDE' AND json_extract(v.properties,'$.ecosystem')='kustomize' ORDER BY "+ "x)), '') || char(10) || 'variants ' || (SELECT COUNT(*) FROM nodes WHERE project=?1 "+ "AND label='Resource' AND json_extract(properties,'$.ecosystem')='kustomize') || "+ "' defined ' || (SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id JOIN "+ "nodes t ON t.id=e.target_id WHERE e.project=?1 AND e.type='DEFINES' AND "+ "s.label='File' AND json_extract(t.properties,'$.ecosystem')='kustomize')";+ if (sqlite3_prepare_v2(cbm_store_get_db(store), sql, -1, &st, NULL) == SQLITE_OK) {+ sqlite3_bind_text(st, 1, lp.project, -1, SQLITE_STATIC);+ if (sqlite3_step(st) == SQLITE_ROW) {+ out = strdup((const char *)sqlite3_column_text(st, 0));+ }+ }+ sqlite3_finalize(st);+ }+ gpf_cleanup(&lp, store);+ return out;+}++/* A kustomization's namePrefix / nameSuffix deploys its objects under other+ * names: each renamed object gets a variant Resource with the deployed name+ * (ecosystem kustomize), which the kustomization's File DEFINES and which+ * OVERRIDEs {via: namePrefix | nameSuffix, kustomization, line} the object.+ * Prefixes compose down the build (outer first), as do suffixes (inner+ * first); the outermost namespace wins; a cluster-scoped kind keeps its+ * own (none); CRDs, Namespaces and apiregistration APIServices keep their+ * names (kustomize's skip list) and get none; a prefix with a `/` is no+ * name part and renames nothing. */+TEST(probe_kustomize_name_prefix_makes_variants) {+ static const GpfFile files[] = {+ {"base/kustomization.yaml",+ "namespace: system\nnamePrefix: b-\nresources:\n- app.yaml\n- crd.yaml\n- ns.yaml\n"+ "- apisvc.yaml\n- role.yaml\n"},+ {"base/app.yaml",+ "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: web\n namespace: system\n"+ "---\napiVersion: v1\nkind: Service\nmetadata:\n name: web\n namespace: system\n"},+ {"base/crd.yaml",+ "apiVersion: apiextensions.k8s.io/v1\nkind: CustomResourceDefinition\nmetadata:\n"+ " name: widgets.example.com\n"},+ {"base/ns.yaml", "apiVersion: v1\nkind: Namespace\nmetadata:\n name: system\n"},+ {"base/apisvc.yaml",+ "apiVersion: apiregistration.k8s.io/v1\nkind: APIService\nmetadata:\n"+ " name: v1.example.com\n"},+ {"base/role.yaml",+ "apiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRole\nmetadata:\n"+ " name: reader\n"},+ {"overlay/kustomization.yaml",+ "namespace: prod\nnamePrefix: p-\nnameSuffix: -x\nresources:\n- ../base\n"},+ {"suffixed/kustomization.yaml", "nameSuffix: -s\nresources:\n- ../base\n"},+ {"slashed/kustomization.yaml", "namePrefix: x/\nresources:\n- ../base\n"}};+ int n = (int)(sizeof(files) / sizeof(files[0]));+ char *got = gpf_kust_variants(files, n);+ static const char want[] =+ "ClusterRole/b-reader rbac.authorization.k8s.io/ClusterRole/-/b-reader <- "+ "base/role.yaml:ClusterRole/reader via=namePrefix kust=base/kustomization.yaml:2\n"+ "ClusterRole/b-reader-s rbac.authorization.k8s.io/ClusterRole/-/b-reader-s <- "+ "base/role.yaml:ClusterRole/reader via=nameSuffix kust=suffixed/kustomization.yaml:1\n"+ "ClusterRole/p-b-reader-x rbac.authorization.k8s.io/ClusterRole/-/p-b-reader-x <- "+ "base/role.yaml:ClusterRole/reader via=namePrefix kust=overlay/kustomization.yaml:2\n"+ "Deployment/b-web apps/Deployment/system/b-web <- base/app.yaml:Deployment/web "+ "via=namePrefix kust=base/kustomization.yaml:2\n"+ "Deployment/b-web-s apps/Deployment/system/b-web-s <- base/app.yaml:Deployment/web "+ "via=nameSuffix kust=suffixed/kustomization.yaml:1\n"+ "Deployment/p-b-web-x apps/Deployment/prod/p-b-web-x <- base/app.yaml:Deployment/web "+ "via=namePrefix kust=overlay/kustomization.yaml:2\n"+ "Service/b-web core/Service/system/b-web <- base/app.yaml:Service/web via=namePrefix "+ "kust=base/kustomization.yaml:2\n"+ "Service/b-web-s core/Service/system/b-web-s <- base/app.yaml:Service/web "+ "via=nameSuffix kust=suffixed/kustomization.yaml:1\n"+ "Service/p-b-web-x core/Service/prod/p-b-web-x <- base/app.yaml:Service/web "+ "via=namePrefix kust=overlay/kustomization.yaml:2\n"+ "variants 9 defined 9";+ if (!got || strcmp(got, want) != 0) {+ fprintf(stderr, "kustomize variants got:\n%s\nwant:\n%s\n", got ? got : "(null)", want);+ free(got);+ FAIL("kustomize variants");+ }+ free(got);+ PASS();+}+/* Every script HTTP_CALLS edge as "<source file> <route QN>", then a line* "edgeless routes <n>": the Route nodes no edge touches. */static char *gpf_script_http(const GpfFile *files, int nfiles) {@@ -5720,6 +5817,7 @@ SUITE(grammar_probe_f) {RUN_TEST(probe_terragrunt_units_compose_their_files);RUN_TEST(probe_ansible_files_import_what_they_name);RUN_TEST(probe_terraform_kubernetes_objects_are_resources);+ RUN_TEST(probe_kustomize_name_prefix_makes_variants);RUN_TEST(probe_image_hub_splits_by_component);RUN_TEST(probe_gitops_objects_deploy_their_units);RUN_TEST(probe_shell_kubectl_deploys_what_it_applies);