Where an env[] item's value comes from: "value", or its valueFrom kind (configMapKeyRef, secretKeyRef, fieldRef, resourceFieldRef, fileKeyRef; "valueFrom" for any other). The value itself is never read.
| 1402 | // (configMapKeyRef, secretKeyRef, fieldRef, resourceFieldRef, fileKeyRef; |
| 1403 | // "valueFrom" for any other). The value itself is never read. |
| 1404 | static const char *k8s_env_source(k8s_walk_t *w, TSNode item) { |
| 1405 | static const char *const KINDS[] = {"configMapKeyRef", "secretKeyRef", "fieldRef", |
| 1406 | "resourceFieldRef", "fileKeyRef"}; |
| 1407 | k8s_kids_t pairs = k8s_kids(item); |
| 1408 | TSNode pair; |
| 1409 | while (k8s_kid(&pairs, true, &pair)) { |
| 1410 | if (!k8s_is_pair(pair)) { |
| 1411 | continue; |
| 1412 | } |
| 1413 | TSNode key = ts_node_named_child(pair, 0); |
| 1414 | const char *k = |
| 1415 | ts_node_is_null(key) ? NULL : get_scalar_text(w->ctx->arena, key, w->ctx->source); |
| 1416 | if (!k || strcmp(k, "valueFrom") != 0) { |
| 1417 | continue; |
| 1418 | } |
| 1419 | k8s_kids_done(&pairs); |
| 1420 | TSNode from = k8s_unwrap(unwrap_pair_value(pair)); |
| 1421 | k8s_kids_t kinds = k8s_kids(from); |
| 1422 | TSNode kp; |
| 1423 | const char *kind = NULL; |
| 1424 | while (k8s_kid(&kinds, true, &kp)) { |
| 1425 | TSNode kk = k8s_is_pair(kp) ? ts_node_named_child(kp, 0) : (TSNode){0}; |
| 1426 | const char *s = |
| 1427 | ts_node_is_null(kk) ? NULL : get_scalar_text(w->ctx->arena, kk, w->ctx->source); |
| 1428 | if (s && !kind) { |
| 1429 | kind = s; |
| 1430 | } |
| 1431 | } |
| 1432 | for (size_t i = 0; kind && i < sizeof(KINDS) / sizeof(KINDS[0]); i++) { |
| 1433 | if (strcmp(kind, KINDS[i]) == 0) { |
| 1434 | return KINDS[i]; |
| 1435 | } |
| 1436 | } |
| 1437 | return "valueFrom"; |
| 1438 | } |
| 1439 | return "value"; |
| 1440 | } |
| 1441 | |
| 1442 | // The Service a container's literal env value addresses (`host:port`, a URL, |
| 1443 | // `<svc>.<ns>.svc...`, a bare name on an address key): a CONNECTS_TO |
no test coverage detected