MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sh_kubectl

Function sh_kubectl

src/pipeline/pass_shell.c:1562–1590  ·  view source on GitHub ↗

kubectl: apply / create / replace -f / -k, or `kubectl kustomize D` as a * pipe's source. */

Source from the content-addressed store, hash-verified

1560/* kubectl: apply / create / replace -f / -k, or `kubectl kustomize D` as a
1561 * pipe's source. */
1562static void sh_kubectl(sh_t *s, TSNode cmd, const sh_argv_t *a, int prog, const sh_src_t *in,
1563 sh_src_t *out) {
1564 sh_kubectl_t k = {0};
1565 sh_kubectl_parse(a, prog + SKIP_ONE, &k);
1566 const char *verb = k.verb >= 0 ? a->v[k.verb] : NULL;
1567 if (sh_eq(verb, "kustomize")) {
1568 const char *d = sh_first_operand(a, k.verb + SKIP_ONE);
1569 *out = (sh_src_t){SH_SRC_KUST, d ? d : ".", "kustomize"};
1570 } else if (sh_eq(verb, "apply") || sh_eq(verb, "create") || sh_eq(verb, "replace")) {
1571 sh_find_t f = {k.recursive, NULL, SH_NO_DEPTH};
1572 for (int i = 0; i < k.nfiles; i++) {
1573 if (sh_eq(k.files[i], "-")) {
1574 sh_deploy_src(s, cmd, in);
1575 continue;
1576 }
1577 sh_targets_t ts = {0};
1578 sh_targets_of(s, k.files[i], sh_t_files, &f, &ts);
1579 sh_hit_all(s, cmd, "kubectl", &ts, false);
1580 cbm_free(CBM_MEM_CLASS_OTHER, ts.items);
1581 }
1582 for (int i = 0; i < k.nkusts; i++) {
1583 sh_targets_t ts = {0};
1584 sh_targets_of(s, k.kusts[i], sh_t_kust, &f, &ts);
1585 sh_hit_all(s, cmd, "kubectl", &ts, false);
1586 cbm_free(CBM_MEM_CLASS_OTHER, ts.items);
1587 }
1588 }
1589 sh_kubectl_free(&k);
1590}
1591
1592/* The chart a helm word names: a chart dir, else an external chart. */
1593static void sh_chart(sh_t *s, TSNode cmd, const char *v) {

Callers 1

sh_deploy_commandFunction · 0.85

Calls 8

sh_kubectl_parseFunction · 0.85
sh_eqFunction · 0.85
sh_first_operandFunction · 0.85
sh_deploy_srcFunction · 0.85
sh_targets_ofFunction · 0.85
sh_hit_allFunction · 0.85
cbm_freeFunction · 0.85
sh_kubectl_freeFunction · 0.85

Tested by

no test coverage detected