helm install|upgrade [NAME] CHART; helm template [NAME] CHART as a source. */
| 1625 | |
| 1626 | /* helm install|upgrade [NAME] CHART; helm template [NAME] CHART as a source. */ |
| 1627 | static void sh_helm(sh_t *s, TSNode cmd, const sh_argv_t *a, int prog, sh_src_t *out) { |
| 1628 | const char *verb = NULL; |
| 1629 | int pos[PAIR_LEN] = {0, 0}; |
| 1630 | int npos = 0; |
| 1631 | int first_split = SH_NO_DEPTH; /* an unknown unquoted word: maybe several */ |
| 1632 | bool gen = false; |
| 1633 | for (int i = prog + SKIP_ONE; i < a->n; i++) { |
| 1634 | const char *w = a->v[i]; |
| 1635 | if (w && w[0] == '-') { |
| 1636 | gen = gen || strcmp(w, "--generate-name") == 0 || strcmp(w, "-g") == 0; |
| 1637 | if (sh_in(w, SH_HELM_VALUED) && !strchr(w, '=')) { |
| 1638 | i++; |
| 1639 | } |
| 1640 | continue; |
| 1641 | } |
| 1642 | if (!verb) { |
| 1643 | if (!w) { |
| 1644 | return; |
| 1645 | } |
| 1646 | verb = w; |
| 1647 | continue; |
| 1648 | } |
| 1649 | if (!w && a->split[i] && first_split == SH_NO_DEPTH) { |
| 1650 | first_split = npos; |
| 1651 | } |
| 1652 | if (npos < PAIR_LEN) { |
| 1653 | pos[npos] = i; |
| 1654 | } |
| 1655 | npos++; |
| 1656 | } |
| 1657 | if (!verb) { |
| 1658 | return; |
| 1659 | } |
| 1660 | if (strcmp(verb, "install") == 0 || strcmp(verb, "upgrade") == 0) { |
| 1661 | int at = gen ? 0 : SKIP_ONE; |
| 1662 | if (npos > at && (first_split == SH_NO_DEPTH || first_split > at)) { |
| 1663 | sh_chart(s, cmd, a->v[pos[at]]); |
| 1664 | } |
| 1665 | } else if (strcmp(verb, "template") == 0 && npos > 0 && |
| 1666 | (first_split == SH_NO_DEPTH || first_split > SKIP_ONE)) { |
| 1667 | int at = npos >= PAIR_LEN ? SKIP_ONE : 0; |
| 1668 | *out = (sh_src_t){SH_SRC_CHART, a->v[pos[at]], "helm"}; |
| 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | /* What a `kubectl apply -f -` reading the pipe deploys. */ |
| 1673 | static void sh_deploy_src(sh_t *s, TSNode cmd, const sh_src_t *src) { |
no test coverage detected