@intentius/chant-lexicon-k8s 0.124.97 → 0.124.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/application-paths.d.ts +4 -0
  2. package/dist/application-paths.d.ts.map +1 -0
  3. package/dist/application-paths.js +95 -0
  4. package/dist/application-set.d.ts +46 -0
  5. package/dist/application-set.d.ts.map +1 -0
  6. package/dist/application-set.js +303 -0
  7. package/dist/cluster-secret.d.ts +36 -0
  8. package/dist/cluster-secret.d.ts.map +1 -0
  9. package/dist/cluster-secret.js +55 -0
  10. package/dist/components/kustomize-apply.d.ts +6 -0
  11. package/dist/components/kustomize-apply.d.ts.map +1 -1
  12. package/dist/components/kustomize-apply.js +1 -1
  13. package/dist/config-schema.d.ts +8 -0
  14. package/dist/config-schema.d.ts.map +1 -1
  15. package/dist/config-schema.js +6 -2
  16. package/dist/config.d.ts +26 -3
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/helm-references.d.ts +113 -0
  19. package/dist/helm-references.d.ts.map +1 -0
  20. package/dist/helm-references.js +389 -0
  21. package/dist/import/generator.d.ts +11 -2
  22. package/dist/import/generator.d.ts.map +1 -1
  23. package/dist/import/generator.js +37 -55
  24. package/dist/import/parser.d.ts.map +1 -1
  25. package/dist/import/parser.js +34 -5
  26. package/dist/import/typed-classes.d.ts +57 -0
  27. package/dist/import/typed-classes.d.ts.map +1 -0
  28. package/dist/import/typed-classes.js +126 -0
  29. package/dist/integrity.json +41 -41
  30. package/dist/kustomize/render.d.ts +41 -2
  31. package/dist/kustomize/render.d.ts.map +1 -1
  32. package/dist/kustomize/render.js +114 -7
  33. package/dist/kustomize/root.d.ts +3 -3
  34. package/dist/kustomize/root.d.ts.map +1 -1
  35. package/dist/kustomize/root.js +6 -1
  36. package/dist/lint/post-synth/argo-helpers.d.ts +3 -0
  37. package/dist/lint/post-synth/argo-helpers.d.ts.map +1 -1
  38. package/dist/lint/post-synth/argo-helpers.js +8 -2
  39. package/dist/lint/post-synth/argo002.d.ts.map +1 -1
  40. package/dist/lint/post-synth/argo002.js +2 -1
  41. package/dist/lint/post-synth/argo003.d.ts.map +1 -1
  42. package/dist/lint/post-synth/argo003.js +2 -1
  43. package/dist/lint/post-synth/argo005.d.ts.map +1 -1
  44. package/dist/lint/post-synth/argo005.js +36 -9
  45. package/dist/lint/post-synth/crd-schema-helpers.d.ts +1 -1
  46. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
  47. package/dist/lint/post-synth/crd-schema-helpers.js +3 -3
  48. package/dist/lint/post-synth/flux002.d.ts.map +1 -1
  49. package/dist/lint/post-synth/flux002.js +2 -1
  50. package/dist/lint/post-synth/flux003.d.ts.map +1 -1
  51. package/dist/lint/post-synth/flux003.js +2 -1
  52. package/dist/lint/post-synth/k8s-helpers.d.ts +32 -0
  53. package/dist/lint/post-synth/k8s-helpers.d.ts.map +1 -1
  54. package/dist/lint/post-synth/k8s-helpers.js +57 -10
  55. package/dist/lint/post-synth/wk8005.d.ts +9 -0
  56. package/dist/lint/post-synth/wk8005.d.ts.map +1 -1
  57. package/dist/lint/post-synth/wk8005.js +53 -3
  58. package/dist/lint/post-synth/wk8006.d.ts.map +1 -1
  59. package/dist/lint/post-synth/wk8006.js +4 -2
  60. package/dist/lint/post-synth/wk8041.d.ts.map +1 -1
  61. package/dist/lint/post-synth/wk8041.js +3 -2
  62. package/dist/lint/post-synth/wk8042.js +2 -2
  63. package/dist/lint/post-synth/wk8101.js +2 -2
  64. package/dist/lint/post-synth/wk8102.d.ts.map +1 -1
  65. package/dist/lint/post-synth/wk8102.js +7 -3
  66. package/dist/lint/post-synth/wk8103.d.ts.map +1 -1
  67. package/dist/lint/post-synth/wk8103.js +3 -2
  68. package/dist/lint/post-synth/wk8104.d.ts.map +1 -1
  69. package/dist/lint/post-synth/wk8104.js +3 -2
  70. package/dist/lint/post-synth/wk8105.d.ts.map +1 -1
  71. package/dist/lint/post-synth/wk8105.js +3 -2
  72. package/dist/lint/post-synth/wk8201.d.ts.map +1 -1
  73. package/dist/lint/post-synth/wk8201.js +3 -2
  74. package/dist/lint/post-synth/wk8202.d.ts.map +1 -1
  75. package/dist/lint/post-synth/wk8202.js +3 -2
  76. package/dist/lint/post-synth/wk8203.d.ts.map +1 -1
  77. package/dist/lint/post-synth/wk8203.js +3 -2
  78. package/dist/lint/post-synth/wk8204.d.ts.map +1 -1
  79. package/dist/lint/post-synth/wk8204.js +5 -2
  80. package/dist/lint/post-synth/wk8205.d.ts.map +1 -1
  81. package/dist/lint/post-synth/wk8205.js +3 -2
  82. package/dist/lint/post-synth/wk8207.js +2 -2
  83. package/dist/lint/post-synth/wk8208.js +2 -2
  84. package/dist/lint/post-synth/wk8209.js +2 -2
  85. package/dist/lint/post-synth/wk8301.d.ts.map +1 -1
  86. package/dist/lint/post-synth/wk8301.js +3 -2
  87. package/dist/lint/post-synth/wk8302.js +2 -2
  88. package/dist/lint/post-synth/wk8303.js +2 -2
  89. package/dist/lint/post-synth/wk8304.js +2 -2
  90. package/dist/lint/post-synth/wk8305.js +2 -2
  91. package/dist/lint/post-synth/wk8306.d.ts.map +1 -1
  92. package/dist/lint/post-synth/wk8306.js +3 -2
  93. package/dist/lint/post-synth/wk8401.js +2 -2
  94. package/dist/lint/post-synth/wk8402.js +2 -2
  95. package/dist/lint/post-synth/wk8403.js +2 -2
  96. package/dist/lint/post-synth/wk8404.d.ts.map +1 -1
  97. package/dist/lint/post-synth/wk8404.js +2 -2
  98. package/dist/lint/post-synth/wk8405.js +2 -2
  99. package/dist/lint/post-synth/wk8406.d.ts.map +1 -1
  100. package/dist/lint/post-synth/wk8406.js +3 -2
  101. package/dist/lint/post-synth/wk8407.js +2 -2
  102. package/dist/lint/post-synth/wk8503.js +2 -2
  103. package/dist/manifest.json +1 -1
  104. package/dist/reference-catalog.d.ts +3 -1
  105. package/dist/reference-catalog.d.ts.map +1 -1
  106. package/dist/reference-catalog.js +283 -15
  107. package/dist/rules/argo-helpers.ts +9 -2
  108. package/dist/rules/argo002.ts +2 -1
  109. package/dist/rules/argo003.ts +2 -1
  110. package/dist/rules/argo005.ts +36 -10
  111. package/dist/rules/crd-schema-helpers.ts +3 -3
  112. package/dist/rules/flux002.ts +2 -1
  113. package/dist/rules/flux003.ts +2 -1
  114. package/dist/rules/k8s-helpers.ts +56 -11
  115. package/dist/rules/wk8005.ts +56 -3
  116. package/dist/rules/wk8006.ts +4 -2
  117. package/dist/rules/wk8041.ts +3 -2
  118. package/dist/rules/wk8042.ts +2 -2
  119. package/dist/rules/wk8101.ts +2 -2
  120. package/dist/rules/wk8102.ts +7 -3
  121. package/dist/rules/wk8103.ts +3 -2
  122. package/dist/rules/wk8104.ts +3 -2
  123. package/dist/rules/wk8105.ts +3 -2
  124. package/dist/rules/wk8201.ts +3 -2
  125. package/dist/rules/wk8202.ts +3 -2
  126. package/dist/rules/wk8203.ts +3 -2
  127. package/dist/rules/wk8204.ts +5 -2
  128. package/dist/rules/wk8205.ts +3 -2
  129. package/dist/rules/wk8207.ts +2 -2
  130. package/dist/rules/wk8208.ts +2 -2
  131. package/dist/rules/wk8209.ts +2 -2
  132. package/dist/rules/wk8301.ts +3 -2
  133. package/dist/rules/wk8302.ts +2 -2
  134. package/dist/rules/wk8303.ts +2 -2
  135. package/dist/rules/wk8304.ts +2 -2
  136. package/dist/rules/wk8305.ts +2 -2
  137. package/dist/rules/wk8306.ts +3 -2
  138. package/dist/rules/wk8401.ts +2 -2
  139. package/dist/rules/wk8402.ts +2 -2
  140. package/dist/rules/wk8403.ts +2 -2
  141. package/dist/rules/wk8404.ts +2 -1
  142. package/dist/rules/wk8405.ts +2 -2
  143. package/dist/rules/wk8406.ts +3 -2
  144. package/dist/rules/wk8407.ts +2 -2
  145. package/dist/rules/wk8503.ts +2 -2
  146. package/dist/workspace-member.d.ts +15 -3
  147. package/dist/workspace-member.d.ts.map +1 -1
  148. package/dist/workspace-member.js +151 -21
  149. package/package.json +5 -5
  150. package/src/application-paths.ts +96 -0
  151. package/src/application-set.test.ts +130 -0
  152. package/src/application-set.ts +336 -0
  153. package/src/cluster-secret.test.ts +117 -0
  154. package/src/cluster-secret.ts +76 -0
  155. package/src/components/kustomize-apply.ts +7 -1
  156. package/src/config-schema.ts +6 -2
  157. package/src/config.ts +24 -4
  158. package/src/helm-references.test.ts +149 -0
  159. package/src/helm-references.ts +425 -0
  160. package/src/import/generator.test.ts +57 -0
  161. package/src/import/generator.ts +35 -61
  162. package/src/import/parser.test.ts +59 -0
  163. package/src/import/parser.ts +38 -5
  164. package/src/import/roundtrip-build.test.ts +91 -0
  165. package/src/import/typed-classes.ts +168 -0
  166. package/src/kustomize/helm.test.ts +183 -0
  167. package/src/kustomize/render.ts +142 -6
  168. package/src/kustomize/root.ts +8 -3
  169. package/src/lint/post-synth/argo-helpers.ts +9 -2
  170. package/src/lint/post-synth/argo002.ts +2 -1
  171. package/src/lint/post-synth/argo003.ts +2 -1
  172. package/src/lint/post-synth/argo005.ts +36 -10
  173. package/src/lint/post-synth/audit-identity.test.ts +65 -0
  174. package/src/lint/post-synth/crd-schema-helpers.ts +3 -3
  175. package/src/lint/post-synth/flux002.ts +2 -1
  176. package/src/lint/post-synth/flux003.ts +2 -1
  177. package/src/lint/post-synth/k8s-helpers.ts +56 -11
  178. package/src/lint/post-synth/post-synth.test.ts +144 -0
  179. package/src/lint/post-synth/wk8005.ts +56 -3
  180. package/src/lint/post-synth/wk8006.ts +4 -2
  181. package/src/lint/post-synth/wk8041.ts +3 -2
  182. package/src/lint/post-synth/wk8042.ts +2 -2
  183. package/src/lint/post-synth/wk8101.ts +2 -2
  184. package/src/lint/post-synth/wk8102.ts +7 -3
  185. package/src/lint/post-synth/wk8103.ts +3 -2
  186. package/src/lint/post-synth/wk8104.ts +3 -2
  187. package/src/lint/post-synth/wk8105.ts +3 -2
  188. package/src/lint/post-synth/wk8201.ts +3 -2
  189. package/src/lint/post-synth/wk8202.ts +3 -2
  190. package/src/lint/post-synth/wk8203.ts +3 -2
  191. package/src/lint/post-synth/wk8204.ts +5 -2
  192. package/src/lint/post-synth/wk8205.ts +3 -2
  193. package/src/lint/post-synth/wk8207.ts +2 -2
  194. package/src/lint/post-synth/wk8208.ts +2 -2
  195. package/src/lint/post-synth/wk8209.ts +2 -2
  196. package/src/lint/post-synth/wk8301.ts +3 -2
  197. package/src/lint/post-synth/wk8302.ts +2 -2
  198. package/src/lint/post-synth/wk8303.ts +2 -2
  199. package/src/lint/post-synth/wk8304.ts +2 -2
  200. package/src/lint/post-synth/wk8305.ts +2 -2
  201. package/src/lint/post-synth/wk8306.ts +3 -2
  202. package/src/lint/post-synth/wk8401.ts +2 -2
  203. package/src/lint/post-synth/wk8402.ts +2 -2
  204. package/src/lint/post-synth/wk8403.ts +2 -2
  205. package/src/lint/post-synth/wk8404.ts +2 -1
  206. package/src/lint/post-synth/wk8405.ts +2 -2
  207. package/src/lint/post-synth/wk8406.ts +3 -2
  208. package/src/lint/post-synth/wk8407.ts +2 -2
  209. package/src/lint/post-synth/wk8503.ts +2 -2
  210. package/src/reference-catalog.test.ts +78 -0
  211. package/src/reference-catalog.ts +297 -16
  212. package/src/testdata/helm-chart-missing/kustomization.yaml +8 -0
  213. package/src/testdata/helm-chart-root/charts/webchart/Chart.yaml +3 -0
  214. package/src/testdata/helm-chart-root/charts/webchart/templates/configmap.yaml +6 -0
  215. package/src/testdata/helm-chart-root/charts/webchart/values.yaml +1 -0
  216. package/src/testdata/helm-chart-root/kustomization.yaml +9 -0
  217. package/src/testdata/helm-chart-root/values.yaml +1 -0
  218. package/src/testdata/workspace-members/argo-clusters/clusters.yaml +34 -0
  219. package/src/testdata/workspace-members/argo-set/all.yaml +43 -0
  220. package/src/testdata/workspace-members/plain/deploy.yaml +27 -0
  221. package/src/testdata/workspace-members/plain/es.yaml +15 -0
  222. package/src/testdata/workspace-members/templated/block.yaml +6 -0
  223. package/src/testdata/workspace-members/templated/chart-cm.yaml +4 -0
  224. package/src/testdata/workspace-members/templated/cm.yaml +6 -0
  225. package/src/workspace-kinds.test.ts +9 -1
  226. package/src/workspace-member.test.ts +69 -3
  227. package/src/workspace-member.ts +165 -24
  228. package/workspace-kinds.json +45 -6
@@ -0,0 +1,336 @@
1
+ /**
2
+ * Argo CD ApplicationSets as the graph reads them (#5102).
3
+ *
4
+ * An ApplicationSet does not name its paths and clusters. Its generators
5
+ * yield parameter sets, and its template turns each set into an Application.
6
+ * {@link generateApplications} expands two generators whose inputs are
7
+ * literals in the repo:
8
+ *
9
+ * - `list`: one parameter set per entry of `elements`.
10
+ * - `clusters`: one per Argo CD cluster Secret in the graph that the
11
+ * generator's `selector` selects (`matchLabels`, and `matchExpressions`
12
+ * with `In`, `NotIn`, `Exists` and `DoesNotExist`), with the generator's
13
+ * `values` merged in under `values`. A generator with no selector also
14
+ * selects the cluster Argo CD runs in (`in-cluster`) when no Secret
15
+ * registers it. The parameters are `name`, `nameNormalized`, `server`,
16
+ * `metadata.labels.<key>` and `metadata.annotations.<key>`.
17
+ *
18
+ * Each parameter set is substituted into the template, with a generator's own
19
+ * `template` merged over it, in the form the ApplicationSet uses: `{{name}}`
20
+ * by default, `{{ .name }}` with `goTemplate: true`. The Go form reads a field
21
+ * (`.metadata.labels.cloud`) and `index` with literal keys; any other
22
+ * function or pipeline, and a field the parameters do not have, is reported
23
+ * and that element is not expanded. A generated Application sits in the
24
+ * ApplicationSet's namespace, as Argo CD creates it there.
25
+ *
26
+ * Other generators (`git`, `matrix`, `merge`, `scmProvider`, `pullRequest`,
27
+ * `clusterDecisionResource`, `plugin`), `elementsYaml`, a generator's
28
+ * post-selector and `templatePatch` are not expanded, and each is reported.
29
+ * Pure.
30
+ */
31
+ import type { IRNode } from "@intentius/chant/graph-ir";
32
+ import type { Generated, GeneratedNode } from "@intentius/chant/graph-refs";
33
+ import { stampGeneratedApplication } from "./helm-references";
34
+
35
+ type Doc = Record<string, unknown>;
36
+
37
+ const isObject = (v: unknown): v is Doc => typeof v === "object" && v !== null && !Array.isArray(v);
38
+ const str = (v: unknown): string | undefined => (typeof v === "string" ? v : undefined);
39
+
40
+ /** The kind of the node an ApplicationSet makes, and of the cluster registrations a `clusters` generator reads. */
41
+ export const APPLICATION = "K8s::Argo::Application";
42
+ export const APPLICATION_SET = "K8s::Argo::ApplicationSet";
43
+ const SECRET = "K8s::Core::Secret";
44
+
45
+ /** The cluster Argo CD runs in, as the `clusters` generator yields it when no Secret registers it. */
46
+ const IN_CLUSTER = { name: "in-cluster", server: "https://kubernetes.default.svc" };
47
+
48
+ /** Generators this module reads. Every other key of a generator entry is one it does not. */
49
+ const EXPANDED = new Set(["list", "clusters"]);
50
+
51
+ /** A template that did not render, and why. */
52
+ class Unsupported extends Error {}
53
+
54
+ // ── substitution ──────────────────────────────────────────────────────────
55
+
56
+ /** A field path of the Go form, `.a.b.c`, as its steps. */
57
+ const FIELD = /^(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/;
58
+ /** A literal Go string, as `index` takes its keys. */
59
+ const QUOTED = /^"(?:[^"\\]|\\.)*"$/;
60
+
61
+ function lookup(params: Doc, steps: string[], written: string): string {
62
+ let cur: unknown = params;
63
+ for (const step of steps) {
64
+ if (!isObject(cur) || !(step in cur)) throw new Unsupported(`the parameters have no ${written}`);
65
+ cur = cur[step];
66
+ }
67
+ if (typeof cur === "string") return cur;
68
+ if (typeof cur === "number" || typeof cur === "boolean") return String(cur);
69
+ throw new Unsupported(`${written} is not a string`);
70
+ }
71
+
72
+ /** The value of one Go template action: a field, or `index` of a field with literal keys. */
73
+ function goAction(expr: string, params: Doc): string {
74
+ if (FIELD.test(expr)) return lookup(params, expr.slice(1).split("."), expr);
75
+ const words = expr.split(/\s+/);
76
+ if (words[0] === "index" && words.length >= 3 && (words[1] === "." || FIELD.test(words[1])) && words.slice(2).every((w) => QUOTED.test(w))) {
77
+ const base = words[1] === "." ? [] : words[1].slice(1).split(".");
78
+ return lookup(params, [...base, ...words.slice(2).map((w) => JSON.parse(w) as string)], expr);
79
+ }
80
+ throw new Unsupported(`{{ ${expr} }} uses a function or form the graph does not expand`);
81
+ }
82
+
83
+ /** Substitute one string in the Go form. `{{-` and `-}}` trim the space beside them, as in Go. */
84
+ function renderGo(text: string, params: Doc): string {
85
+ let out = "";
86
+ let i = 0;
87
+ while (i < text.length) {
88
+ const open = text.indexOf("{{", i);
89
+ if (open === -1) {
90
+ out += text.slice(i);
91
+ break;
92
+ }
93
+ const close = text.indexOf("}}", open + 2);
94
+ if (close === -1) throw new Unsupported(`"${text}" opens an action it does not close`);
95
+ let before = text.slice(i, open);
96
+ let inner = text.slice(open + 2, close);
97
+ if (/^-\s/.test(inner)) {
98
+ before = before.replace(/\s+$/, "");
99
+ inner = inner.slice(1);
100
+ }
101
+ let next = close + 2;
102
+ if (/\s-$/.test(inner)) {
103
+ inner = inner.slice(0, -1);
104
+ while (next < text.length && /\s/.test(text[next])) next++;
105
+ }
106
+ const expr = inner.trim();
107
+ if (expr.startsWith("/*")) {
108
+ out += before;
109
+ } else {
110
+ out += before + goAction(expr, params);
111
+ }
112
+ i = next;
113
+ }
114
+ return out;
115
+ }
116
+
117
+ /** Substitute one string in the default form, `{{name}}`, against flattened parameters. */
118
+ function renderPlain(text: string, flat: Record<string, string>): string {
119
+ return text.replace(/\{\{([^{}]*)\}\}/g, (_m, inner: string) => {
120
+ const key = inner.trim();
121
+ if (!(key in flat)) throw new Unsupported(`the parameters have no ${key} for {{${inner}}}`);
122
+ return flat[key];
123
+ });
124
+ }
125
+
126
+ /** Every string in a tree, keys included, substituted. */
127
+ function renderTree(value: unknown, one: (s: string) => string): unknown {
128
+ if (typeof value === "string") return value.includes("{{") ? one(value) : value;
129
+ if (Array.isArray(value)) return value.map((v) => renderTree(v, one));
130
+ if (isObject(value)) {
131
+ const out: Doc = {};
132
+ for (const [k, v] of Object.entries(value)) out[k.includes("{{") ? one(k) : k] = renderTree(v, one);
133
+ return out;
134
+ }
135
+ return value;
136
+ }
137
+
138
+ /** Nested parameters as `a.b.c` keys, scalars as strings. */
139
+ export function flattenParams(params: Doc, prefix = "", out: Record<string, string> = {}): Record<string, string> {
140
+ for (const [k, v] of Object.entries(params)) {
141
+ const key = prefix ? `${prefix}.${k}` : k;
142
+ if (isObject(v)) flattenParams(v, key, out);
143
+ else if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") out[key] = String(v);
144
+ }
145
+ return out;
146
+ }
147
+
148
+ /** A generator's own `template` over the ApplicationSet's: maps merge key by key, anything else is replaced. */
149
+ function merge(base: unknown, over: unknown): unknown {
150
+ if (!isObject(base) || !isObject(over)) return over === undefined ? base : over;
151
+ const out: Doc = { ...base };
152
+ for (const [k, v] of Object.entries(over)) out[k] = merge(base[k], v);
153
+ return out;
154
+ }
155
+
156
+ // ── clusters ──────────────────────────────────────────────────────────────
157
+
158
+ interface ClusterParams {
159
+ params: Doc;
160
+ node?: IRNode;
161
+ }
162
+
163
+ const labelsOf = (node: IRNode): Record<string, string> => {
164
+ const labels = isObject(node.attrs.metadata) ? node.attrs.metadata.labels : undefined;
165
+ return isObject(labels) ? (Object.fromEntries(Object.entries(labels).filter(([, v]) => typeof v === "string")) as Record<string, string>) : {};
166
+ };
167
+
168
+ /** Whether a label selector selects `labels`, or why it cannot be read. */
169
+ function selects(selector: Doc, labels: Record<string, string>): boolean {
170
+ const matchLabels = isObject(selector.matchLabels) ? selector.matchLabels : {};
171
+ for (const [k, v] of Object.entries(matchLabels)) if (labels[k] !== String(v)) return false;
172
+ const expressions = Array.isArray(selector.matchExpressions) ? selector.matchExpressions : [];
173
+ for (const e of expressions) {
174
+ if (!isObject(e) || typeof e.key !== "string") throw new Unsupported("a matchExpressions entry has no key");
175
+ const values = Array.isArray(e.values) ? e.values.map(String) : [];
176
+ const has = e.key in labels;
177
+ switch (e.operator) {
178
+ case "In":
179
+ if (!has || !values.includes(labels[e.key])) return false;
180
+ break;
181
+ case "NotIn":
182
+ if (has && values.includes(labels[e.key])) return false;
183
+ break;
184
+ case "Exists":
185
+ if (!has) return false;
186
+ break;
187
+ case "DoesNotExist":
188
+ if (has) return false;
189
+ break;
190
+ default:
191
+ throw new Unsupported(`matchExpressions operator ${String(e.operator)} is not one the graph reads`);
192
+ }
193
+ }
194
+ return true;
195
+ }
196
+
197
+ /** `name` as Argo CD normalizes it for `nameNormalized`: lower case, with any character a resource name cannot hold made `-`. */
198
+ const normalizeName = (name: string): string => name.toLowerCase().replace(/[^a-z0-9.-]/g, "-");
199
+
200
+ function clusterParams(name: string, server: string, node?: IRNode): ClusterParams {
201
+ const metadata = node && isObject(node.attrs.metadata) ? node.attrs.metadata : {};
202
+ const annotations = isObject(metadata.annotations) ? metadata.annotations : {};
203
+ return {
204
+ params: { name, nameNormalized: normalizeName(name), server, metadata: { labels: node ? labelsOf(node) : {}, annotations: { ...annotations } } },
205
+ ...(node ? { node } : {}),
206
+ };
207
+ }
208
+
209
+ /** The clusters a `clusters` generator selects, by Secret name. */
210
+ function selectedClusters(generator: Doc, nodes: readonly IRNode[]): ClusterParams[] {
211
+ const selector = isObject(generator.selector) ? generator.selector : {};
212
+ const secrets = nodes.filter((n) => n.kind === SECRET && isObject(n.attrs.argoCluster));
213
+ const out: ClusterParams[] = [];
214
+ for (const node of secrets) {
215
+ const cluster = node.attrs.argoCluster as Doc;
216
+ const name = str(cluster.name);
217
+ const server = str(cluster.server);
218
+ if (name === undefined || server === undefined) continue;
219
+ if (selects(selector, labelsOf(node))) out.push(clusterParams(name, server, node));
220
+ }
221
+ const empty = !isObject(generator.selector) || (Object.keys(selector.matchLabels ?? {}).length === 0 && (!Array.isArray(selector.matchExpressions) || selector.matchExpressions.length === 0));
222
+ if (empty && !out.some((c) => c.params.server === IN_CLUSTER.server)) out.push(clusterParams(IN_CLUSTER.name, IN_CLUSTER.server));
223
+ return out.sort((a, b) => String(a.params.name).localeCompare(String(b.params.name)) || (a.node?.id ?? "").localeCompare(b.node?.id ?? ""));
224
+ }
225
+
226
+ // ── expansion ─────────────────────────────────────────────────────────────
227
+
228
+ /**
229
+ * The Applications an ApplicationSet node generates from its `list` and
230
+ * `clusters` generators, given every node the pass reads (the cluster
231
+ * Secrets among them), and a line for each thing it did not expand.
232
+ */
233
+ export function generateApplications(holder: IRNode, nodes: readonly IRNode[]): Generated {
234
+ const out: Generated = { nodes: [], notExpanded: [] };
235
+ const spec = isObject(holder.attrs.spec) ? holder.attrs.spec : {};
236
+ if (spec.templatePatch !== undefined) {
237
+ out.notExpanded.push("templatePatch is not expanded, so no Application is generated");
238
+ return out;
239
+ }
240
+ const go = spec.goTemplate === true;
241
+ const namespace = isObject(holder.attrs.metadata) ? str(holder.attrs.metadata.namespace) : undefined;
242
+ const generators = Array.isArray(spec.generators) ? spec.generators : [];
243
+ const seen = new Set<string>();
244
+
245
+ generators.forEach((generator, i) => {
246
+ const at = `generators[${i}]`;
247
+ if (!isObject(generator)) return;
248
+ const types = Object.keys(generator).filter((k) => k !== "selector");
249
+ const type = types[0];
250
+ if (types.length !== 1) {
251
+ out.notExpanded.push(`${at} names ${types.length === 0 ? "no generator" : `several generators (${types.join(", ")})`}, and is not expanded`);
252
+ return;
253
+ }
254
+ if (!EXPANDED.has(type)) {
255
+ out.notExpanded.push(`${at}: the ${type} generator is not expanded`);
256
+ return;
257
+ }
258
+ if (generator.selector !== undefined) {
259
+ out.notExpanded.push(`${at}: a generator's post-selector is not expanded`);
260
+ return;
261
+ }
262
+ const body = isObject(generator[type]) ? (generator[type] as Doc) : {};
263
+ const template = merge(spec.template, body.template);
264
+
265
+ let sets: ClusterParams[];
266
+ if (type === "list") {
267
+ if (body.elementsYaml !== undefined) {
268
+ out.notExpanded.push(`${at}: list elementsYaml is not expanded`);
269
+ return;
270
+ }
271
+ const elements = Array.isArray(body.elements) ? body.elements : [];
272
+ sets = elements.map((e) => ({ params: isObject(e) ? e : {} }));
273
+ } else {
274
+ if (body.flatList === true) {
275
+ out.notExpanded.push(`${at}: a clusters generator with flatList is not expanded`);
276
+ return;
277
+ }
278
+ try {
279
+ sets = selectedClusters(body, nodes);
280
+ } catch (err) {
281
+ out.notExpanded.push(`${at}: ${(err as Error).message}, so the generator is not expanded`);
282
+ return;
283
+ }
284
+ const values = isObject(body.values) ? body.values : undefined;
285
+ if (values) {
286
+ const withValues: ClusterParams[] = [];
287
+ for (const set of sets) {
288
+ try {
289
+ const one = go ? (s: string) => renderGo(s, set.params) : (s: string) => renderPlain(s, flattenParams(set.params));
290
+ withValues.push({ ...set, params: { ...set.params, values: renderTree(values, one) } });
291
+ } catch (err) {
292
+ out.notExpanded.push(`${at} cluster ${String(set.params.name)}: values: ${(err as Error).message}; not expanded`);
293
+ }
294
+ }
295
+ sets = withValues;
296
+ }
297
+ }
298
+
299
+ sets.forEach((set, j) => {
300
+ const which = type === "clusters" ? `${at} cluster ${String(set.params.name)}` : `${at} element ${j}`;
301
+ const flat = flattenParams(set.params);
302
+ let rendered: unknown;
303
+ try {
304
+ rendered = renderTree(template, go ? (s) => renderGo(s, set.params) : (s) => renderPlain(s, flat));
305
+ } catch (err) {
306
+ out.notExpanded.push(`${which}: ${(err as Error).message}; not expanded`);
307
+ return;
308
+ }
309
+ const app = isObject(rendered) ? rendered : {};
310
+ const metadata: Doc = { ...(isObject(app.metadata) ? app.metadata : {}) };
311
+ const name = str(metadata.name);
312
+ if (!name) {
313
+ out.notExpanded.push(`${which}: the template gives no metadata.name; not expanded`);
314
+ return;
315
+ }
316
+ if (seen.has(name)) {
317
+ out.notExpanded.push(`${which}: Application ${name} is generated twice; the second is not expanded`);
318
+ return;
319
+ }
320
+ seen.add(name);
321
+ delete metadata.namespace;
322
+ if (namespace !== undefined) metadata.namespace = namespace;
323
+ const node: GeneratedNode = {
324
+ key: name,
325
+ kind: APPLICATION,
326
+ // Stamped as the reader stamps an Application written by hand, so its charts and values files join the Helm graph (#5094).
327
+ attrs: stampGeneratedApplication({ apiVersion: str(holder.attrs.apiVersion) ?? "argoproj.io/v1alpha1", kind: "Application", metadata, spec: isObject(app.spec) ? app.spec : {} }),
328
+ generator: type,
329
+ params: flat,
330
+ ...(set.node ? { cluster: set.node } : {}),
331
+ };
332
+ out.nodes.push(node);
333
+ });
334
+ });
335
+ return out;
336
+ }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Argo CD cluster Secrets as the graph reads them (#5101): the name and
3
+ * server it joins on, decoded when they sit in `data`, and nothing else of
4
+ * the Secret's credentials.
5
+ */
6
+ import { describe, expect, it } from "vitest";
7
+ import type { IRNode } from "@intentius/chant/graph-ir";
8
+ import { runCatalogPass } from "@intentius/chant/workspace/catalog-edges";
9
+ import type { ComposedNode } from "@intentius/chant/workspace/compose-graph";
10
+ import { clusterSecretJoin, clusterSecretView, isClusterSecretDocument, k8sDeclaredNode, registersCluster } from "./cluster-secret";
11
+ import { k8sReferenceCatalog } from "./reference-catalog";
12
+
13
+ const LABEL = "argocd.argoproj.io/secret-type";
14
+ const b64 = (s: string) => Buffer.from(s).toString("base64");
15
+ const secret = (extra: Record<string, unknown>, labels: Record<string, string> = { [LABEL]: "cluster" }): Record<string, unknown> => ({
16
+ apiVersion: "v1",
17
+ kind: "Secret",
18
+ metadata: { name: "cluster-prod", namespace: "argocd", labels },
19
+ ...extra,
20
+ });
21
+
22
+ describe("a cluster Secret document", () => {
23
+ it("is a v1 Secret with the cluster label", () => {
24
+ expect(isClusterSecretDocument(secret({}))).toBe(true);
25
+ expect(isClusterSecretDocument(secret({}, {}))).toBe(false);
26
+ expect(isClusterSecretDocument(secret({}, { [LABEL]: "repository" }))).toBe(false);
27
+ expect(isClusterSecretDocument({ ...secret({}), kind: "ConfigMap" })).toBe(false);
28
+ });
29
+
30
+ it("gives its name and server from stringData, or decoded from data, stringData first", () => {
31
+ expect(clusterSecretJoin(secret({ stringData: { name: "prod", server: "https://10.0.0.1" } }))).toEqual({ name: "prod", server: "https://10.0.0.1" });
32
+ expect(clusterSecretJoin(secret({ data: { name: b64("staging"), server: b64("https://10.0.0.2") } }))).toEqual({ name: "staging", server: "https://10.0.0.2" });
33
+ expect(clusterSecretJoin(secret({ stringData: { name: "a" }, data: { name: b64("b"), server: b64("https://s") } }))).toEqual({ name: "a", server: "https://s" });
34
+ expect(clusterSecretJoin(secret({ data: { name: Buffer.from([0xff, 0xfe]).toString("base64") } }))).toEqual({});
35
+ });
36
+
37
+ it("is cut down to its metadata, name and server, with the credentials gone", () => {
38
+ const view = clusterSecretView(secret({ type: "Opaque", stringData: { name: "prod", server: "https://10.0.0.1", config: '{"bearerToken":"t"}' }, data: { config: b64("{}") } }));
39
+ expect(view).toEqual({
40
+ apiVersion: "v1",
41
+ kind: "Secret",
42
+ metadata: { name: "cluster-prod", namespace: "argocd", labels: { [LABEL]: "cluster" } },
43
+ type: "Opaque",
44
+ stringData: { name: "prod", server: "https://10.0.0.1" },
45
+ });
46
+ });
47
+ });
48
+
49
+ describe("the node the catalog reads", () => {
50
+ const node = (attrs: Record<string, unknown>, kind = "K8s::Core::Secret"): IRNode => ({ id: "argo/s", kind, lexicon: "k8s", attrs });
51
+
52
+ it("gives a cluster Secret argoCluster, decoded, and leaves its credentials out", () => {
53
+ const { apiVersion: _a, kind: _k, ...attrs } = secret({ data: { name: b64("staging"), server: b64("https://10.0.0.2"), config: b64("{}") } });
54
+ expect(k8sDeclaredNode(node(attrs))).toEqual({
55
+ kind: "K8s::Core::Secret",
56
+ attrs: { metadata: attrs.metadata, argoCluster: { name: "staging", server: "https://10.0.0.2" } },
57
+ nonLiteral: 0,
58
+ });
59
+ expect(registersCluster(node(attrs))).toBe(true);
60
+ });
61
+
62
+ it("reads any other node as it is, a Secret with a name of its own included", () => {
63
+ const plain = { metadata: { name: "db-login" }, stringData: { name: "orders" } };
64
+ expect(k8sDeclaredNode(node(plain))).toBeUndefined();
65
+ expect(registersCluster(node(plain))).toBe(false);
66
+ expect(k8sDeclaredNode(node({ metadata: { labels: { [LABEL]: "cluster" } } }, "K8s::Core::ConfigMap"))).toBeUndefined();
67
+ });
68
+ });
69
+
70
+ describe("the Argo CD rules on a composed graph", () => {
71
+ const composed = (member: string, id: string, kind: string, attrs: Record<string, unknown>, lexicon = "k8s"): ComposedNode => ({ id: `${member}/${id}`, kind, lexicon, attrs, member });
72
+ const app = (destination: Record<string, string>, namespace = "argocd") =>
73
+ composed("argo", "app", "K8s::Argo::Application", { metadata: { name: "web", namespace }, spec: { destination } });
74
+ const cluster = (name: string, server = "https://10.0.0.1", namespace = "argocd") =>
75
+ composed("argo", "cluster", "K8s::Core::Secret", { metadata: { name: `cluster-${name}`, namespace, labels: { [LABEL]: "cluster" } }, stringData: { name, server } });
76
+ // What the terraform catalog gives a cluster block: its provider type and the literal name.
77
+ const tf = { lexicon: "terraform", catalog: { identities: [{ kind: "google_container_cluster", ids: ["name"] }], refs: [] } };
78
+ const block = (member: string, name: string) => composed(member, `google_container_cluster.${name}`, "google_container_cluster", { name }, "terraform");
79
+ const pass = (nodes: ComposedNode[]) => runCatalogPass(nodes, [{ lexicon: "k8s", catalog: k8sReferenceCatalog }, tf]);
80
+ const DEST = "k8s:K8s::Argo::Application:spec.destination.name";
81
+ const SERVER = "k8s:K8s::Argo::Application:spec.destination.server";
82
+ const REG = "k8s:K8s::Core::Secret:argoCluster.name";
83
+
84
+ it("joins an Application to its cluster Secret by name, and by server", () => {
85
+ expect(pass([app({ name: "prod" }), cluster("prod")]).edges.map((e) => [e.from, e.to, e.rule])).toEqual([["argo/app", "argo/cluster", DEST]]);
86
+ expect(pass([app({ server: "https://10.0.0.1" }), cluster("prod")]).edges.map((e) => [e.from, e.to, e.rule])).toEqual([["argo/app", "argo/cluster", SERVER]]);
87
+ });
88
+
89
+ it("does not report an in-cluster destination, or one in another namespace, as dangling", () => {
90
+ expect(pass([app({ server: "https://kubernetes.default.svc" }), cluster("prod")]).dangling.filter((d) => d.rule === SERVER)).toEqual([]);
91
+ expect(pass([app({ name: "prod" }, "other"), cluster("prod")]).edges).toEqual([]);
92
+ });
93
+
94
+ it("joins a cluster Secret's name to a cluster block of that name", () => {
95
+ const out = pass([cluster("prod"), block("tf", "prod")]);
96
+ expect(out.edges.map((e) => [e.from, e.to, e.rule])).toEqual([["argo/cluster", "tf/google_container_cluster.prod", REG]]);
97
+ expect(out.dangling.filter((d) => d.rule === REG)).toEqual([]);
98
+ });
99
+
100
+ it("lists the Secret's name as dangling once, when no cluster block has it, whatever the kinds", () => {
101
+ const out = pass([cluster("prod"), block("tf", "prod-gke")]);
102
+ expect(out.edges).toEqual([]);
103
+ expect(out.dangling.filter((d) => d.rule === REG)).toEqual([expect.objectContaining({ from: "argo/cluster", value: "prod", rule: REG })]);
104
+ });
105
+
106
+ it("draws no edge for two cluster blocks of one name, and records both", () => {
107
+ const out = pass([cluster("prod"), block("a", "prod"), block("b", "prod")]);
108
+ expect(out.edges).toEqual([]);
109
+ expect(out.ambiguous).toEqual([expect.objectContaining({ from: "argo/cluster", rule: REG, value: "prod", candidates: ["a/google_container_cluster.prod", "b/google_container_cluster.prod"] })]);
110
+ });
111
+
112
+ it("does not read a Secret with a name of its own as a cluster", () => {
113
+ const plain = composed("argo", "db", "K8s::Core::Secret", { metadata: { name: "db", namespace: "argocd" }, stringData: { name: "orders" } });
114
+ expect(pass([plain, block("tf", "orders")]).edges).toEqual([]);
115
+ expect(pass([plain]).dangling.filter((d) => d.rule === REG)).toEqual([]);
116
+ });
117
+ });
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Argo CD cluster Secrets as the graph reads them (#5101).
3
+ *
4
+ * A cluster Secret is a Secret labelled `argocd.argoproj.io/secret-type:
5
+ * cluster`. Its `name` and `server` say which cluster it registers, and they
6
+ * are what an Application's destination and a Terraform cluster resource are
7
+ * joined on. They sit in `stringData`, or base64 in `data`.
8
+ *
9
+ * The rest of the Secret is the cluster's credentials: a bearer token, a CA
10
+ * bundle. No graph read needs them, so {@link clusterSecretView} drops them
11
+ * when a member reads a manifest directory.
12
+ */
13
+ import type { DeclaredCatalogNode } from "@intentius/chant/graph-refs";
14
+ import type { IRNode } from "@intentius/chant/graph-ir";
15
+ import { CLUSTER_SECRET_TYPE_LABEL } from "./lint/post-synth/argo-helpers";
16
+
17
+ type Doc = Record<string, unknown>;
18
+
19
+ const isObject = (v: unknown): v is Doc => typeof v === "object" && v !== null && !Array.isArray(v);
20
+
21
+ /** Whether the labels of an object mark an Argo CD cluster Secret. */
22
+ function labelled(metadata: unknown): boolean {
23
+ return isObject(metadata) && isObject(metadata.labels) && metadata.labels[CLUSTER_SECRET_TYPE_LABEL] === "cluster";
24
+ }
25
+
26
+ /** Whether a manifest document is a Secret labelled as an Argo CD cluster registration. */
27
+ export function isClusterSecretDocument(doc: Doc): boolean {
28
+ return doc.kind === "Secret" && typeof doc.apiVersion === "string" && !doc.apiVersion.includes("/") && labelled(doc.metadata);
29
+ }
30
+
31
+ /** A string field of a cluster Secret: `stringData` when set, else `data` decoded from base64. */
32
+ function field(secret: Doc, key: string): string | undefined {
33
+ const plain = isObject(secret.stringData) ? secret.stringData[key] : undefined;
34
+ if (typeof plain === "string") return plain;
35
+ const encoded = isObject(secret.data) ? secret.data[key] : undefined;
36
+ if (typeof encoded !== "string") return undefined;
37
+ const text = Buffer.from(encoded, "base64").toString("utf-8");
38
+ return text.includes("\uFFFD") ? undefined : text;
39
+ }
40
+
41
+ /** The `name` and `server` a cluster Secret registers, as the ones it sets. */
42
+ export function clusterSecretJoin(secret: Doc): { name?: string; server?: string } {
43
+ const name = field(secret, "name");
44
+ const server = field(secret, "server");
45
+ return { ...(name !== undefined ? { name } : {}), ...(server !== undefined ? { server } : {}) };
46
+ }
47
+
48
+ /** A cluster Secret document cut down to its metadata and the `name` and `server` in `stringData`. */
49
+ export function clusterSecretView(doc: Doc): Doc {
50
+ return {
51
+ apiVersion: doc.apiVersion,
52
+ kind: doc.kind,
53
+ metadata: doc.metadata,
54
+ ...(doc.type !== undefined ? { type: doc.type } : {}),
55
+ stringData: clusterSecretJoin(doc),
56
+ };
57
+ }
58
+
59
+ /**
60
+ * The node the catalog reads for a declared node of the k8s lexicon: a
61
+ * cluster Secret with its `name` and `server` under `argoCluster`, decoded,
62
+ * and nothing else of its `data`. Any other node is read as it is. Only a
63
+ * cluster Secret has that path, so a Secret that happens to carry a
64
+ * `stringData.name` is not read as a cluster registration.
65
+ */
66
+ export function k8sDeclaredNode(node: IRNode): DeclaredCatalogNode | undefined {
67
+ if (node.kind !== "K8s::Core::Secret" || !labelled(node.attrs.metadata)) return undefined;
68
+ const { name, server } = clusterSecretJoin(node.attrs);
69
+ const { data: _data, stringData: _stringData, ...rest } = node.attrs;
70
+ return { kind: node.kind, attrs: { ...rest, argoCluster: { ...(name !== undefined ? { name } : {}), ...(server !== undefined ? { server } : {}) } }, nonLiteral: 0 };
71
+ }
72
+
73
+ /** Whether a node is an Argo CD cluster Secret: what a member's `runsOn` joins to the cluster resource. */
74
+ export function registersCluster(node: IRNode): boolean {
75
+ return node.kind === "K8s::Core::Secret" && labelled(node.attrs.metadata);
76
+ }
@@ -73,6 +73,12 @@ export interface KustomizeApplyInput {
73
73
  context?: string;
74
74
  /** Same delete vocabulary as kubectl-apply; default `never`. */
75
75
  delete?: "never" | "owned-only";
76
+ /** Render a kustomization that has `helmCharts` (`--enable-helm`, #5112). Default off. */
77
+ enableHelm?: boolean;
78
+ /** The `helm` binary for `--helm-command`. */
79
+ helmCommand?: string;
80
+ /** Let kustomize pull a chart that is not in the chart home (network). Default off. */
81
+ fetchCharts?: boolean;
76
82
  }
77
83
 
78
84
  /** Factory with injectable renderer + applier, so tests assert the render
@@ -87,7 +93,7 @@ export function createKustomizeApplyCapability(
87
93
  // undo of its own — same posture as kubectl-apply.
88
94
  rollbackPolicy: "needs-opt-out",
89
95
  async run(ctx: DeployContext, input: KustomizeApplyInput): Promise<KustomizeApplyOutcome> {
90
- const documents = await renderKustomizeDocuments(input.dir, run);
96
+ const documents = await renderKustomizeDocuments(input.dir, run, { enableHelm: input.enableHelm, helmCommand: input.helmCommand, fetchCharts: input.fetchCharts });
91
97
  const applier: Applier = apply ?? ((await import("../op/activities/kubectl")).applyManifest as unknown as Applier);
92
98
  return applier({
93
99
  manifest: `kustomize:${input.dir}`,
@@ -69,15 +69,19 @@ export const k8sConfigSchema = z.strictObject({
69
69
  kustomize: z
70
70
  .strictObject({
71
71
  roots: z
72
- .array(z.union([z.string(), z.strictObject({ path: z.string(), patches: z.array(renderedPatchSchema).optional() })]))
72
+ .array(z.union([z.string(), z.strictObject({ path: z.string(), patches: z.array(renderedPatchSchema).optional(), enableHelm: z.boolean().optional(), helmCommand: z.string().optional(), fetchCharts: z.boolean().optional() })]))
73
73
  .optional(),
74
74
  })
75
75
  .optional(),
76
76
  member: z
77
77
  .strictObject({
78
- kind: z.enum(["kustomize", "argo-app", "flux-kustomization"]),
78
+ kind: z.enum(["kustomize", "argo-app", "flux-kustomization", "manifests"]),
79
79
  dir: z.string().min(1),
80
80
  label: z.string().optional(),
81
+ enableHelm: z.boolean().optional(),
82
+ helmCommand: z.string().optional(),
83
+ fetchCharts: z.boolean().optional(),
84
+ workspace: z.string().optional(),
81
85
  })
82
86
  .optional(),
83
87
  receipts: z
package/src/config.ts CHANGED
@@ -105,6 +105,17 @@ export interface K8sChantConfig {
105
105
  * An entry may also be `{ path, patches }`: the patches apply to the
106
106
  * rendered documents before they become entities (see `RenderedPatch`).
107
107
  *
108
+ * A kustomization with `helmCharts` renders only when asked (#5112).
109
+ * `enableHelm: true` passes `--enable-helm` to kustomize (and to `kubectl
110
+ * kustomize`), and `helmCommand` names the `helm` binary for
111
+ * `--helm-command`. Without `enableHelm` the root fails with a message that
112
+ * names the charts and this option. kustomize pulls a chart that is not
113
+ * already in the root's chart home (`helmGlobals.chartHome`, default
114
+ * `charts/`), which reaches the network, so that is its own switch:
115
+ * `fetchCharts: true` allows the pull, and without it a chart that is not in
116
+ * the chart home fails naming the chart, with no network used. A pull writes
117
+ * the chart into the root's directory.
118
+ *
108
119
  * ```ts
109
120
  * k8s: {
110
121
  * kustomize: {
@@ -118,13 +129,13 @@ export interface K8sChantConfig {
118
129
  */
119
130
  kustomize?: {
120
131
  /** Kustomization directories to render into the build, optionally with patches. */
121
- roots?: Array<string | { path: string; patches?: RenderedPatch[] }>;
132
+ roots?: Array<string | { path: string; patches?: RenderedPatch[]; enableHelm?: boolean; helmCommand?: string; fetchCharts?: boolean }>;
122
133
  };
123
134
 
124
135
  /**
125
136
  * One workspace member read into the graph (#3179). `chant workspace graph`
126
137
  * writes this into the reader project it makes for a member of kind
127
- * `kustomize`, `argo-app` or `flux-kustomization`; it is not meant to be
138
+ * `kustomize`, `argo-app`, `flux-kustomization` or `manifests`; it is not meant to be
128
139
  * written by hand. `dir` is the member's directory, absolute; `label` names
129
140
  * the entities (`<label>/deploymentWeb`), the member's name.
130
141
  *
@@ -132,12 +143,21 @@ export interface K8sChantConfig {
132
143
  * neither installed the graph carries no objects for it and says why on
133
144
  * `meta.k8sMember` (`rendered: false`, `reason`); a render the binary ran
134
145
  * and refused still fails. An Argo or Flux member is read from its manifests
135
- * and needs no binary.
146
+ * and needs no binary. A `manifests` member keeps every document with an
147
+ * `apiVersion` and a `kind`.
136
148
  */
137
149
  member?: {
138
- kind: "kustomize" | "argo-app" | "flux-kustomization";
150
+ kind: "kustomize" | "argo-app" | "flux-kustomization" | "manifests";
139
151
  dir: string;
140
152
  label?: string;
153
+ /** Kustomize only: pass `--enable-helm` (#5112). Also read from the environment as `CHANT_K8S_ENABLE_HELM=1`, which is how `chant workspace graph` is told, since it writes this config itself. */
154
+ enableHelm?: boolean;
155
+ /** Kustomize only: the `helm` binary for `--helm-command`. Environment: `CHANT_K8S_HELM_COMMAND`. */
156
+ helmCommand?: string;
157
+ /** Kustomize only: let kustomize pull a chart that is not in the chart home, which uses the network. Environment: `CHANT_K8S_FETCH_CHARTS=1`. */
158
+ fetchCharts?: boolean;
159
+ /** The workspace root, absolute. A `manifests` member leaves out a directory a kustomization under it lists in `resources`. */
160
+ workspace?: string;
141
161
  };
142
162
 
143
163
  /**