@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
@@ -7,51 +7,12 @@
7
7
  import { EmbeddedImportScope, isEmbeddedReference, renderEmbeddedReference, } from "@intentius/chant/import/embedded";
8
8
  import { SECRET_DECLARATION_ENTITY_TYPE } from "@intentius/chant/secret-provenance";
9
9
  import { isMaskedValueRef } from "../index-import.js";
10
+ import { importClassFor } from "./typed-classes.js";
10
11
  const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
11
12
  /** An object key as TypeScript: bare when it is an identifier, quoted otherwise (`"config.yaml"`, `"app.kubernetes.io/name"`). */
12
13
  function propertyKey(key) {
13
14
  return IDENT.test(key) ? key : JSON.stringify(key);
14
15
  }
15
- /**
16
- * Map K8s entity types to their constructor class names.
17
- */
18
- const TYPE_TO_CLASS = {
19
- // Core
20
- "K8s::Core::Pod": "Pod",
21
- "K8s::Core::Service": "Service",
22
- "K8s::Core::ConfigMap": "ConfigMap",
23
- "K8s::Core::Secret": "Secret",
24
- "K8s::Core::Namespace": "Namespace",
25
- "K8s::Core::ServiceAccount": "ServiceAccount",
26
- "K8s::Core::PersistentVolume": "PersistentVolume",
27
- "K8s::Core::PersistentVolumeClaim": "PersistentVolumeClaim",
28
- "K8s::Core::Endpoints": "Endpoints",
29
- "K8s::Core::LimitRange": "LimitRange",
30
- "K8s::Core::ResourceQuota": "ResourceQuota",
31
- // Apps
32
- "K8s::Apps::Deployment": "Deployment",
33
- "K8s::Apps::StatefulSet": "StatefulSet",
34
- "K8s::Apps::DaemonSet": "DaemonSet",
35
- "K8s::Apps::ReplicaSet": "ReplicaSet",
36
- // Batch
37
- "K8s::Batch::Job": "Job",
38
- "K8s::Batch::CronJob": "CronJob",
39
- // Networking
40
- "K8s::Networking::Ingress": "Ingress",
41
- "K8s::Networking::NetworkPolicy": "NetworkPolicy",
42
- "K8s::Networking::IngressClass": "IngressClass",
43
- // RBAC
44
- "K8s::Rbac::Role": "Role",
45
- "K8s::Rbac::ClusterRole": "ClusterRole",
46
- "K8s::Rbac::RoleBinding": "RoleBinding",
47
- "K8s::Rbac::ClusterRoleBinding": "ClusterRoleBinding",
48
- // Autoscaling
49
- "K8s::Autoscaling::HorizontalPodAutoscaler": "HorizontalPodAutoscaler",
50
- // Policy
51
- "K8s::Policy::PodDisruptionBudget": "PodDisruptionBudget",
52
- // Storage
53
- "K8s::Storage::StorageClass": "StorageClass",
54
- };
55
16
  /**
56
17
  * Properties that reference known property entity constructors.
57
18
  * Key: property name found in K8s specs → Value: constructor class name.
@@ -119,12 +80,14 @@ export class K8sGenerator {
119
80
  const lines = [];
120
81
  this.usesMaskedValue = false;
121
82
  let usesDeclareSecret = false;
83
+ let usesManifest = false;
122
84
  // Collect which constructors are needed
123
85
  const usedConstructors = new Set();
124
86
  for (const resource of ir.resources) {
125
- const cls = this.resolveClass(resource.type);
126
- if (cls)
127
- usedConstructors.add(cls);
87
+ const cls = this.resolveClass(resource);
88
+ if (!cls)
89
+ continue;
90
+ usedConstructors.add(cls);
128
91
  // Check properties for nested constructors
129
92
  this.collectNestedConstructors(resource.properties, usedConstructors, resource.type);
130
93
  }
@@ -150,8 +113,15 @@ export class K8sGenerator {
150
113
  lines.push("");
151
114
  continue;
152
115
  }
153
- const cls = this.resolveClass(resource.type);
116
+ const cls = this.resolveClass(resource);
154
117
  if (!cls) {
118
+ const manifest = this.emitManifest(resource);
119
+ if (manifest) {
120
+ usesManifest = true;
121
+ lines.push(`export const ${resource.logicalId} = ${manifest};`);
122
+ lines.push("");
123
+ continue;
124
+ }
155
125
  lines.push(`// TODO: unsupported type ${resource.type} (${resource.logicalId})`);
156
126
  lines.push("");
157
127
  continue;
@@ -168,7 +138,7 @@ export class K8sGenerator {
168
138
  const code = lines.join("\n").replace(/"(?:[^"\\\n]|\\.)*"/g, '""');
169
139
  for (const m of code.matchAll(/\bnew ([A-Z][A-Za-z0-9_]*)\(/g))
170
140
  usedConstructors.add(m[1]);
171
- const imports = [...usedConstructors].sort().join(", ");
141
+ const imports = [...(usesManifest ? ["k8sManifest"] : []), ...[...usedConstructors].sort()].join(", ");
172
142
  const head = [
173
143
  ...(usesDeclareSecret ? [`import { declareSecret } from "@intentius/chant";`] : []),
174
144
  ...(imports ? [`import { ${imports} } from "@intentius/chant-lexicon-k8s";`] : []),
@@ -195,17 +165,29 @@ export class K8sGenerator {
195
165
  ];
196
166
  }
197
167
  /**
198
- * Resolve a K8s type name to a constructor class name.
199
- * Falls back to extracting the last segment of the type.
168
+ * Resolve a resource to a constructor class name, or undefined when the
169
+ * lexicon exports none or the class builds another apiVersion than the
170
+ * resource has (the resource is written as a `k8sManifest`, see
171
+ * `importClassFor`).
172
+ */
173
+ resolveClass(resource) {
174
+ return importClassFor(resource).cls;
175
+ }
176
+ /**
177
+ * An untyped resource: the whole manifest handed to `k8sManifest`, which
178
+ * the serializer writes as given. Property constructors do not apply, the
179
+ * kind's schema is unknown. Undefined when the apiVersion or kind cannot
180
+ * be found.
200
181
  */
201
- resolveClass(type) {
202
- if (TYPE_TO_CLASS[type])
203
- return TYPE_TO_CLASS[type];
204
- // Fallback: extract Kind from "K8s::Group::Kind"
205
- const parts = type.split("::");
206
- if (parts.length === 3 && parts[0] === "K8s")
207
- return parts[2];
208
- return undefined;
182
+ emitManifest(resource) {
183
+ const meta = resource.metadata ?? {};
184
+ const apiVersion = meta.apiVersion ?? resource.properties.apiVersion;
185
+ const kind = meta.kind ?? resource.type.split("::").pop();
186
+ if (typeof apiVersion !== "string" || typeof kind !== "string")
187
+ return undefined;
188
+ const rest = { ...resource.properties };
189
+ delete rest.apiVersion;
190
+ return `k8sManifest(${this.emitLiteral({ apiVersion, kind, ...rest }, 0, resource.type)})`;
209
191
  }
210
192
  collectNestedConstructors(props, used, parentType) {
211
193
  for (const [key, value] of Object.entries(props)) {
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/import/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAc,YAAY,EAAE,MAAM,gCAAgC,CAAC;AA2I3G;;;;;GAKG;AACH,qBAAa,SAAU,YAAW,cAAc;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,CAkCzD;IAED,OAAO,CAAC,aAAa;CAiCtB"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/import/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAc,YAAY,EAAE,MAAM,gCAAgC,CAAC;AA+I3G;;;;;GAKG;AACH,qBAAa,SAAU,YAAW,cAAc;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,CAqDzD;IAED,OAAO,CAAC,aAAa;CA2CtB"}
@@ -8,6 +8,7 @@
8
8
  import { parseYAML, splitYAMLDocuments } from "@intentius/chant/yaml";
9
9
  import { namespaceSegmentForGroup } from "../group-namespace.js";
10
10
  import { delegateEmbedded } from "./embedded.js";
11
+ import { importClassFor, keptApiVersionWarning, untypedKindWarning } from "./typed-classes.js";
11
12
  // ── GVK to type name mapping ───────────────────────────────────────
12
13
  /**
13
14
  * Well-known kind+apiVersion pairs mapped to K8s type names.
@@ -114,13 +115,16 @@ function apiVersionToGroup(apiVersion) {
114
115
  * Combines kind (lowercased first char) with the object name (PascalCased).
115
116
  *
116
117
  * E.g., kind="Deployment", name="my-app" → "deploymentMyApp"
118
+ * and kind="ClusterRole", name="system:node" gives "clusterRoleSystemNode".
117
119
  */
118
120
  function toLogicalId(kind, name) {
119
121
  const prefix = kind.charAt(0).toLowerCase() + kind.slice(1);
120
- if (!name)
122
+ if (typeof name !== "string" || !name)
121
123
  return prefix;
124
+ // Split on every character an identifier cannot hold (`:` in `system:node`,
125
+ // `/`, `@`, spaces), not only the `-_.` of DNS names.
122
126
  const pascalName = name
123
- .split(/[-_.]/)
127
+ .split(/[^A-Za-z0-9]+/)
124
128
  .map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1))
125
129
  .join("");
126
130
  return `${prefix}${pascalName}`;
@@ -141,6 +145,7 @@ export class K8sParser {
141
145
  */
142
146
  parse(content, context) {
143
147
  const resources = [];
148
+ const parseWarnings = [];
144
149
  const namespaces = new Set();
145
150
  // Split into documents on `---` / `...` markers (a trailing `# comment`
146
151
  // allowed); empty and comment-only documents are dropped (#2965).
@@ -149,7 +154,7 @@ export class K8sParser {
149
154
  const doc = parseYAML(docStr);
150
155
  if (!doc || typeof doc !== "object")
151
156
  continue;
152
- const resource = this.parseDocument(doc, context?.embedded);
157
+ const resource = this.parseDocument(doc, context?.embedded, parseWarnings);
153
158
  if (resource) {
154
159
  resources.push(resource);
155
160
  // Track namespaces
@@ -159,6 +164,21 @@ export class K8sParser {
159
164
  }
160
165
  }
161
166
  }
167
+ // One warning per kind the lexicon has no class for (#5070), and one per
168
+ // object kept at an apiVersion its class does not build (#5075).
169
+ const warnings = [...parseWarnings];
170
+ const warned = new Set();
171
+ for (const r of resources) {
172
+ const choice = importClassFor(r);
173
+ if (choice.reason === "other-apiVersion") {
174
+ warnings.push(keptApiVersionWarning(String(r.metadata?.kind), r.metadata?.originalName, choice.apiVersion, choice.builtApiVersion));
175
+ continue;
176
+ }
177
+ if (choice.cls || warned.has(r.type))
178
+ continue;
179
+ warned.add(r.type);
180
+ warnings.push(untypedKindWarning(String(r.metadata?.apiVersion), String(r.metadata?.kind)));
181
+ }
162
182
  const metadata = {};
163
183
  if (namespaces.size > 0) {
164
184
  metadata.namespaces = [...namespaces];
@@ -167,15 +187,24 @@ export class K8sParser {
167
187
  resources,
168
188
  parameters: [],
169
189
  metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
190
+ ...(warnings.length > 0 ? { warnings } : {}),
170
191
  };
171
192
  }
172
- parseDocument(doc, embedded) {
193
+ parseDocument(doc, embedded, warnings = []) {
173
194
  const apiVersion = doc.apiVersion;
174
195
  const kind = doc.kind;
175
196
  if (!apiVersion || !kind)
176
197
  return null;
177
198
  const metadata = (doc.metadata ?? {});
178
- const name = metadata.name;
199
+ // A template placeholder such as `name: {{name}}` is a YAML flow mapping,
200
+ // not a string. The object keeps its properties as written; the logical
201
+ // id comes from the kind alone.
202
+ const rawName = metadata.name;
203
+ if (rawName !== undefined && rawName !== null && typeof rawName !== "string") {
204
+ warnings.push(`${kind} (${apiVersion}): metadata.name is ${Array.isArray(rawName) ? "a list" : typeof rawName === "object" ? "a mapping" : `a ${typeof rawName}`}, not a string ` +
205
+ "(a template placeholder such as {{name}}?). The object is imported with the name as written; render the template first for a usable name.");
206
+ }
207
+ const name = typeof rawName === "string" ? rawName : undefined;
179
208
  const type = resolveTypeName(apiVersion, kind);
180
209
  const logicalId = toLogicalId(kind, name);
181
210
  // Extract the user-configurable properties (skip apiVersion, kind)
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Which `K8s::Group::Kind` types the k8s lexicon exports a class for, so
3
+ * `chant import` writes a class only when the module it imports from has it
4
+ * (#5070), and only when building that class gives back the apiVersion the
5
+ * file has (#5075).
6
+ */
7
+ import type { ResourceIR } from "@intentius/chant/import/parser";
8
+ /**
9
+ * Map K8s entity types to their constructor class names.
10
+ */
11
+ export declare const TYPE_TO_CLASS: Record<string, string>;
12
+ /**
13
+ * The class `@intentius/chant-lexicon-k8s` exports for an entity type, or
14
+ * undefined when it has none (a custom resource whose CRD is not in the
15
+ * lexicon). A class named like the kind counts only when it constructs this
16
+ * type: two groups can share a kind name.
17
+ */
18
+ export declare function exportedClassFor(type: string): string | undefined;
19
+ /**
20
+ * The warning for a kind with no class, once per kind. It names the way to
21
+ * get types: list the CRD under `k8s.crds` and run `chant generate`.
22
+ */
23
+ export declare function untypedKindWarning(apiVersion: string, kind: string): string;
24
+ /**
25
+ * The apiVersion the build writes for a class of this entity type, from the
26
+ * packaged lexicon (the same lookup the serializer makes), or undefined when
27
+ * this checkout has not generated it.
28
+ */
29
+ export declare function builtApiVersionFor(type: string): string | undefined;
30
+ /**
31
+ * How `chant import` writes one parsed object: the one place that decides it.
32
+ * `cls` is set when the object is written as `new <cls>(...)`; otherwise it
33
+ * is an untyped `k8sManifest` and `reason` says why.
34
+ *
35
+ * A class builds with its own apiVersion, so an object whose file says
36
+ * another one (`rbac.authorization.k8s.io/v1beta1` against a class that
37
+ * writes `v1`) would come back from the build at a version nobody wrote, and
38
+ * the fields may not mean the same thing there. Such an object stays
39
+ * untyped at the version in the file, with `builtApiVersion` naming what the
40
+ * class would have written. A document that carries its apiVersion as a
41
+ * property (see `ALIASED_GVKS` in ./parser.ts) builds with it, so it keeps
42
+ * its class.
43
+ */
44
+ export interface ImportClass {
45
+ cls?: string;
46
+ reason?: "no-class" | "other-apiVersion";
47
+ apiVersion?: string;
48
+ builtApiVersion?: string;
49
+ }
50
+ export declare function importClassFor(resource: Pick<ResourceIR, "type" | "properties" | "metadata">): ImportClass;
51
+ /**
52
+ * The warning for an object kept at its own apiVersion because the lexicon's
53
+ * class is for another one. Names the object, the version in the file and the
54
+ * version the class would have written.
55
+ */
56
+ export declare function keptApiVersionWarning(kind: string, name: string | undefined, apiVersion: string, builtApiVersion: string): string;
57
+ //# sourceMappingURL=typed-classes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-classes.d.ts","sourceRoot":"","sources":["../../src/import/typed-classes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAMjE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2ChD,CAAC;AAkBF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK3E;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUnE;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,UAAU,GAAG,kBAAkB,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC,GAAG,WAAW,CAS1G;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAKjI"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Which `K8s::Group::Kind` types the k8s lexicon exports a class for, so
3
+ * `chant import` writes a class only when the module it imports from has it
4
+ * (#5070), and only when building that class gives back the apiVersion the
5
+ * file has (#5075).
6
+ */
7
+ import { createRequire } from "module";
8
+ import { moduleSourceUrl } from "@intentius/chant/module-source";
9
+ // `require` is not defined where this runs as an ES module; the serializer
10
+ // reads the same file the same way.
11
+ const require = createRequire(moduleSourceUrl(import.meta.url));
12
+ /**
13
+ * Map K8s entity types to their constructor class names.
14
+ */
15
+ export const TYPE_TO_CLASS = {
16
+ // Core
17
+ "K8s::Core::Pod": "Pod",
18
+ "K8s::Core::Service": "Service",
19
+ "K8s::Core::ConfigMap": "ConfigMap",
20
+ "K8s::Core::Secret": "Secret",
21
+ "K8s::Core::Namespace": "Namespace",
22
+ "K8s::Core::ServiceAccount": "ServiceAccount",
23
+ "K8s::Core::PersistentVolume": "PersistentVolume",
24
+ "K8s::Core::PersistentVolumeClaim": "PersistentVolumeClaim",
25
+ "K8s::Core::Endpoints": "Endpoints",
26
+ "K8s::Core::LimitRange": "LimitRange",
27
+ "K8s::Core::ResourceQuota": "ResourceQuota",
28
+ // Apps
29
+ "K8s::Apps::Deployment": "Deployment",
30
+ "K8s::Apps::StatefulSet": "StatefulSet",
31
+ "K8s::Apps::DaemonSet": "DaemonSet",
32
+ "K8s::Apps::ReplicaSet": "ReplicaSet",
33
+ // Batch
34
+ "K8s::Batch::Job": "Job",
35
+ "K8s::Batch::CronJob": "CronJob",
36
+ // Networking
37
+ "K8s::Networking::Ingress": "Ingress",
38
+ "K8s::Networking::NetworkPolicy": "NetworkPolicy",
39
+ "K8s::Networking::IngressClass": "IngressClass",
40
+ // RBAC
41
+ "K8s::Rbac::Role": "Role",
42
+ "K8s::Rbac::ClusterRole": "ClusterRole",
43
+ "K8s::Rbac::RoleBinding": "RoleBinding",
44
+ "K8s::Rbac::ClusterRoleBinding": "ClusterRoleBinding",
45
+ // Autoscaling
46
+ "K8s::Autoscaling::HorizontalPodAutoscaler": "HorizontalPodAutoscaler",
47
+ // Policy
48
+ "K8s::Policy::PodDisruptionBudget": "PodDisruptionBudget",
49
+ // Storage
50
+ "K8s::Storage::StorageClass": "StorageClass",
51
+ };
52
+ let cachedEntries;
53
+ /** The packaged `lexicon-k8s.json`, or null when this checkout has not generated it. */
54
+ function lexiconEntries() {
55
+ if (cachedEntries !== undefined)
56
+ return cachedEntries;
57
+ try {
58
+ cachedEntries = require("../generated/lexicon-k8s.json");
59
+ }
60
+ catch {
61
+ cachedEntries = null;
62
+ }
63
+ return cachedEntries;
64
+ }
65
+ /**
66
+ * The class `@intentius/chant-lexicon-k8s` exports for an entity type, or
67
+ * undefined when it has none (a custom resource whose CRD is not in the
68
+ * lexicon). A class named like the kind counts only when it constructs this
69
+ * type: two groups can share a kind name.
70
+ */
71
+ export function exportedClassFor(type) {
72
+ const known = TYPE_TO_CLASS[type];
73
+ if (known)
74
+ return known;
75
+ const parts = type.split("::");
76
+ if (parts.length !== 3 || parts[0] !== "K8s")
77
+ return undefined;
78
+ const entries = lexiconEntries();
79
+ return entries?.[parts[2]]?.resourceType === type ? parts[2] : undefined;
80
+ }
81
+ /**
82
+ * The warning for a kind with no class, once per kind. It names the way to
83
+ * get types: list the CRD under `k8s.crds` and run `chant generate`.
84
+ */
85
+ export function untypedKindWarning(apiVersion, kind) {
86
+ return (`${kind} (${apiVersion}) has no class in @intentius/chant-lexicon-k8s; written as an untyped k8sManifest. ` +
87
+ "To get a typed class, list its CRD under k8s.crds in chant.config.ts and run chant generate.");
88
+ }
89
+ let cachedBuiltVersions;
90
+ /**
91
+ * The apiVersion the build writes for a class of this entity type, from the
92
+ * packaged lexicon (the same lookup the serializer makes), or undefined when
93
+ * this checkout has not generated it.
94
+ */
95
+ export function builtApiVersionFor(type) {
96
+ if (!cachedBuiltVersions) {
97
+ cachedBuiltVersions = new Map();
98
+ for (const entry of Object.values(lexiconEntries() ?? {})) {
99
+ if (entry.resourceType && entry.apiVersion && !cachedBuiltVersions.has(entry.resourceType)) {
100
+ cachedBuiltVersions.set(entry.resourceType, entry.apiVersion);
101
+ }
102
+ }
103
+ }
104
+ return cachedBuiltVersions.get(type);
105
+ }
106
+ export function importClassFor(resource) {
107
+ const cls = exportedClassFor(resource.type);
108
+ const apiVersion = resource.metadata?.apiVersion;
109
+ if (!cls)
110
+ return { reason: "no-class", ...(typeof apiVersion === "string" ? { apiVersion } : {}) };
111
+ if (typeof apiVersion !== "string")
112
+ return { cls };
113
+ const written = resource.properties?.apiVersion ?? builtApiVersionFor(resource.type);
114
+ if (written === undefined || written === apiVersion)
115
+ return { cls };
116
+ return { reason: "other-apiVersion", apiVersion, builtApiVersion: String(written) };
117
+ }
118
+ /**
119
+ * The warning for an object kept at its own apiVersion because the lexicon's
120
+ * class is for another one. Names the object, the version in the file and the
121
+ * version the class would have written.
122
+ */
123
+ export function keptApiVersionWarning(kind, name, apiVersion, builtApiVersion) {
124
+ return (`${kind}${name ? ` ${name}` : ""} (${apiVersion}): the class in @intentius/chant-lexicon-k8s builds ${builtApiVersion}, ` +
125
+ "so it is written as an untyped k8sManifest that keeps the apiVersion from the file.");
126
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "f925154a1ee9abd9d57646ae662a93628fbb67ae39e827c75679cd32b140cd54",
4
+ "manifest.json": "8368ab161dc1f27630cf3d163a6fb0ae8e9a00d8c20d7c07b19c753b54b58410",
5
5
  "meta.json": "e187074ca194ceaf969a3e2f9a85a0be42e7935de316817f309f6c9bee4eb952",
6
6
  "types/index.d.ts": "35f6ca4fa77c28ecad363920b444f27ab72f0fe49e82eb20e42824c312ac689b",
7
7
  "rules/argo-appset-single-project.ts": "afa9f310753aa2d475f35012b13135b2dfaebed2a35d44edbe185ebc07673674",
@@ -11,50 +11,50 @@
11
11
  "rules/hardcoded-namespace.ts": "4b149cddd01cf9f8fc539bd1e499226a3fb06ba21dff74c71ec18e5335a4eca7",
12
12
  "rules/latest-image-tag.ts": "fa53d7fd8b60e6ee27b37dc2687964339061de5dab12118bf1878d85c0e31c47",
13
13
  "rules/missing-resource-limits.ts": "afc3376962765f64984786e4f42c02575c34d6f2c1bfc3f30fb73a7d1a7f99bd",
14
- "rules/argo-helpers.ts": "ac68a33978b03c0fde7a6e4fa0c9a8907c21d11012d9408b6db64c66cb7ec635",
15
- "rules/argo002.ts": "d2f07daabfc7a4624d3d60ea151fd2380d43f1578dd6a17825f6f6e0ebc610ba",
16
- "rules/argo003.ts": "a61024fbd3db772eface6b2e4fee618a5818f12a1050faea8e358e0fdc992396",
17
- "rules/argo005.ts": "611ea489e005e3ead925013e636f0d7c6899fd0ce68c59a97541fc6fe4e8d25c",
18
- "rules/crd-schema-helpers.ts": "131783fd70ccb3e829084550f6e66e5af3d436d909803b2ab60b5c06f9f32039",
19
- "rules/flux002.ts": "4269ce13121bc5b28c02aad06765dc85085a1c9ebcc936ae958663b85de07bc6",
20
- "rules/flux003.ts": "a174af9941bd2491a9bbf72039ab2fc4d4f4de388b2884ddf7123f05594d9d4e",
21
- "rules/k8s-helpers.ts": "868cac99b4505a8e060384a716047646da1583568ef6da471a186dc760961212",
14
+ "rules/argo-helpers.ts": "5060db3c1cfb6498b77a3100af46886acd90a3a0ae2e568704935f0904c33d60",
15
+ "rules/argo002.ts": "0ff0e1bb18dd22e974d78bb3071cdddcd1599800910f17aac2c36db5526a452a",
16
+ "rules/argo003.ts": "ae43d069d7cc93d95be45b4b92b52dacba814c0f4f86dfe3d1672781bdfca254",
17
+ "rules/argo005.ts": "d2ddb5782776d766b886b94157a070dec7945311918a9ec4d71cfdfb025dfb2e",
18
+ "rules/crd-schema-helpers.ts": "8e06144c5b2ad90fc2c635f76391e53cfb8e5f0ddbf1cde25079a1273f9bc3e5",
19
+ "rules/flux002.ts": "2cbb21eb452f39f74ba8c79d9cecc62b65148d1f9b5edeaaf589b621aab4f64a",
20
+ "rules/flux003.ts": "83927d3e199492e7a3af96e4ac38257d6ae417fe3993e712915b6c8179ffcaac",
21
+ "rules/k8s-helpers.ts": "da1ef8578b15ee2af2df22d41e5193fbe0555c787a9112c24d343ccaccc9be75",
22
22
  "rules/monitoring-selection-helpers.ts": "34537f8d3bbdb81e4353997e77063030adb5bc55571425365cf037c4107bfc26",
23
23
  "rules/otel-placement-helpers.ts": "0d43cb3a5339fc614f3c8e1bbd505b9eccd04dfc25f185232727660b4a27c8ef",
24
24
  "rules/sops-helpers.ts": "c2b8e08e7d292e770fd4761ad2a55e165c7cd375768b709491165cbf4fa1ba51",
25
- "rules/wk8005.ts": "c80c4962e2015ce15266dd2080014fcabf1412ca35e8475ae41aa895c5684b78",
26
- "rules/wk8006.ts": "3992f695985fd8473f6bc1f85027f13b0824f7c0bd1c1305a0a29a3c0757f45a",
27
- "rules/wk8041.ts": "7ce5b4b6f3b0b40ef50bd90dcc0f355de5169d4c44130df3120c71fa4e81f617",
28
- "rules/wk8042.ts": "a063e0d49540d4ea67de5382c7b3561c1ebb52d227b5f5e957c57031e811bf83",
29
- "rules/wk8101.ts": "3af21df238f4dc55d3f3ed10f7ddc97b6fe9612c1e0bb7a646cd6e9cc7e749b0",
30
- "rules/wk8102.ts": "6b7ffc802341fad34e008b2dd5e6a9e3e238d753095808602a2c7cb721572170",
31
- "rules/wk8103.ts": "6759ca2f7aa0d93c4975da8bd0e4402864c94127efb2ed7c7cb192465c4baa4c",
32
- "rules/wk8104.ts": "8f83d7fa7e5164e956130684103ead1dcd4d6a4f3b8de96b12ede1f3c79aaa77",
33
- "rules/wk8105.ts": "69eaef8aa7d82d703d686e53c561ee43b3857e1ac4a50b3bc99af338308e8c1f",
34
- "rules/wk8201.ts": "fccf7d731b4025557dfb4172c84568df144ead0d55a58223993000327b83ab6c",
35
- "rules/wk8202.ts": "1949c08013f5b031be1d1efe07175c7e87dd0335640ac6841af9cff53a8ea95a",
36
- "rules/wk8203.ts": "5ce81de30107f5a5275dfec5a6e3c276648d8ace059936f8b6a728ee30f893a6",
37
- "rules/wk8204.ts": "95e13194e70aa8a9f0767cc407bba2ec075c7887b50b7ca17597c46613350c9c",
38
- "rules/wk8205.ts": "721d3351c175eb77d4c758c400ba2b7d355a39ade48b22b2ecd8dfc87a94bb70",
39
- "rules/wk8207.ts": "a117ed20207987eca5a6ff417e02dc3b237a64e6724e3124b3ff154f365f7940",
40
- "rules/wk8208.ts": "3c41d08ae274a77aab919fcf02ff939e94eb9211c8e6eee9946a7ec8ecccc6b8",
41
- "rules/wk8209.ts": "ac9ff3748dbca62ea7c1145e3cd180886a3092de91d784ab9b4d24f0f92dac7b",
42
- "rules/wk8301.ts": "04bc6b98ad4194ed24a7e08643c53627f648fede5b1b6dd117e6864c16598771",
43
- "rules/wk8302.ts": "87f21e7869ac5f3d37d3fd2f106316de6c59d1c195c1fa19d6890e61fd53b353",
44
- "rules/wk8303.ts": "d69766dddbad1cc53f31ef0600e3668e866ff6e48518cebc4f486a26167c78ee",
45
- "rules/wk8304.ts": "c7fa1dcda03e9e0936cc70f6846f8071c9674b42debc1ac4ac6829f86fbd6dbe",
46
- "rules/wk8305.ts": "fc96dac7c65eba1ab7ec849b7de145856c005b21ab3751979374b513ca1744d1",
47
- "rules/wk8306.ts": "871dead6cfebcfd4110e048edaf47bd591b0f97a0288aceda1707f9e16fcd749",
48
- "rules/wk8401.ts": "9c491a161587282fbc56c8cdaba1c944940e89f497bbb0d24d4cc3737cb2a754",
49
- "rules/wk8402.ts": "0da5f0856ab5639e4327d8f184b453543435506ce2779cd082590251601f8ee2",
50
- "rules/wk8403.ts": "b68ddb1b00d85970fc0b864e8331cf4ac663bd830dd05e1812b79e1095734b53",
51
- "rules/wk8404.ts": "4899e584d8ccd27d1196a653dd1326af84780e5e99ba48d320fc52b2545e050b",
52
- "rules/wk8405.ts": "8ad90d6939d9b7de26a0805c0460296139c6419aa3b447ad130bdacfb5077c8a",
53
- "rules/wk8406.ts": "2a9a602ae7f6a6631c88c8d5165e3b077a051c75ac2d8241289358f30f5dadf4",
54
- "rules/wk8407.ts": "094eeee7f3a541c0f845bb7e7a41930216dbfb5498215415a1655776fd9351de",
25
+ "rules/wk8005.ts": "2d89d65e8536a37b69c318526eaf4dd5239c1a198051088b79a9f131e2083832",
26
+ "rules/wk8006.ts": "398b0455e55ae2beab6aa61f13ecfdc71063a8eeac96c7ad692727c15788ada4",
27
+ "rules/wk8041.ts": "6828bffd871d24355074f03a5c58f67749b4f99ec34fd7dd1c50f3bc03773ded",
28
+ "rules/wk8042.ts": "b25fd40f413bb76a7da4a58848fd2227e85968afb331d9fcdb246e1db70dfda5",
29
+ "rules/wk8101.ts": "10251cc23aaa6a520d0c683c1d103cf8d67b43c206f0119bf619e9fd48785802",
30
+ "rules/wk8102.ts": "8178aad5e4b7b17f475e4af702d73d65f19fb705130d965e8a93ea50bcebcd97",
31
+ "rules/wk8103.ts": "1d0f49bbaef32ff8ffa846b254f3b4250655e86d8354be1a87e64779d638aea6",
32
+ "rules/wk8104.ts": "4a6b2516580f74cce7576f2c04a7b1c92ee090fd0be20c87b41c78c4e718d440",
33
+ "rules/wk8105.ts": "d7f1ea1ecbfae12d0234ecc08efd90b902963f417e461b356cdb751cbef91dc3",
34
+ "rules/wk8201.ts": "0c96a044f872d43caf03974180180c710215fbc831736d446745b72b89fe3ff8",
35
+ "rules/wk8202.ts": "a9118ec194059f3239c8c44cab93a21728542f7ed0bc4a2141e09356098e8d9c",
36
+ "rules/wk8203.ts": "baffe9e669aaf2017211df0134e763bd88b34342ee29b8665f459b4d1adaa99e",
37
+ "rules/wk8204.ts": "df8aa7a6620a562335665cfdb975dd2a71fad796e48e09d3905b5239b3ce1fb0",
38
+ "rules/wk8205.ts": "8a03b91c8343247acb40f057d30ca802e00b108d54db67585a5a2f85fdffa795",
39
+ "rules/wk8207.ts": "b4cde2d592711f27999efdb39cdafb5fd8a5fd8c96c091c798588313d1727e22",
40
+ "rules/wk8208.ts": "f6fde8e196545d5581673f3c96dcea7b163686e368a59dd438e484267ec62de5",
41
+ "rules/wk8209.ts": "cdcccc59a9ce6120a031092a0d5b17740fbbc58e3699df5bdd7e089fadbd88c5",
42
+ "rules/wk8301.ts": "b7b22bbb0da64c33f2dcca4093cf5f7bb917d0694560910e6c0784b64cc5bee8",
43
+ "rules/wk8302.ts": "b6a494fb93d7ce7b7264cbffe39df37be84cf6e745e9f5eb17360effd2703058",
44
+ "rules/wk8303.ts": "983bc332a3976898b3e613414beb26bb8d656eb04e781b0d8cd7ce607f1874f1",
45
+ "rules/wk8304.ts": "439eab1c94cce39a6a24299f25662d93d9395bdb5188bc73663d05b82a268208",
46
+ "rules/wk8305.ts": "07540ddfcd3eed0e07edefe7028060353bd992c028cd870ae83b0b3a015d6e3c",
47
+ "rules/wk8306.ts": "a1cc86010b824e58f37b0e09e7ab51bc1ef948901b07c1aaefe10365dc7f1ef6",
48
+ "rules/wk8401.ts": "8311519c54d606ce8e772b20d876a5488cd3c8b8167d61b1a43769283d7c4fd3",
49
+ "rules/wk8402.ts": "566a793b069cebde9d9f8d9bb4cbc46c15bacd1ac6d5e4606d69eb2df253b82e",
50
+ "rules/wk8403.ts": "adeb3b39a3ed651b00f718754daf04c21f49cba4cf84bc4d511bfbbc2608dc22",
51
+ "rules/wk8404.ts": "b5fc9e9f8863b370610188bb42b200cb321b4cc8f4e5fdea8565f64671f89e50",
52
+ "rules/wk8405.ts": "dc48d01833eb39b3198d5af87ae197d345cf872b751565e74d5586b2f6918c53",
53
+ "rules/wk8406.ts": "a5c268b4a2b8b273fc96a1a28fb2b7c8c696d74473b5e983d39e83c1a0209724",
54
+ "rules/wk8407.ts": "93a4e7df01d5d8733b1ae2d7b9e3b32e2de8182b5a199c92074af09e04af54dd",
55
55
  "rules/wk8501.ts": "7de8c368ae0b0a2678441a97ec6bed8172f1f127bad6a8441b39ea8d1d4f1dd3",
56
56
  "rules/wk8502.ts": "c13813543b4ec42b9b87d2ebfe20bae3e6e954a8d7c4e9387581a753484aa778",
57
- "rules/wk8503.ts": "4ee80ded81a0b2cff24013b300ee3fcadbfd29e20346b964a97e557afa1147f3",
57
+ "rules/wk8503.ts": "ed7d56e3546a0ab2bdebb41a4445e433d54531174bd567a98994d0adbf7768d4",
58
58
  "rules/wk8504.ts": "b1dd7689e37f788fb4524c42254d5d99048a38203643a405f25383ac21b74e36",
59
59
  "rules/wk8505.ts": "b866168e8c8ed55edb5d69666258cdb6c4a2e2db3e41951a59fe54fd7d5bda5b",
60
60
  "rules/wk8601.ts": "d086334847a083f2c90cbf0232a34af9df2b794d69f8b136227de34b04ca0147",
@@ -78,5 +78,5 @@
78
78
  "skills/chant-k8s-argo.md": "24c9a85b78a2fc5c6657424baac9cc6d6caff6f47605b8146b2c0082133181cf",
79
79
  "skills/chant-k8s-flux.md": "9670efc2e9854bd14686b5adeb707396b9030a4dcaee6529b30abf56efe2c50c"
80
80
  },
81
- "composite": "ccdcd64c7256ae88f02ff947c2d565f37ad5bc53a97ebc99eebb2429ba9a092b"
81
+ "composite": "32f1dcf4d290aabbf5c9aefd9fc05f8d5829b9feb608a6d9aa39af8082113ff9"
82
82
  }
@@ -3,8 +3,47 @@ export type KustomizeRunner = (command: string) => Promise<{
3
3
  stdout: string;
4
4
  }>;
5
5
  export declare const defaultKustomizeRunner: KustomizeRunner;
6
+ /**
7
+ * Helm inflation for a render (#5112). A kustomization with `helmCharts` only
8
+ * renders when kustomize is given `--enable-helm`, and kustomize then runs
9
+ * `helm pull` for any chart that is not already in the chart home, which
10
+ * reaches the network. Both are off until the caller asks.
11
+ */
12
+ export interface KustomizeHelmOptions {
13
+ /** Pass `--enable-helm`. Without it a kustomization that has `helmCharts` is refused with a message naming this option. */
14
+ enableHelm?: boolean;
15
+ /** The `helm` binary, passed as `--helm-command`. Unset, kustomize looks for `helm` on PATH. */
16
+ helmCommand?: string;
17
+ /** Let kustomize pull a chart that is not in the chart home. Unset, a chart that is missing fails naming the chart, and no network is used. Needs `enableHelm`. */
18
+ fetchCharts?: boolean;
19
+ }
6
20
  /** The exact render command, standalone binary first. Pure; exported for tests. */
7
- export declare function renderCommand(dir: string, tool?: "kustomize" | "kubectl"): string;
21
+ export declare function renderCommand(dir: string, tool?: "kustomize" | "kubectl", helm?: KustomizeHelmOptions): string;
22
+ /**
23
+ * A kustomization names a chart and the render was not allowed to inflate it
24
+ * (`enableHelm` unset). A class of its own so the workspace graph reader tells
25
+ * it from a render the binary ran and refused.
26
+ */
27
+ export declare class KustomizeHelmDisabledError extends Error {
28
+ constructor(message: string);
29
+ }
30
+ /**
31
+ * Helm inflation was asked for and a chart could not be had: it is not in the
32
+ * chart home and `fetchCharts` is off, or helm failed on it. The member reader
33
+ * keeps the Helm nodes it read as data when it sees this.
34
+ */
35
+ export declare class KustomizeHelmRenderError extends Error {
36
+ constructor(message: string);
37
+ }
38
+ /**
39
+ * Check a render's Helm settings before any subprocess runs. With inflation
40
+ * off, a kustomization that has `helmCharts` is refused here, naming the
41
+ * charts and the option. With it on and `fetchCharts` off, a chart that is
42
+ * not in its chart home is refused naming the chart and the directory it is
43
+ * expected in, so a render with no network says what is missing and never
44
+ * starts a pull. Kustomizations the root lists are checked too.
45
+ */
46
+ export declare function checkHelmOptions(dir: string, helm?: KustomizeHelmOptions): void;
8
47
  /**
9
48
  * Neither `kustomize` nor `kubectl` is installed. A class of its own so a
10
49
  * caller that can say "not rendered, and why" (the workspace graph reader,
@@ -19,5 +58,5 @@ export declare class KustomizeBinaryMissingError extends Error {
19
58
  * binary is missing; when both binaries are missing, fails with a message
20
59
  * naming them.
21
60
  */
22
- export declare function renderKustomizeDocuments(dir: string, run?: KustomizeRunner): Promise<Array<Record<string, unknown>>>;
61
+ export declare function renderKustomizeDocuments(dir: string, run?: KustomizeRunner, helm?: KustomizeHelmOptions): Promise<Array<Record<string, unknown>>>;
23
62
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/kustomize/render.ts"],"names":[],"mappings":"AA4BA,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/E,eAAO,MAAM,sBAAsB,EAAE,eACgB,CAAC;AAOtD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,GAAG,SAAuB,GAAG,MAAM,CAE9F;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAQD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,eAAwC,GAC5C,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAwBzC"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/kustomize/render.ts"],"names":[],"mappings":"AA+BA,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/E,eAAO,MAAM,sBAAsB,EAAE,eACgB,CAAC;AAOtD;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,2HAA2H;IAC3H,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gGAAgG;IAChG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mKAAmK;IACnK,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,GAAG,SAAuB,EAAE,IAAI,GAAE,oBAAyB,GAAG,MAAM,CAG/H;AAED;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAuCD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB,GAAG,IAAI,CAoBnF;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAgCD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,eAAwC,EAC7C,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAyBzC"}