@intentius/chant-lexicon-k8s 0.124.98 → 0.124.100

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 (941) hide show
  1. package/dist/actions/apps.d.ts +0 -1
  2. package/dist/actions/batch.d.ts +0 -1
  3. package/dist/actions/core.d.ts +0 -1
  4. package/dist/actions/index.d.ts +0 -1
  5. package/dist/actions/networking.d.ts +0 -1
  6. package/dist/actions/rbac.d.ts +0 -1
  7. package/dist/api/classify.d.ts +0 -1
  8. package/dist/api/connect.d.ts +0 -1
  9. package/dist/api/fake-cluster.d.ts +0 -1
  10. package/dist/api/operation-surface.d.ts +0 -1
  11. package/dist/api/owner-chain.d.ts +0 -1
  12. package/dist/api/sweep-types.d.ts +0 -1
  13. package/dist/application-paths.d.ts +0 -1
  14. package/dist/application-set.d.ts +0 -1
  15. package/dist/behaviour-kinds.d.ts +0 -1
  16. package/dist/cluster-secret.d.ts +0 -1
  17. package/dist/codegen/docs-cli.d.ts +0 -1
  18. package/dist/codegen/docs.d.ts +0 -1
  19. package/dist/codegen/generate-cli.d.ts +0 -1
  20. package/dist/codegen/generate-lexicon.d.ts +7 -1
  21. package/dist/codegen/generate-lexicon.js +2 -0
  22. package/dist/codegen/generate-list-map-keys.d.ts +0 -1
  23. package/dist/codegen/generate-operations.d.ts +0 -1
  24. package/dist/codegen/generate-typescript.d.ts +0 -1
  25. package/dist/codegen/generate.d.ts +0 -1
  26. package/dist/codegen/naming.d.ts +0 -1
  27. package/dist/codegen/package.d.ts +0 -1
  28. package/dist/codegen/patches.d.ts +0 -1
  29. package/dist/codegen/typecheck.d.ts +0 -1
  30. package/dist/codegen/versions.d.ts +0 -1
  31. package/dist/components/argo-app.d.ts +0 -1
  32. package/dist/components/builders.d.ts +0 -1
  33. package/dist/components/capability-plugin.d.ts +0 -1
  34. package/dist/components/flux-reconcile.d.ts +0 -1
  35. package/dist/components/index.d.ts +0 -1
  36. package/dist/components/kubectl-apply.d.ts +0 -1
  37. package/dist/components/kustomize-apply.d.ts +0 -1
  38. package/dist/composites/adot-collector.d.ts +0 -1
  39. package/dist/composites/agic-ingress.d.ts +0 -1
  40. package/dist/composites/aks-external-dns-agent.d.ts +0 -1
  41. package/dist/composites/alb-ingress.d.ts +0 -1
  42. package/dist/composites/argo-app.d.ts +0 -1
  43. package/dist/composites/autoscaled-service.d.ts +0 -1
  44. package/dist/composites/azure-disk-storage-class.d.ts +0 -1
  45. package/dist/composites/azure-file-storage-class.d.ts +0 -1
  46. package/dist/composites/azure-monitor-collector.d.ts +0 -1
  47. package/dist/composites/batch-job.d.ts +0 -1
  48. package/dist/composites/catalog.d.ts +0 -1
  49. package/dist/composites/cockroachdb-cluster.d.ts +0 -1
  50. package/dist/composites/cockroachdb-region-stack.d.ts +0 -1
  51. package/dist/composites/config-connector-context.d.ts +0 -1
  52. package/dist/composites/configured-app.d.ts +0 -1
  53. package/dist/composites/cron-schedule.d.ts +0 -1
  54. package/dist/composites/cron-workload.d.ts +0 -1
  55. package/dist/composites/ebs-storage-class.d.ts +0 -1
  56. package/dist/composites/efs-storage-class.d.ts +0 -1
  57. package/dist/composites/external-dns-agent.d.ts +0 -1
  58. package/dist/composites/filestore-storage-class.d.ts +0 -1
  59. package/dist/composites/fluent-bit-agent.d.ts +0 -1
  60. package/dist/composites/flux-app.d.ts +0 -1
  61. package/dist/composites/gce-ingress.d.ts +0 -1
  62. package/dist/composites/gce-pd-storage-class.d.ts +0 -1
  63. package/dist/composites/gke-external-dns-agent.d.ts +0 -1
  64. package/dist/composites/gke-fluent-bit-agent.d.ts +0 -1
  65. package/dist/composites/gke-gateway.d.ts +0 -1
  66. package/dist/composites/gke-otel-collector.d.ts +0 -1
  67. package/dist/composites/index.d.ts +0 -1
  68. package/dist/composites/inference-service.d.ts +0 -1
  69. package/dist/composites/irsa-service-account.d.ts +0 -1
  70. package/dist/composites/member-defaults.d.ts +0 -1
  71. package/dist/composites/metrics-server.d.ts +0 -1
  72. package/dist/composites/model.d.ts +0 -1
  73. package/dist/composites/monitored-service.d.ts +0 -1
  74. package/dist/composites/namespace-env.d.ts +0 -1
  75. package/dist/composites/network-isolated-app.d.ts +0 -1
  76. package/dist/composites/node-agent.d.ts +0 -1
  77. package/dist/composites/operator-stack.d.ts +0 -1
  78. package/dist/composites/otel-collector-agent.d.ts +0 -1
  79. package/dist/composites/otel-collector-gateway.d.ts +0 -1
  80. package/dist/composites/otel-collector-node.d.ts +0 -1
  81. package/dist/composites/otel-collector-rbac.d.ts +0 -1
  82. package/dist/composites/otel-collector-shape.d.ts +0 -1
  83. package/dist/composites/otel-collector.d.ts +0 -1
  84. package/dist/composites/otel-operator-collector.d.ts +0 -1
  85. package/dist/composites/ray-cluster.d.ts +0 -1
  86. package/dist/composites/ray-job.d.ts +0 -1
  87. package/dist/composites/ray-service.d.ts +0 -1
  88. package/dist/composites/secure-ingress.d.ts +0 -1
  89. package/dist/composites/security-context.d.ts +0 -1
  90. package/dist/composites/sidecar-app.d.ts +0 -1
  91. package/dist/composites/stateful-app.d.ts +0 -1
  92. package/dist/composites/vllm-serving-runtime.d.ts +0 -1
  93. package/dist/composites/web-app.d.ts +0 -1
  94. package/dist/composites/worker-pool.d.ts +0 -1
  95. package/dist/composites/workload-identity-sa.d.ts +0 -1
  96. package/dist/composites/workload-identity-service-account.d.ts +0 -1
  97. package/dist/config-schema.d.ts +0 -1
  98. package/dist/config.d.ts +0 -1
  99. package/dist/coverage.d.ts +0 -1
  100. package/dist/crd/crd-sources.d.ts +0 -1
  101. package/dist/crd/loader.d.ts +0 -1
  102. package/dist/crd/oci-chart.d.ts +0 -1
  103. package/dist/crd/parser.d.ts +0 -1
  104. package/dist/crd/parser.js +3 -0
  105. package/dist/crd/project-codegen.d.ts +0 -1
  106. package/dist/crd/types.d.ts +0 -1
  107. package/dist/deep-observe-hooks.d.ts +0 -1
  108. package/dist/deep-observe.d.ts +0 -1
  109. package/dist/default-labels.d.ts +0 -1
  110. package/dist/describe-resources.d.ts +0 -1
  111. package/dist/describe-stack-status.d.ts +0 -1
  112. package/dist/detect.d.ts +0 -1
  113. package/dist/effect-receipt-row.d.ts +0 -1
  114. package/dist/export-resources.d.ts +0 -1
  115. package/dist/generated/index.d.ts +0 -1
  116. package/{src → dist}/generated/lexicon-k8s.json +1984 -155
  117. package/dist/generated/runtime.d.ts +0 -1
  118. package/dist/group-namespace.d.ts +0 -1
  119. package/dist/helm-references.d.ts +0 -1
  120. package/dist/import/directory.d.ts +7 -0
  121. package/dist/import/directory.js +103 -0
  122. package/dist/import/embedded.d.ts +3 -1
  123. package/dist/import/embedded.js +34 -0
  124. package/dist/import/generator.d.ts +2 -3
  125. package/dist/import/generator.js +6 -2
  126. package/dist/import/live-export.d.ts +0 -1
  127. package/dist/import/parser.d.ts +0 -1
  128. package/dist/import/parser.js +34 -7
  129. package/dist/import/testdata/embedded/fixtures.d.ts +0 -1
  130. package/dist/import/typed-classes.d.ts +21 -2
  131. package/dist/import/typed-classes.js +41 -3
  132. package/dist/include/entity.d.ts +0 -1
  133. package/dist/include/resolve.d.ts +0 -1
  134. package/dist/index-identity.d.ts +0 -1
  135. package/dist/index-import.d.ts +0 -1
  136. package/dist/index.d.ts +0 -1
  137. package/dist/integrity.json +5 -3
  138. package/dist/kube/apply.d.ts +0 -1
  139. package/dist/kube/connect.d.ts +0 -1
  140. package/dist/kube/delete.d.ts +0 -1
  141. package/dist/kube/describe.d.ts +0 -1
  142. package/dist/kube/events.d.ts +0 -1
  143. package/dist/kube/flags.d.ts +0 -1
  144. package/dist/kube/get.d.ts +0 -1
  145. package/dist/kube/group.d.ts +0 -1
  146. package/dist/kube/logs.d.ts +0 -1
  147. package/dist/kube/project.d.ts +0 -1
  148. package/dist/kube/render.d.ts +0 -1
  149. package/dist/kube/source.d.ts +0 -1
  150. package/dist/kube/target.d.ts +0 -1
  151. package/dist/kube/testing.d.ts +0 -1
  152. package/dist/kube/top.d.ts +0 -1
  153. package/dist/kube/verdict.d.ts +0 -1
  154. package/dist/kube/wait.d.ts +0 -1
  155. package/dist/kustomize/render.d.ts +0 -1
  156. package/dist/kustomize/rendered-entity.d.ts +0 -1
  157. package/dist/kustomize/root.d.ts +0 -1
  158. package/dist/lint/audit-catalog.d.ts +0 -1
  159. package/dist/lint/audit-catalog.js +1 -0
  160. package/dist/lint/audit-lineage.d.ts +0 -1
  161. package/dist/lint/post-synth/argo-helpers.d.ts +0 -1
  162. package/dist/lint/post-synth/argo002.d.ts +0 -1
  163. package/dist/lint/post-synth/argo003.d.ts +0 -1
  164. package/dist/lint/post-synth/argo005.d.ts +0 -1
  165. package/dist/lint/post-synth/crd-schema-helpers.d.ts +0 -1
  166. package/dist/lint/post-synth/flux002.d.ts +0 -1
  167. package/dist/lint/post-synth/flux003.d.ts +0 -1
  168. package/dist/lint/post-synth/index.d.ts +0 -1
  169. package/dist/lint/post-synth/index.js +2 -0
  170. package/dist/lint/post-synth/k8s-helpers.d.ts +0 -1
  171. package/dist/lint/post-synth/monitoring-selection-helpers.d.ts +0 -1
  172. package/dist/lint/post-synth/otel-placement-helpers.d.ts +0 -1
  173. package/dist/lint/post-synth/sops-helpers.d.ts +0 -1
  174. package/dist/lint/post-synth/top-level-fields-helpers.d.ts +16 -0
  175. package/dist/lint/post-synth/top-level-fields-helpers.js +45 -0
  176. package/dist/lint/post-synth/wk8005.d.ts +0 -1
  177. package/dist/lint/post-synth/wk8006.d.ts +0 -1
  178. package/dist/lint/post-synth/wk8041.d.ts +0 -1
  179. package/dist/lint/post-synth/wk8042.d.ts +0 -1
  180. package/dist/lint/post-synth/wk8101.d.ts +0 -1
  181. package/dist/lint/post-synth/wk8102.d.ts +0 -1
  182. package/dist/lint/post-synth/wk8103.d.ts +0 -1
  183. package/dist/lint/post-synth/wk8104.d.ts +0 -1
  184. package/dist/lint/post-synth/wk8105.d.ts +0 -1
  185. package/dist/lint/post-synth/wk8201.d.ts +0 -1
  186. package/dist/lint/post-synth/wk8202.d.ts +0 -1
  187. package/dist/lint/post-synth/wk8203.d.ts +0 -1
  188. package/dist/lint/post-synth/wk8204.d.ts +0 -1
  189. package/dist/lint/post-synth/wk8205.d.ts +0 -1
  190. package/dist/lint/post-synth/wk8207.d.ts +0 -1
  191. package/dist/lint/post-synth/wk8208.d.ts +0 -1
  192. package/dist/lint/post-synth/wk8209.d.ts +0 -1
  193. package/dist/lint/post-synth/wk8301.d.ts +0 -1
  194. package/dist/lint/post-synth/wk8302.d.ts +0 -1
  195. package/dist/lint/post-synth/wk8303.d.ts +0 -1
  196. package/dist/lint/post-synth/wk8304.d.ts +0 -1
  197. package/dist/lint/post-synth/wk8305.d.ts +0 -1
  198. package/dist/lint/post-synth/wk8306.d.ts +0 -1
  199. package/dist/lint/post-synth/wk8401.d.ts +0 -1
  200. package/dist/lint/post-synth/wk8402.d.ts +0 -1
  201. package/dist/lint/post-synth/wk8403.d.ts +0 -1
  202. package/dist/lint/post-synth/wk8404.d.ts +0 -1
  203. package/dist/lint/post-synth/wk8405.d.ts +0 -1
  204. package/dist/lint/post-synth/wk8406.d.ts +0 -1
  205. package/dist/lint/post-synth/wk8407.d.ts +0 -1
  206. package/dist/lint/post-synth/wk8501.d.ts +0 -1
  207. package/dist/lint/post-synth/wk8502.d.ts +0 -1
  208. package/dist/lint/post-synth/wk8503.d.ts +0 -1
  209. package/dist/lint/post-synth/wk8504.d.ts +0 -1
  210. package/dist/lint/post-synth/wk8505.d.ts +0 -1
  211. package/dist/lint/post-synth/wk8506.d.ts +14 -0
  212. package/dist/lint/post-synth/wk8506.js +38 -0
  213. package/dist/lint/post-synth/wk8601.d.ts +0 -1
  214. package/dist/lint/post-synth/wk8602.d.ts +0 -1
  215. package/dist/lint/post-synth/wk8603.d.ts +0 -1
  216. package/dist/lint/post-synth/wk8604.d.ts +0 -1
  217. package/dist/lint/post-synth/wk8605.d.ts +0 -1
  218. package/dist/lint/post-synth/wk8606.d.ts +0 -1
  219. package/dist/lint/post-synth/wk8701.d.ts +0 -1
  220. package/dist/lint/post-synth/wk8702.d.ts +0 -1
  221. package/dist/lint/post-synth/wk8703.d.ts +0 -1
  222. package/dist/lint/post-synth/wk8704.d.ts +0 -1
  223. package/dist/lint/post-synth/wk8705.d.ts +0 -1
  224. package/dist/lint/rules/argo-appset-single-project.d.ts +0 -1
  225. package/dist/lint/rules/argo-ast.d.ts +0 -1
  226. package/dist/lint/rules/argo-automated-prune.d.ts +0 -1
  227. package/dist/lint/rules/flux-source-ref-pin.d.ts +0 -1
  228. package/dist/lint/rules/hardcoded-namespace.d.ts +0 -1
  229. package/dist/lint/rules/latest-image-tag.d.ts +0 -1
  230. package/dist/lint/rules/missing-resource-limits.d.ts +0 -1
  231. package/dist/listed-types.d.ts +0 -1
  232. package/dist/lsp/completions.d.ts +0 -1
  233. package/dist/lsp/hover.d.ts +0 -1
  234. package/dist/manifest-entity.d.ts +0 -1
  235. package/dist/manifest-files.d.ts +16 -0
  236. package/dist/manifest-files.js +24 -0
  237. package/dist/manifest.json +1 -1
  238. package/dist/meta.json +1984 -155
  239. package/dist/micro-time.d.ts +0 -1
  240. package/dist/okf/index.md +1 -0
  241. package/dist/okf/rules/WK8506.md +11 -0
  242. package/dist/op/activities/apply-diff.d.ts +0 -1
  243. package/dist/op/activities/argo.d.ts +0 -1
  244. package/dist/op/activities/ensure-secret.d.ts +0 -1
  245. package/dist/op/activities/index.d.ts +0 -1
  246. package/dist/op/activities/kubectl.d.ts +0 -1
  247. package/dist/op/activities/wait-for-ready.d.ts +0 -1
  248. package/dist/op/builders.d.ts +0 -1
  249. package/dist/package-cli.d.ts +0 -1
  250. package/dist/patch/json-patch.d.ts +0 -1
  251. package/dist/patch/rendered-patch.d.ts +0 -1
  252. package/dist/plugin.d.ts +0 -1
  253. package/dist/plugin.js +2 -0
  254. package/dist/project-kinds.d.ts +0 -1
  255. package/dist/receipt-store.d.ts +0 -1
  256. package/dist/reference-catalog.d.ts +0 -1
  257. package/dist/rules/top-level-fields-helpers.ts +54 -0
  258. package/dist/rules/wk8506.ts +43 -0
  259. package/dist/secret-labels.d.ts +0 -1
  260. package/dist/secret-store.d.ts +0 -1
  261. package/dist/serializer.d.ts +0 -1
  262. package/dist/sops/encrypted-secret-file.d.ts +0 -1
  263. package/dist/sops/entity.d.ts +0 -1
  264. package/dist/spec/fetch.d.ts +0 -1
  265. package/dist/spec/parse.d.ts +6 -1
  266. package/dist/spec/parse.js +1 -0
  267. package/dist/subscribe-changes.d.ts +0 -1
  268. package/dist/teardown.d.ts +0 -1
  269. package/dist/telemetry-release.d.ts +0 -1
  270. package/dist/top-level-fields.d.ts +24 -0
  271. package/dist/top-level-fields.js +35 -0
  272. package/dist/validate-cli.d.ts +0 -1
  273. package/dist/validate.d.ts +0 -1
  274. package/dist/variables.d.ts +0 -1
  275. package/dist/whoami.d.ts +0 -1
  276. package/dist/workspace-member.d.ts +0 -1
  277. package/dist/workspace-member.js +1 -9
  278. package/package.json +12 -13
  279. package/dist/actions/apps.d.ts.map +0 -1
  280. package/dist/actions/batch.d.ts.map +0 -1
  281. package/dist/actions/core.d.ts.map +0 -1
  282. package/dist/actions/index.d.ts.map +0 -1
  283. package/dist/actions/networking.d.ts.map +0 -1
  284. package/dist/actions/rbac.d.ts.map +0 -1
  285. package/dist/api/classify.d.ts.map +0 -1
  286. package/dist/api/connect.d.ts.map +0 -1
  287. package/dist/api/fake-cluster.d.ts.map +0 -1
  288. package/dist/api/operation-surface.d.ts.map +0 -1
  289. package/dist/api/owner-chain.d.ts.map +0 -1
  290. package/dist/api/sweep-types.d.ts.map +0 -1
  291. package/dist/application-paths.d.ts.map +0 -1
  292. package/dist/application-set.d.ts.map +0 -1
  293. package/dist/behaviour-kinds.d.ts.map +0 -1
  294. package/dist/cluster-secret.d.ts.map +0 -1
  295. package/dist/codegen/docs-cli.d.ts.map +0 -1
  296. package/dist/codegen/docs.d.ts.map +0 -1
  297. package/dist/codegen/generate-cli.d.ts.map +0 -1
  298. package/dist/codegen/generate-lexicon.d.ts.map +0 -1
  299. package/dist/codegen/generate-list-map-keys.d.ts.map +0 -1
  300. package/dist/codegen/generate-operations.d.ts.map +0 -1
  301. package/dist/codegen/generate-typescript.d.ts.map +0 -1
  302. package/dist/codegen/generate.d.ts.map +0 -1
  303. package/dist/codegen/naming.d.ts.map +0 -1
  304. package/dist/codegen/package.d.ts.map +0 -1
  305. package/dist/codegen/patches.d.ts.map +0 -1
  306. package/dist/codegen/typecheck.d.ts.map +0 -1
  307. package/dist/codegen/versions.d.ts.map +0 -1
  308. package/dist/components/argo-app.d.ts.map +0 -1
  309. package/dist/components/builders.d.ts.map +0 -1
  310. package/dist/components/capability-plugin.d.ts.map +0 -1
  311. package/dist/components/flux-reconcile.d.ts.map +0 -1
  312. package/dist/components/index.d.ts.map +0 -1
  313. package/dist/components/kubectl-apply.d.ts.map +0 -1
  314. package/dist/components/kustomize-apply.d.ts.map +0 -1
  315. package/dist/composites/adot-collector.d.ts.map +0 -1
  316. package/dist/composites/agic-ingress.d.ts.map +0 -1
  317. package/dist/composites/aks-external-dns-agent.d.ts.map +0 -1
  318. package/dist/composites/alb-ingress.d.ts.map +0 -1
  319. package/dist/composites/argo-app.d.ts.map +0 -1
  320. package/dist/composites/autoscaled-service.d.ts.map +0 -1
  321. package/dist/composites/azure-disk-storage-class.d.ts.map +0 -1
  322. package/dist/composites/azure-file-storage-class.d.ts.map +0 -1
  323. package/dist/composites/azure-monitor-collector.d.ts.map +0 -1
  324. package/dist/composites/batch-job.d.ts.map +0 -1
  325. package/dist/composites/catalog.d.ts.map +0 -1
  326. package/dist/composites/cockroachdb-cluster.d.ts.map +0 -1
  327. package/dist/composites/cockroachdb-region-stack.d.ts.map +0 -1
  328. package/dist/composites/config-connector-context.d.ts.map +0 -1
  329. package/dist/composites/configured-app.d.ts.map +0 -1
  330. package/dist/composites/cron-schedule.d.ts.map +0 -1
  331. package/dist/composites/cron-workload.d.ts.map +0 -1
  332. package/dist/composites/ebs-storage-class.d.ts.map +0 -1
  333. package/dist/composites/efs-storage-class.d.ts.map +0 -1
  334. package/dist/composites/external-dns-agent.d.ts.map +0 -1
  335. package/dist/composites/filestore-storage-class.d.ts.map +0 -1
  336. package/dist/composites/fluent-bit-agent.d.ts.map +0 -1
  337. package/dist/composites/flux-app.d.ts.map +0 -1
  338. package/dist/composites/gce-ingress.d.ts.map +0 -1
  339. package/dist/composites/gce-pd-storage-class.d.ts.map +0 -1
  340. package/dist/composites/gke-external-dns-agent.d.ts.map +0 -1
  341. package/dist/composites/gke-fluent-bit-agent.d.ts.map +0 -1
  342. package/dist/composites/gke-gateway.d.ts.map +0 -1
  343. package/dist/composites/gke-otel-collector.d.ts.map +0 -1
  344. package/dist/composites/index.d.ts.map +0 -1
  345. package/dist/composites/inference-service.d.ts.map +0 -1
  346. package/dist/composites/irsa-service-account.d.ts.map +0 -1
  347. package/dist/composites/member-defaults.d.ts.map +0 -1
  348. package/dist/composites/metrics-server.d.ts.map +0 -1
  349. package/dist/composites/model.d.ts.map +0 -1
  350. package/dist/composites/monitored-service.d.ts.map +0 -1
  351. package/dist/composites/namespace-env.d.ts.map +0 -1
  352. package/dist/composites/network-isolated-app.d.ts.map +0 -1
  353. package/dist/composites/node-agent.d.ts.map +0 -1
  354. package/dist/composites/operator-stack.d.ts.map +0 -1
  355. package/dist/composites/otel-collector-agent.d.ts.map +0 -1
  356. package/dist/composites/otel-collector-gateway.d.ts.map +0 -1
  357. package/dist/composites/otel-collector-node.d.ts.map +0 -1
  358. package/dist/composites/otel-collector-rbac.d.ts.map +0 -1
  359. package/dist/composites/otel-collector-shape.d.ts.map +0 -1
  360. package/dist/composites/otel-collector.d.ts.map +0 -1
  361. package/dist/composites/otel-operator-collector.d.ts.map +0 -1
  362. package/dist/composites/ray-cluster.d.ts.map +0 -1
  363. package/dist/composites/ray-job.d.ts.map +0 -1
  364. package/dist/composites/ray-service.d.ts.map +0 -1
  365. package/dist/composites/secure-ingress.d.ts.map +0 -1
  366. package/dist/composites/security-context.d.ts.map +0 -1
  367. package/dist/composites/sidecar-app.d.ts.map +0 -1
  368. package/dist/composites/stateful-app.d.ts.map +0 -1
  369. package/dist/composites/vllm-serving-runtime.d.ts.map +0 -1
  370. package/dist/composites/web-app.d.ts.map +0 -1
  371. package/dist/composites/worker-pool.d.ts.map +0 -1
  372. package/dist/composites/workload-identity-sa.d.ts.map +0 -1
  373. package/dist/composites/workload-identity-service-account.d.ts.map +0 -1
  374. package/dist/config-schema.d.ts.map +0 -1
  375. package/dist/config.d.ts.map +0 -1
  376. package/dist/coverage.d.ts.map +0 -1
  377. package/dist/crd/crd-sources.d.ts.map +0 -1
  378. package/dist/crd/loader.d.ts.map +0 -1
  379. package/dist/crd/oci-chart.d.ts.map +0 -1
  380. package/dist/crd/parser.d.ts.map +0 -1
  381. package/dist/crd/project-codegen.d.ts.map +0 -1
  382. package/dist/crd/types.d.ts.map +0 -1
  383. package/dist/deep-observe-hooks.d.ts.map +0 -1
  384. package/dist/deep-observe.d.ts.map +0 -1
  385. package/dist/default-labels.d.ts.map +0 -1
  386. package/dist/describe-resources.d.ts.map +0 -1
  387. package/dist/describe-stack-status.d.ts.map +0 -1
  388. package/dist/detect.d.ts.map +0 -1
  389. package/dist/effect-receipt-row.d.ts.map +0 -1
  390. package/dist/export-resources.d.ts.map +0 -1
  391. package/dist/generated/index.d.ts.map +0 -1
  392. package/dist/generated/runtime.d.ts.map +0 -1
  393. package/dist/group-namespace.d.ts.map +0 -1
  394. package/dist/helm-references.d.ts.map +0 -1
  395. package/dist/import/embedded.d.ts.map +0 -1
  396. package/dist/import/generator.d.ts.map +0 -1
  397. package/dist/import/live-export.d.ts.map +0 -1
  398. package/dist/import/parser.d.ts.map +0 -1
  399. package/dist/import/testdata/embedded/fixtures.d.ts.map +0 -1
  400. package/dist/import/typed-classes.d.ts.map +0 -1
  401. package/dist/include/entity.d.ts.map +0 -1
  402. package/dist/include/resolve.d.ts.map +0 -1
  403. package/dist/index-identity.d.ts.map +0 -1
  404. package/dist/index-import.d.ts.map +0 -1
  405. package/dist/index.d.ts.map +0 -1
  406. package/dist/kube/apply.d.ts.map +0 -1
  407. package/dist/kube/connect.d.ts.map +0 -1
  408. package/dist/kube/delete.d.ts.map +0 -1
  409. package/dist/kube/describe.d.ts.map +0 -1
  410. package/dist/kube/events.d.ts.map +0 -1
  411. package/dist/kube/flags.d.ts.map +0 -1
  412. package/dist/kube/get.d.ts.map +0 -1
  413. package/dist/kube/group.d.ts.map +0 -1
  414. package/dist/kube/logs.d.ts.map +0 -1
  415. package/dist/kube/project.d.ts.map +0 -1
  416. package/dist/kube/render.d.ts.map +0 -1
  417. package/dist/kube/source.d.ts.map +0 -1
  418. package/dist/kube/target.d.ts.map +0 -1
  419. package/dist/kube/testing.d.ts.map +0 -1
  420. package/dist/kube/top.d.ts.map +0 -1
  421. package/dist/kube/verdict.d.ts.map +0 -1
  422. package/dist/kube/wait.d.ts.map +0 -1
  423. package/dist/kustomize/render.d.ts.map +0 -1
  424. package/dist/kustomize/rendered-entity.d.ts.map +0 -1
  425. package/dist/kustomize/root.d.ts.map +0 -1
  426. package/dist/lint/audit-catalog.d.ts.map +0 -1
  427. package/dist/lint/audit-lineage.d.ts.map +0 -1
  428. package/dist/lint/post-synth/argo-helpers.d.ts.map +0 -1
  429. package/dist/lint/post-synth/argo002.d.ts.map +0 -1
  430. package/dist/lint/post-synth/argo003.d.ts.map +0 -1
  431. package/dist/lint/post-synth/argo005.d.ts.map +0 -1
  432. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +0 -1
  433. package/dist/lint/post-synth/flux002.d.ts.map +0 -1
  434. package/dist/lint/post-synth/flux003.d.ts.map +0 -1
  435. package/dist/lint/post-synth/index.d.ts.map +0 -1
  436. package/dist/lint/post-synth/k8s-helpers.d.ts.map +0 -1
  437. package/dist/lint/post-synth/monitoring-selection-helpers.d.ts.map +0 -1
  438. package/dist/lint/post-synth/otel-placement-helpers.d.ts.map +0 -1
  439. package/dist/lint/post-synth/sops-helpers.d.ts.map +0 -1
  440. package/dist/lint/post-synth/wk8005.d.ts.map +0 -1
  441. package/dist/lint/post-synth/wk8006.d.ts.map +0 -1
  442. package/dist/lint/post-synth/wk8041.d.ts.map +0 -1
  443. package/dist/lint/post-synth/wk8042.d.ts.map +0 -1
  444. package/dist/lint/post-synth/wk8101.d.ts.map +0 -1
  445. package/dist/lint/post-synth/wk8102.d.ts.map +0 -1
  446. package/dist/lint/post-synth/wk8103.d.ts.map +0 -1
  447. package/dist/lint/post-synth/wk8104.d.ts.map +0 -1
  448. package/dist/lint/post-synth/wk8105.d.ts.map +0 -1
  449. package/dist/lint/post-synth/wk8201.d.ts.map +0 -1
  450. package/dist/lint/post-synth/wk8202.d.ts.map +0 -1
  451. package/dist/lint/post-synth/wk8203.d.ts.map +0 -1
  452. package/dist/lint/post-synth/wk8204.d.ts.map +0 -1
  453. package/dist/lint/post-synth/wk8205.d.ts.map +0 -1
  454. package/dist/lint/post-synth/wk8207.d.ts.map +0 -1
  455. package/dist/lint/post-synth/wk8208.d.ts.map +0 -1
  456. package/dist/lint/post-synth/wk8209.d.ts.map +0 -1
  457. package/dist/lint/post-synth/wk8301.d.ts.map +0 -1
  458. package/dist/lint/post-synth/wk8302.d.ts.map +0 -1
  459. package/dist/lint/post-synth/wk8303.d.ts.map +0 -1
  460. package/dist/lint/post-synth/wk8304.d.ts.map +0 -1
  461. package/dist/lint/post-synth/wk8305.d.ts.map +0 -1
  462. package/dist/lint/post-synth/wk8306.d.ts.map +0 -1
  463. package/dist/lint/post-synth/wk8401.d.ts.map +0 -1
  464. package/dist/lint/post-synth/wk8402.d.ts.map +0 -1
  465. package/dist/lint/post-synth/wk8403.d.ts.map +0 -1
  466. package/dist/lint/post-synth/wk8404.d.ts.map +0 -1
  467. package/dist/lint/post-synth/wk8405.d.ts.map +0 -1
  468. package/dist/lint/post-synth/wk8406.d.ts.map +0 -1
  469. package/dist/lint/post-synth/wk8407.d.ts.map +0 -1
  470. package/dist/lint/post-synth/wk8501.d.ts.map +0 -1
  471. package/dist/lint/post-synth/wk8502.d.ts.map +0 -1
  472. package/dist/lint/post-synth/wk8503.d.ts.map +0 -1
  473. package/dist/lint/post-synth/wk8504.d.ts.map +0 -1
  474. package/dist/lint/post-synth/wk8505.d.ts.map +0 -1
  475. package/dist/lint/post-synth/wk8601.d.ts.map +0 -1
  476. package/dist/lint/post-synth/wk8602.d.ts.map +0 -1
  477. package/dist/lint/post-synth/wk8603.d.ts.map +0 -1
  478. package/dist/lint/post-synth/wk8604.d.ts.map +0 -1
  479. package/dist/lint/post-synth/wk8605.d.ts.map +0 -1
  480. package/dist/lint/post-synth/wk8606.d.ts.map +0 -1
  481. package/dist/lint/post-synth/wk8701.d.ts.map +0 -1
  482. package/dist/lint/post-synth/wk8702.d.ts.map +0 -1
  483. package/dist/lint/post-synth/wk8703.d.ts.map +0 -1
  484. package/dist/lint/post-synth/wk8704.d.ts.map +0 -1
  485. package/dist/lint/post-synth/wk8705.d.ts.map +0 -1
  486. package/dist/lint/rules/argo-appset-single-project.d.ts.map +0 -1
  487. package/dist/lint/rules/argo-ast.d.ts.map +0 -1
  488. package/dist/lint/rules/argo-automated-prune.d.ts.map +0 -1
  489. package/dist/lint/rules/flux-source-ref-pin.d.ts.map +0 -1
  490. package/dist/lint/rules/hardcoded-namespace.d.ts.map +0 -1
  491. package/dist/lint/rules/latest-image-tag.d.ts.map +0 -1
  492. package/dist/lint/rules/missing-resource-limits.d.ts.map +0 -1
  493. package/dist/listed-types.d.ts.map +0 -1
  494. package/dist/lsp/completions.d.ts.map +0 -1
  495. package/dist/lsp/hover.d.ts.map +0 -1
  496. package/dist/manifest-entity.d.ts.map +0 -1
  497. package/dist/micro-time.d.ts.map +0 -1
  498. package/dist/op/activities/apply-diff.d.ts.map +0 -1
  499. package/dist/op/activities/argo.d.ts.map +0 -1
  500. package/dist/op/activities/ensure-secret.d.ts.map +0 -1
  501. package/dist/op/activities/index.d.ts.map +0 -1
  502. package/dist/op/activities/kubectl.d.ts.map +0 -1
  503. package/dist/op/activities/wait-for-ready.d.ts.map +0 -1
  504. package/dist/op/builders.d.ts.map +0 -1
  505. package/dist/package-cli.d.ts.map +0 -1
  506. package/dist/patch/json-patch.d.ts.map +0 -1
  507. package/dist/patch/rendered-patch.d.ts.map +0 -1
  508. package/dist/plugin.d.ts.map +0 -1
  509. package/dist/project-kinds.d.ts.map +0 -1
  510. package/dist/receipt-store.d.ts.map +0 -1
  511. package/dist/reference-catalog.d.ts.map +0 -1
  512. package/dist/secret-labels.d.ts.map +0 -1
  513. package/dist/secret-store.d.ts.map +0 -1
  514. package/dist/serializer.d.ts.map +0 -1
  515. package/dist/sops/encrypted-secret-file.d.ts.map +0 -1
  516. package/dist/sops/entity.d.ts.map +0 -1
  517. package/dist/spec/fetch.d.ts.map +0 -1
  518. package/dist/spec/parse.d.ts.map +0 -1
  519. package/dist/subscribe-changes.d.ts.map +0 -1
  520. package/dist/teardown.d.ts.map +0 -1
  521. package/dist/telemetry-release.d.ts.map +0 -1
  522. package/dist/validate-cli.d.ts.map +0 -1
  523. package/dist/validate.d.ts.map +0 -1
  524. package/dist/variables.d.ts.map +0 -1
  525. package/dist/whoami.d.ts.map +0 -1
  526. package/dist/workspace-member.d.ts.map +0 -1
  527. package/src/actions/actions.test.ts +0 -83
  528. package/src/actions/apps.ts +0 -23
  529. package/src/actions/batch.ts +0 -9
  530. package/src/actions/core.ts +0 -62
  531. package/src/actions/index.ts +0 -50
  532. package/src/actions/networking.ts +0 -15
  533. package/src/actions/rbac.ts +0 -13
  534. package/src/api/classify.test.ts +0 -170
  535. package/src/api/classify.ts +0 -154
  536. package/src/api/connect.ts +0 -104
  537. package/src/api/fake-cluster.ts +0 -231
  538. package/src/api/operation-surface.test.ts +0 -116
  539. package/src/api/operation-surface.ts +0 -130
  540. package/src/api/owner-chain.test.ts +0 -171
  541. package/src/api/owner-chain.ts +0 -144
  542. package/src/api/sweep-types.ts +0 -35
  543. package/src/application-paths.ts +0 -96
  544. package/src/application-set.test.ts +0 -130
  545. package/src/application-set.ts +0 -336
  546. package/src/behaviour-kinds.ts +0 -88
  547. package/src/cluster-secret.test.ts +0 -117
  548. package/src/cluster-secret.ts +0 -76
  549. package/src/codegen/declarations.test.ts +0 -118
  550. package/src/codegen/docs-cli.ts +0 -3
  551. package/src/codegen/docs.ts +0 -156
  552. package/src/codegen/generate-cli.ts +0 -41
  553. package/src/codegen/generate-crd-sources.test.ts +0 -49
  554. package/src/codegen/generate-lexicon.ts +0 -105
  555. package/src/codegen/generate-list-map-keys.test.ts +0 -112
  556. package/src/codegen/generate-list-map-keys.ts +0 -99
  557. package/src/codegen/generate-operations.ts +0 -56
  558. package/src/codegen/generate-typescript.ts +0 -162
  559. package/src/codegen/generate.ts +0 -231
  560. package/src/codegen/naming.test.ts +0 -63
  561. package/src/codegen/naming.ts +0 -201
  562. package/src/codegen/package.ts +0 -53
  563. package/src/codegen/patches.ts +0 -108
  564. package/src/codegen/snapshot.test.ts +0 -115
  565. package/src/codegen/typecheck.test.ts +0 -24
  566. package/src/codegen/typecheck.ts +0 -4
  567. package/src/codegen/versions.ts +0 -50
  568. package/src/components/argo-app.test.ts +0 -137
  569. package/src/components/argo-app.ts +0 -163
  570. package/src/components/builders.ts +0 -30
  571. package/src/components/capability-plugin.test.ts +0 -20
  572. package/src/components/capability-plugin.ts +0 -44
  573. package/src/components/flux-reconcile.test.ts +0 -145
  574. package/src/components/flux-reconcile.ts +0 -159
  575. package/src/components/index.ts +0 -44
  576. package/src/components/kubectl-apply-plan.k3d.e2e.test.ts +0 -127
  577. package/src/components/kubectl-apply.test.ts +0 -465
  578. package/src/components/kubectl-apply.ts +0 -570
  579. package/src/components/kustomize-apply.test.ts +0 -98
  580. package/src/components/kustomize-apply.ts +0 -110
  581. package/src/composites/__snapshots__/gke-otel-collector.snapshot.test.ts.snap +0 -335
  582. package/src/composites/adot-collector.ts +0 -258
  583. package/src/composites/agic-ingress.ts +0 -157
  584. package/src/composites/aks-external-dns-agent.ts +0 -211
  585. package/src/composites/alb-ingress.ts +0 -161
  586. package/src/composites/argo-app.ts +0 -381
  587. package/src/composites/autoscaled-service.ts +0 -293
  588. package/src/composites/azure-disk-storage-class.ts +0 -91
  589. package/src/composites/azure-file-storage-class.ts +0 -86
  590. package/src/composites/azure-monitor-collector.ts +0 -245
  591. package/src/composites/batch-job.ts +0 -230
  592. package/src/composites/catalog.test.ts +0 -39
  593. package/src/composites/catalog.ts +0 -4115
  594. package/src/composites/cockroachdb-cluster.ts +0 -528
  595. package/src/composites/cockroachdb-region-stack.ts +0 -553
  596. package/src/composites/composites.test.ts +0 -4291
  597. package/src/composites/config-connector-context.ts +0 -69
  598. package/src/composites/configured-app.ts +0 -231
  599. package/src/composites/cron-schedule.ts +0 -47
  600. package/src/composites/cron-workload.ts +0 -182
  601. package/src/composites/ebs-storage-class.ts +0 -105
  602. package/src/composites/efs-storage-class.ts +0 -86
  603. package/src/composites/external-dns-agent.ts +0 -181
  604. package/src/composites/filestore-storage-class.ts +0 -88
  605. package/src/composites/fluent-bit-agent.ts +0 -227
  606. package/src/composites/flux-app.ts +0 -298
  607. package/src/composites/gce-ingress.ts +0 -152
  608. package/src/composites/gce-pd-storage-class.ts +0 -94
  609. package/src/composites/gke-external-dns-agent.ts +0 -189
  610. package/src/composites/gke-fluent-bit-agent.ts +0 -232
  611. package/src/composites/gke-gateway.ts +0 -150
  612. package/src/composites/gke-otel-collector.snapshot.test.ts +0 -53
  613. package/src/composites/gke-otel-collector.ts +0 -156
  614. package/src/composites/index.ts +0 -133
  615. package/src/composites/inference-service.ts +0 -141
  616. package/src/composites/irsa-service-account.ts +0 -123
  617. package/src/composites/member-defaults.test.ts +0 -63
  618. package/src/composites/member-defaults.ts +0 -29
  619. package/src/composites/metrics-server.ts +0 -240
  620. package/src/composites/model.ts +0 -151
  621. package/src/composites/monitored-service.ts +0 -252
  622. package/src/composites/namespace-env.ts +0 -173
  623. package/src/composites/network-isolated-app.ts +0 -208
  624. package/src/composites/node-agent.ts +0 -242
  625. package/src/composites/operator-stack.ts +0 -387
  626. package/src/composites/otel-collector-agent.ts +0 -230
  627. package/src/composites/otel-collector-gateway.test.ts +0 -380
  628. package/src/composites/otel-collector-gateway.ts +0 -404
  629. package/src/composites/otel-collector-node.test.ts +0 -193
  630. package/src/composites/otel-collector-node.ts +0 -211
  631. package/src/composites/otel-collector-rbac.test.ts +0 -125
  632. package/src/composites/otel-collector-rbac.ts +0 -146
  633. package/src/composites/otel-collector-shape.ts +0 -163
  634. package/src/composites/otel-collector.ts +0 -209
  635. package/src/composites/otel-operator-collector.test.ts +0 -267
  636. package/src/composites/otel-operator-collector.ts +0 -221
  637. package/src/composites/ray-cluster.ts +0 -591
  638. package/src/composites/ray-job.ts +0 -236
  639. package/src/composites/ray-service.ts +0 -272
  640. package/src/composites/secure-ingress.ts +0 -160
  641. package/src/composites/security-context.ts +0 -10
  642. package/src/composites/sidecar-app.ts +0 -213
  643. package/src/composites/stateful-app.ts +0 -196
  644. package/src/composites/vllm-serving-runtime.test.ts +0 -167
  645. package/src/composites/vllm-serving-runtime.ts +0 -197
  646. package/src/composites/web-app.ts +0 -254
  647. package/src/composites/worker-pool.ts +0 -279
  648. package/src/composites/workload-identity-sa.ts +0 -127
  649. package/src/composites/workload-identity-service-account.ts +0 -123
  650. package/src/config-augmentation.test.ts +0 -100
  651. package/src/config-schema.ts +0 -113
  652. package/src/config.ts +0 -235
  653. package/src/coverage.test.ts +0 -27
  654. package/src/coverage.ts +0 -35
  655. package/src/crd/clickhouse-operators.test.ts +0 -105
  656. package/src/crd/cnpg.test.ts +0 -191
  657. package/src/crd/crd-sources.ts +0 -688
  658. package/src/crd/infisical.test.ts +0 -100
  659. package/src/crd/loader.test.ts +0 -90
  660. package/src/crd/loader.ts +0 -214
  661. package/src/crd/oci-chart.test.ts +0 -149
  662. package/src/crd/oci-chart.ts +0 -178
  663. package/src/crd/parser.test.ts +0 -585
  664. package/src/crd/parser.ts +0 -437
  665. package/src/crd/project-codegen.e2e.test.ts +0 -239
  666. package/src/crd/project-codegen.ts +0 -327
  667. package/src/crd/traefik.test.ts +0 -108
  668. package/src/crd/types.ts +0 -92
  669. package/src/deep-observe-hooks.ts +0 -361
  670. package/src/deep-observe.test.ts +0 -1160
  671. package/src/deep-observe.ts +0 -290
  672. package/src/default-labels.test.ts +0 -111
  673. package/src/default-labels.ts +0 -122
  674. package/src/describe-resources.test.ts +0 -1873
  675. package/src/describe-resources.ts +0 -839
  676. package/src/describe-stack-status.test.ts +0 -169
  677. package/src/describe-stack-status.ts +0 -143
  678. package/src/detect.ts +0 -9
  679. package/src/effect-receipt-row.test.ts +0 -285
  680. package/src/effect-receipt-row.ts +0 -268
  681. package/src/export-resources-io.test.ts +0 -97
  682. package/src/export-resources.ts +0 -72
  683. package/src/generated/index.d.ts +0 -8909
  684. package/src/generated/index.ts +0 -1153
  685. package/src/generated/runtime.ts +0 -4
  686. package/src/group-namespace.test.ts +0 -99
  687. package/src/group-namespace.ts +0 -103
  688. package/src/helm-references.test.ts +0 -149
  689. package/src/helm-references.ts +0 -425
  690. package/src/import/embedded-live.test.ts +0 -180
  691. package/src/import/embedded-roundtrip.test.ts +0 -298
  692. package/src/import/embedded-types.e2e.test.ts +0 -45
  693. package/src/import/embedded.test.ts +0 -189
  694. package/src/import/embedded.ts +0 -208
  695. package/src/import/generator.test.ts +0 -197
  696. package/src/import/generator.ts +0 -348
  697. package/src/import/live-export.test.ts +0 -114
  698. package/src/import/live-export.ts +0 -97
  699. package/src/import/operator-alerting-roundtrip.test.ts +0 -158
  700. package/src/import/operator-collector-roundtrip.test.ts +0 -105
  701. package/src/import/parser.test.ts +0 -233
  702. package/src/import/parser.ts +0 -263
  703. package/src/import/roundtrip-build.test.ts +0 -224
  704. package/src/import/roundtrip.test.ts +0 -86
  705. package/src/import/testdata/embedded/README.md +0 -14
  706. package/src/import/testdata/embedded/agent-observability.yaml +0 -2905
  707. package/src/import/testdata/embedded/alertmanager-configmap.yaml +0 -91
  708. package/src/import/testdata/embedded/fixtures.ts +0 -71
  709. package/src/import/testdata/embedded/grafana-dashboard-configmap.yaml +0 -364
  710. package/src/import/testdata/embedded/grafana-operator-dashboard.yaml +0 -363
  711. package/src/import/testdata/embedded/grafana-v2-dashboard-configmap.yaml +0 -851
  712. package/src/import/testdata/embedded/node-exporter-prometheusrule.yaml +0 -425
  713. package/src/import/testdata/embedded/otel-collector-daemonset.yaml +0 -225
  714. package/src/import/typed-classes.ts +0 -168
  715. package/src/include/entity.ts +0 -119
  716. package/src/include/include.test.ts +0 -345
  717. package/src/include/resolve.ts +0 -204
  718. package/src/index-identity.ts +0 -119
  719. package/src/index-import.test.ts +0 -244
  720. package/src/index-import.ts +0 -181
  721. package/src/index.ts +0 -172
  722. package/src/kube/apply.test.ts +0 -105
  723. package/src/kube/apply.ts +0 -106
  724. package/src/kube/connect.ts +0 -55
  725. package/src/kube/delete.test.ts +0 -123
  726. package/src/kube/delete.ts +0 -174
  727. package/src/kube/describe.test.ts +0 -106
  728. package/src/kube/describe.ts +0 -195
  729. package/src/kube/events.test.ts +0 -115
  730. package/src/kube/events.ts +0 -160
  731. package/src/kube/flags.test.ts +0 -65
  732. package/src/kube/flags.ts +0 -114
  733. package/src/kube/get.test.ts +0 -195
  734. package/src/kube/get.ts +0 -190
  735. package/src/kube/group.test.ts +0 -33
  736. package/src/kube/group.ts +0 -125
  737. package/src/kube/logs.test.ts +0 -126
  738. package/src/kube/logs.ts +0 -96
  739. package/src/kube/project.test.ts +0 -57
  740. package/src/kube/project.ts +0 -106
  741. package/src/kube/render.test.ts +0 -142
  742. package/src/kube/render.ts +0 -252
  743. package/src/kube/source.test.ts +0 -138
  744. package/src/kube/source.ts +0 -139
  745. package/src/kube/target.test.ts +0 -67
  746. package/src/kube/target.ts +0 -89
  747. package/src/kube/testing.ts +0 -42
  748. package/src/kube/top.test.ts +0 -149
  749. package/src/kube/top.ts +0 -120
  750. package/src/kube/verdict.test.ts +0 -48
  751. package/src/kube/verdict.ts +0 -77
  752. package/src/kube/wait.test.ts +0 -125
  753. package/src/kube/wait.ts +0 -160
  754. package/src/kustomize/helm.test.ts +0 -183
  755. package/src/kustomize/render.ts +0 -232
  756. package/src/kustomize/rendered-entity.ts +0 -82
  757. package/src/kustomize/root.test.ts +0 -309
  758. package/src/kustomize/root.ts +0 -100
  759. package/src/kustomize/search.test.ts +0 -101
  760. package/src/lifecycle-integration.test.ts +0 -325
  761. package/src/lint/audit-catalog.ts +0 -63
  762. package/src/lint/audit-lineage.ts +0 -127
  763. package/src/lint/post-synth/argo-helpers.ts +0 -54
  764. package/src/lint/post-synth/argo002.ts +0 -48
  765. package/src/lint/post-synth/argo003.ts +0 -81
  766. package/src/lint/post-synth/argo005.ts +0 -85
  767. package/src/lint/post-synth/audit-identity.test.ts +0 -65
  768. package/src/lint/post-synth/crd-schema-helpers.ts +0 -235
  769. package/src/lint/post-synth/flux002.ts +0 -78
  770. package/src/lint/post-synth/flux003.ts +0 -76
  771. package/src/lint/post-synth/index.ts +0 -107
  772. package/src/lint/post-synth/k8s-helpers.test.ts +0 -236
  773. package/src/lint/post-synth/k8s-helpers.ts +0 -296
  774. package/src/lint/post-synth/monitoring-selection-helpers.ts +0 -185
  775. package/src/lint/post-synth/monitoring-selection.test.ts +0 -316
  776. package/src/lint/post-synth/otel-placement-helpers.ts +0 -333
  777. package/src/lint/post-synth/otel-placement.test.ts +0 -450
  778. package/src/lint/post-synth/post-synth.test.ts +0 -2942
  779. package/src/lint/post-synth/sops-helpers.ts +0 -76
  780. package/src/lint/post-synth/wk8005.ts +0 -107
  781. package/src/lint/post-synth/wk8006.ts +0 -65
  782. package/src/lint/post-synth/wk8041.ts +0 -69
  783. package/src/lint/post-synth/wk8042.ts +0 -43
  784. package/src/lint/post-synth/wk8101.ts +0 -60
  785. package/src/lint/post-synth/wk8102.ts +0 -41
  786. package/src/lint/post-synth/wk8103.ts +0 -41
  787. package/src/lint/post-synth/wk8104.ts +0 -65
  788. package/src/lint/post-synth/wk8105.ts +0 -41
  789. package/src/lint/post-synth/wk8201.ts +0 -51
  790. package/src/lint/post-synth/wk8202.ts +0 -42
  791. package/src/lint/post-synth/wk8203.ts +0 -42
  792. package/src/lint/post-synth/wk8204.ts +0 -84
  793. package/src/lint/post-synth/wk8205.ts +0 -52
  794. package/src/lint/post-synth/wk8207.ts +0 -40
  795. package/src/lint/post-synth/wk8208.ts +0 -40
  796. package/src/lint/post-synth/wk8209.ts +0 -40
  797. package/src/lint/post-synth/wk8301.ts +0 -55
  798. package/src/lint/post-synth/wk8302.ts +0 -41
  799. package/src/lint/post-synth/wk8303.ts +0 -93
  800. package/src/lint/post-synth/wk8304.ts +0 -65
  801. package/src/lint/post-synth/wk8305.ts +0 -112
  802. package/src/lint/post-synth/wk8306.ts +0 -46
  803. package/src/lint/post-synth/wk8401.ts +0 -93
  804. package/src/lint/post-synth/wk8402.ts +0 -38
  805. package/src/lint/post-synth/wk8403.ts +0 -55
  806. package/src/lint/post-synth/wk8404.ts +0 -50
  807. package/src/lint/post-synth/wk8405.ts +0 -85
  808. package/src/lint/post-synth/wk8406.ts +0 -56
  809. package/src/lint/post-synth/wk8407.ts +0 -66
  810. package/src/lint/post-synth/wk8501.ts +0 -40
  811. package/src/lint/post-synth/wk8502.ts +0 -39
  812. package/src/lint/post-synth/wk8503.ts +0 -220
  813. package/src/lint/post-synth/wk8504.ts +0 -51
  814. package/src/lint/post-synth/wk8505.ts +0 -65
  815. package/src/lint/post-synth/wk8601.ts +0 -44
  816. package/src/lint/post-synth/wk8602.ts +0 -133
  817. package/src/lint/post-synth/wk8603.ts +0 -66
  818. package/src/lint/post-synth/wk8604.ts +0 -36
  819. package/src/lint/post-synth/wk8605.test.ts +0 -153
  820. package/src/lint/post-synth/wk8605.ts +0 -133
  821. package/src/lint/post-synth/wk8606.ts +0 -27
  822. package/src/lint/post-synth/wk8701.ts +0 -37
  823. package/src/lint/post-synth/wk8702.ts +0 -43
  824. package/src/lint/post-synth/wk8703.ts +0 -37
  825. package/src/lint/post-synth/wk8704.ts +0 -134
  826. package/src/lint/post-synth/wk8705.ts +0 -45
  827. package/src/lint/rules/argo-appset-single-project.ts +0 -66
  828. package/src/lint/rules/argo-ast.ts +0 -121
  829. package/src/lint/rules/argo-automated-prune.ts +0 -75
  830. package/src/lint/rules/flux-source-ref-pin.ts +0 -52
  831. package/src/lint/rules/hardcoded-namespace.ts +0 -71
  832. package/src/lint/rules/latest-image-tag.ts +0 -121
  833. package/src/lint/rules/missing-resource-limits.ts +0 -111
  834. package/src/lint/rules/rules.test.ts +0 -421
  835. package/src/list-map-key-table.test.ts +0 -83
  836. package/src/list-map-order-key.test.ts +0 -119
  837. package/src/listed-types.test.ts +0 -76
  838. package/src/listed-types.ts +0 -70
  839. package/src/lsp/completions.test.ts +0 -64
  840. package/src/lsp/completions.ts +0 -21
  841. package/src/lsp/hover.test.ts +0 -69
  842. package/src/lsp/hover.ts +0 -69
  843. package/src/manifest-entity.test.ts +0 -78
  844. package/src/manifest-entity.ts +0 -82
  845. package/src/micro-time.test.ts +0 -48
  846. package/src/micro-time.ts +0 -51
  847. package/src/op/activities/apply-diff.ts +0 -87
  848. package/src/op/activities/argo.test.ts +0 -79
  849. package/src/op/activities/argo.ts +0 -163
  850. package/src/op/activities/ensure-secret.ts +0 -71
  851. package/src/op/activities/index.ts +0 -79
  852. package/src/op/activities/kubectl-plan.test.ts +0 -224
  853. package/src/op/activities/kubectl.test.ts +0 -662
  854. package/src/op/activities/kubectl.ts +0 -723
  855. package/src/op/activities/wait-for-ready.test.ts +0 -260
  856. package/src/op/activities/wait-for-ready.ts +0 -371
  857. package/src/op/builders.test.ts +0 -82
  858. package/src/op/builders.ts +0 -95
  859. package/src/package-cli.ts +0 -28
  860. package/src/patch/json-patch.test.ts +0 -91
  861. package/src/patch/json-patch.ts +0 -189
  862. package/src/patch/rendered-patch.test.ts +0 -143
  863. package/src/patch/rendered-patch.ts +0 -180
  864. package/src/plugin.test.ts +0 -273
  865. package/src/plugin.ts +0 -827
  866. package/src/project-kinds.ts +0 -75
  867. package/src/prometheus-rule-groups.test.ts +0 -135
  868. package/src/receipt-store.test.ts +0 -380
  869. package/src/receipt-store.ts +0 -290
  870. package/src/reference-catalog.test.ts +0 -251
  871. package/src/reference-catalog.ts +0 -438
  872. package/src/secret-labels.ts +0 -36
  873. package/src/secret-store.test.ts +0 -184
  874. package/src/secret-store.ts +0 -165
  875. package/src/serializer-ownership.test.ts +0 -44
  876. package/src/serializer-telemetry.test.ts +0 -146
  877. package/src/serializer.test.ts +0 -640
  878. package/src/serializer.ts +0 -655
  879. package/src/skills/chant-k8s-aks.md +0 -146
  880. package/src/skills/chant-k8s-argo.md +0 -190
  881. package/src/skills/chant-k8s-deployment-strategies.md +0 -183
  882. package/src/skills/chant-k8s-eks.md +0 -171
  883. package/src/skills/chant-k8s-flux.md +0 -162
  884. package/src/skills/chant-k8s-gke.md +0 -246
  885. package/src/skills/chant-k8s-patterns.md +0 -245
  886. package/src/skills/chant-k8s-ray.md +0 -252
  887. package/src/skills/chant-k8s-security.md +0 -237
  888. package/src/skills/chant-k8s.md +0 -307
  889. package/src/sops/encrypted-secret-file.test.ts +0 -333
  890. package/src/sops/encrypted-secret-file.ts +0 -264
  891. package/src/sops/entity.ts +0 -53
  892. package/src/spec/fetch.test.ts +0 -24
  893. package/src/spec/fetch.ts +0 -68
  894. package/src/spec/parse.test.ts +0 -262
  895. package/src/spec/parse.ts +0 -864
  896. package/src/subscribe-changes.test.ts +0 -368
  897. package/src/subscribe-changes.ts +0 -210
  898. package/src/teardown.test.ts +0 -240
  899. package/src/teardown.ts +0 -239
  900. package/src/telemetry-build.test.ts +0 -79
  901. package/src/telemetry-release.ts +0 -93
  902. package/src/testdata/helm-chart-missing/kustomization.yaml +0 -8
  903. package/src/testdata/helm-chart-root/charts/webchart/Chart.yaml +0 -3
  904. package/src/testdata/helm-chart-root/charts/webchart/templates/configmap.yaml +0 -6
  905. package/src/testdata/helm-chart-root/charts/webchart/values.yaml +0 -1
  906. package/src/testdata/helm-chart-root/kustomization.yaml +0 -9
  907. package/src/testdata/helm-chart-root/values.yaml +0 -1
  908. package/src/testdata/include/bundle.yaml +0 -45
  909. package/src/testdata/indexed/listing.json +0 -67
  910. package/src/testdata/kustomize-root/base/deployment.yaml +0 -17
  911. package/src/testdata/kustomize-root/base/kustomization.yaml +0 -3
  912. package/src/testdata/kustomize-root/base/service.yaml +0 -9
  913. package/src/testdata/kustomize-root/overlays/prod/kustomization.yaml +0 -6
  914. package/src/testdata/manifests/configmap.yaml +0 -7
  915. package/src/testdata/manifests/deployment.yaml +0 -22
  916. package/src/testdata/manifests/full-app.yaml +0 -61
  917. package/src/testdata/manifests/secret.yaml +0 -7
  918. package/src/testdata/manifests/service.yaml +0 -15
  919. package/src/testdata/sops/db-credentials.sops.yaml +0 -23
  920. package/src/testdata/workspace-members/argo/guestbook.yaml +0 -28
  921. package/src/testdata/workspace-members/argo/namespace.yaml +0 -4
  922. package/src/testdata/workspace-members/argo-clusters/clusters.yaml +0 -34
  923. package/src/testdata/workspace-members/argo-set/all.yaml +0 -43
  924. package/src/testdata/workspace-members/flux/apps.yaml +0 -12
  925. package/src/testdata/workspace-members/flux/kustomization.yaml +0 -4
  926. package/src/testdata/workspace-members/plain/deploy.yaml +0 -27
  927. package/src/testdata/workspace-members/plain/es.yaml +0 -15
  928. package/src/testdata/workspace-members/templated/block.yaml +0 -6
  929. package/src/testdata/workspace-members/templated/chart-cm.yaml +0 -4
  930. package/src/testdata/workspace-members/templated/cm.yaml +0 -6
  931. package/src/validate-cli.ts +0 -21
  932. package/src/validate.test.ts +0 -29
  933. package/src/validate.ts +0 -53
  934. package/src/variables.ts +0 -36
  935. package/src/whoami.test.ts +0 -203
  936. package/src/whoami.ts +0 -122
  937. package/src/workspace-kinds.test.ts +0 -43
  938. package/src/workspace-member.test.ts +0 -220
  939. package/src/workspace-member.ts +0 -269
  940. /package/{src → dist}/generated/list-map-keys.json +0 -0
  941. /package/{src → dist}/generated/operations.json +0 -0
@@ -1,4291 +0,0 @@
1
- import { describe, test, expect, vi } from "vitest";
2
- import { isCompositeInstance } from "@intentius/chant";
3
- import { emitYAML } from "@intentius/chant/yaml";
4
- import { WebApp } from "./web-app";
5
-
6
- /** Helper to access props on a Declarable member. */
7
- function p(member: unknown): Record<string, unknown> {
8
- return (member as any).props;
9
- }
10
- import { StatefulApp } from "./stateful-app";
11
- import { ArgoAppFor, ArgoAppSetForRegions, registerArgoCluster } from "./argo-app";
12
- import { FluxGitSource, FluxAppFor } from "./flux-app";
13
- import { Model, resolveModelStorageUri } from "./model";
14
- import { OperatorStack, deriveHostVerbClass } from "./operator-stack";
15
- import type { OpConfig } from "@intentius/chant/op";
16
- import { CronWorkload } from "./cron-workload";
17
- import { AutoscaledService } from "./autoscaled-service";
18
- import { WorkerPool } from "./worker-pool";
19
- import { NamespaceEnv } from "./namespace-env";
20
- import { NodeAgent } from "./node-agent";
21
- import { BatchJob } from "./batch-job";
22
- import { SecureIngress } from "./secure-ingress";
23
- import { ConfiguredApp } from "./configured-app";
24
- import { SidecarApp } from "./sidecar-app";
25
- import { MonitoredService } from "./monitored-service";
26
- import { NetworkIsolatedApp } from "./network-isolated-app";
27
- import { IrsaServiceAccount } from "./irsa-service-account";
28
- import { AlbIngress } from "./alb-ingress";
29
- import { GceIngress } from "./gce-ingress";
30
- import { EbsStorageClass } from "./ebs-storage-class";
31
- import { EfsStorageClass } from "./efs-storage-class";
32
- import { FluentBitAgent } from "./fluent-bit-agent";
33
- import { ExternalDnsAgent } from "./external-dns-agent";
34
- import { AdotCollector } from "./adot-collector";
35
- import { MetricsServer } from "./metrics-server";
36
- import { WorkloadIdentityServiceAccount } from "./workload-identity-service-account";
37
- import { GcePdStorageClass } from "./gce-pd-storage-class";
38
- import { FilestoreStorageClass } from "./filestore-storage-class";
39
- import { GkeGateway } from "./gke-gateway";
40
- import { ConfigConnectorContext } from "./config-connector-context";
41
- import { InferenceService } from "./inference-service";
42
-
43
- // ── WebApp ──────────────────────────────────────────────────────────
44
-
45
- describe("WebApp", () => {
46
- test("returns deployment and service", () => {
47
- const result = WebApp({ name: "app", image: "app:1.0" });
48
- expect(result.deployment).toBeDefined();
49
- expect(result.service).toBeDefined();
50
- });
51
-
52
- test("does not include ingress by default", () => {
53
- const result = WebApp({ name: "app", image: "app:1.0" });
54
- expect(result.ingress).toBeUndefined();
55
- });
56
-
57
- test("includes ingress when ingressHost is set", () => {
58
- const result = WebApp({
59
- name: "app",
60
- image: "app:1.0",
61
- ingressHost: "app.example.com",
62
- });
63
- expect(result.ingress).toBeDefined();
64
- const spec = p(result.ingress).spec as any;
65
- expect(spec.rules[0].host).toBe("app.example.com");
66
- });
67
-
68
- test("ingress includes TLS when ingressTlsSecret is set", () => {
69
- const result = WebApp({
70
- name: "app",
71
- image: "app:1.0",
72
- ingressHost: "app.example.com",
73
- ingressTlsSecret: "tls-secret",
74
- });
75
- const spec = p(result.ingress).spec as any;
76
- expect(spec.tls).toBeDefined();
77
- expect(spec.tls[0].secretName).toBe("tls-secret");
78
- });
79
-
80
- test("props flow through (image, port, replicas)", () => {
81
- const result = WebApp({
82
- name: "web",
83
- image: "web:2.0",
84
- port: 3000,
85
- replicas: 5,
86
- });
87
- const spec = p(result.deployment).spec as any;
88
- expect(spec.replicas).toBe(5);
89
- const container = spec.template.spec.containers[0];
90
- expect(container.image).toBe("web:2.0");
91
- expect(container.ports[0].containerPort).toBe(3000);
92
- });
93
-
94
- test("default port is 80", () => {
95
- const result = WebApp({ name: "app", image: "app:1.0" });
96
- const spec = p(result.deployment).spec as any;
97
- const container = spec.template.spec.containers[0];
98
- expect(container.ports[0].containerPort).toBe(80);
99
- });
100
-
101
- test("default replicas is 2", () => {
102
- const result = WebApp({ name: "app", image: "app:1.0" });
103
- const spec = p(result.deployment).spec as any;
104
- expect(spec.replicas).toBe(2);
105
- });
106
-
107
- test("service type is ClusterIP", () => {
108
- const result = WebApp({ name: "app", image: "app:1.0" });
109
- const spec = p(result.service).spec as any;
110
- expect(spec.type).toBe("ClusterIP");
111
- });
112
-
113
- test("includes common labels", () => {
114
- const result = WebApp({ name: "app", image: "app:1.0" });
115
- const meta = p(result.deployment).metadata as any;
116
- expect(meta.labels["app.kubernetes.io/name"]).toBe("app");
117
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
118
- });
119
-
120
- test("namespace is set when provided", () => {
121
- const result = WebApp({
122
- name: "app",
123
- image: "app:1.0",
124
- namespace: "prod",
125
- });
126
- const meta = p(result.deployment).metadata as any;
127
- expect(meta.namespace).toBe("prod");
128
- });
129
-
130
- test("env vars passed to container", () => {
131
- const result = WebApp({
132
- name: "app",
133
- image: "app:1.0",
134
- env: [{ name: "FOO", value: "bar" }],
135
- });
136
- const spec = p(result.deployment).spec as any;
137
- const container = spec.template.spec.containers[0];
138
- expect(container.env).toEqual([{ name: "FOO", value: "bar" }]);
139
- });
140
-
141
- test("component labels on each resource", () => {
142
- const result = WebApp({
143
- name: "app",
144
- image: "app:1.0",
145
- ingressHost: "app.example.com",
146
- });
147
- expect((p(result.deployment).metadata as any).labels["app.kubernetes.io/component"]).toBe("server");
148
- expect((p(result.service).metadata as any).labels["app.kubernetes.io/component"]).toBe("server");
149
- expect((p(result.ingress).metadata as any).labels["app.kubernetes.io/component"]).toBe("ingress");
150
- });
151
- });
152
-
153
- // ── StatefulApp ─────────────────────────────────────────────────────
154
-
155
- describe("StatefulApp", () => {
156
- test("returns statefulSet and service", () => {
157
- const result = StatefulApp({ name: "db", image: "postgres:16" });
158
- expect(result.statefulSet).toBeDefined();
159
- expect(result.service).toBeDefined();
160
- });
161
-
162
- test("service is headless (clusterIP: None)", () => {
163
- const result = StatefulApp({ name: "db", image: "postgres:16" });
164
- const spec = p(result.service).spec as any;
165
- expect(spec.clusterIP).toBe("None");
166
- });
167
-
168
- test("includes volumeClaimTemplates", () => {
169
- const result = StatefulApp({
170
- name: "db",
171
- image: "postgres:16",
172
- storageSize: "20Gi",
173
- });
174
- const spec = p(result.statefulSet).spec as any;
175
- expect(spec.volumeClaimTemplates).toBeDefined();
176
- expect(spec.volumeClaimTemplates[0].spec.resources.requests.storage).toBe(
177
- "20Gi",
178
- );
179
- });
180
-
181
- test("default port is 5432", () => {
182
- const result = StatefulApp({ name: "db", image: "postgres:16" });
183
- const spec = p(result.statefulSet).spec as any;
184
- const container = spec.template.spec.containers[0];
185
- expect(container.ports[0].containerPort).toBe(5432);
186
- });
187
-
188
- test("default replicas is 1", () => {
189
- const result = StatefulApp({ name: "db", image: "postgres:16" });
190
- const spec = p(result.statefulSet).spec as any;
191
- expect(spec.replicas).toBe(1);
192
- });
193
-
194
- test("serviceName matches name", () => {
195
- const result = StatefulApp({ name: "db", image: "postgres:16" });
196
- const spec = p(result.statefulSet).spec as any;
197
- expect(spec.serviceName).toBe("db");
198
- });
199
-
200
- test("storageClassName set when provided", () => {
201
- const result = StatefulApp({
202
- name: "db",
203
- image: "postgres:16",
204
- storageClassName: "ssd",
205
- });
206
- const spec = p(result.statefulSet).spec as any;
207
- expect(spec.volumeClaimTemplates[0].spec.storageClassName).toBe("ssd");
208
- });
209
-
210
- test("component labels on each resource", () => {
211
- const result = StatefulApp({ name: "db", image: "postgres:16" });
212
- expect((p(result.statefulSet).metadata as any).labels["app.kubernetes.io/component"]).toBe("database");
213
- expect((p(result.service).metadata as any).labels["app.kubernetes.io/component"]).toBe("database");
214
- });
215
- });
216
-
217
- // ── CronWorkload ────────────────────────────────────────────────────
218
-
219
- describe("CronWorkload", () => {
220
- test("returns cronJob, serviceAccount, role, roleBinding", () => {
221
- const result = CronWorkload({
222
- name: "backup",
223
- image: "backup:1.0",
224
- schedule: "0 2 * * *",
225
- });
226
- expect(result.cronJob).toBeDefined();
227
- expect(result.serviceAccount).toBeDefined();
228
- expect(result.role).toBeDefined();
229
- expect(result.roleBinding).toBeDefined();
230
- });
231
-
232
- test("cronJob has correct schedule", () => {
233
- const result = CronWorkload({
234
- name: "backup",
235
- image: "backup:1.0",
236
- schedule: "0 2 * * *",
237
- });
238
- const spec = p(result.cronJob).spec as any;
239
- expect(spec.schedule).toBe("0 2 * * *");
240
- });
241
-
242
- test("RBAC references correct ServiceAccount", () => {
243
- const result = CronWorkload({
244
- name: "backup",
245
- image: "backup:1.0",
246
- schedule: "0 2 * * *",
247
- });
248
- const binding = p(result.roleBinding) as any;
249
- expect(binding.subjects[0].name).toBe("backup-sa");
250
- expect(binding.roleRef.name).toBe("backup-role");
251
- });
252
-
253
- test("serviceAccount name follows naming convention", () => {
254
- const result = CronWorkload({
255
- name: "cleanup",
256
- image: "cleanup:1.0",
257
- schedule: "*/5 * * * *",
258
- });
259
- const meta = p(result.serviceAccount).metadata as any;
260
- expect(meta.name).toBe("cleanup-sa");
261
- });
262
-
263
- test("custom RBAC rules are used", () => {
264
- const result = CronWorkload({
265
- name: "backup",
266
- image: "backup:1.0",
267
- schedule: "0 2 * * *",
268
- rbacRules: [
269
- { apiGroups: [""], resources: ["secrets"], verbs: ["get"] },
270
- ],
271
- });
272
- const role = p(result.role) as any;
273
- expect(role.rules[0].resources).toEqual(["secrets"]);
274
- expect(role.rules[0].verbs).toEqual(["get"]);
275
- });
276
-
277
- test("default RBAC rules when none provided", () => {
278
- const result = CronWorkload({
279
- name: "backup",
280
- image: "backup:1.0",
281
- schedule: "0 2 * * *",
282
- });
283
- const role = p(result.role) as any;
284
- expect(role.rules.length).toBeGreaterThan(0);
285
- });
286
-
287
- test("command and args passed through", () => {
288
- const result = CronWorkload({
289
- name: "backup",
290
- image: "backup:1.0",
291
- schedule: "0 2 * * *",
292
- command: ["pg_dump"],
293
- args: ["-h", "postgres"],
294
- });
295
- const spec = p(result.cronJob).spec as any;
296
- const container =
297
- spec.jobTemplate.spec.template.spec.containers[0];
298
- expect(container.command).toEqual(["pg_dump"]);
299
- expect(container.args).toEqual(["-h", "postgres"]);
300
- });
301
-
302
- test("default restartPolicy is OnFailure", () => {
303
- const result = CronWorkload({
304
- name: "backup",
305
- image: "backup:1.0",
306
- schedule: "0 2 * * *",
307
- });
308
- const spec = p(result.cronJob).spec as any;
309
- expect(spec.jobTemplate.spec.template.spec.restartPolicy).toBe(
310
- "OnFailure",
311
- );
312
- });
313
-
314
- test("includes common labels on all resources", () => {
315
- const result = CronWorkload({
316
- name: "backup",
317
- image: "backup:1.0",
318
- schedule: "0 2 * * *",
319
- });
320
-
321
- for (const resource of [
322
- result.cronJob,
323
- result.serviceAccount,
324
- result.role,
325
- result.roleBinding,
326
- ]) {
327
- const meta = p(resource).metadata as any;
328
- expect(meta.labels["app.kubernetes.io/name"]).toBe("backup");
329
- }
330
- });
331
-
332
- test("component labels on each resource", () => {
333
- const result = CronWorkload({
334
- name: "backup",
335
- image: "backup:1.0",
336
- schedule: "0 2 * * *",
337
- });
338
- expect((p(result.cronJob).metadata as any).labels["app.kubernetes.io/component"]).toBe("worker");
339
- expect((p(result.serviceAccount).metadata as any).labels["app.kubernetes.io/component"]).toBe("worker");
340
- expect((p(result.role).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
341
- expect((p(result.roleBinding).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
342
- });
343
-
344
- // ── schedule validation (#2071 item 4) ────────────────────────────
345
-
346
- test("accepts a valid five-field schedule", () => {
347
- expect(() =>
348
- CronWorkload({ name: "backup", image: "backup:1.0", schedule: "0 2 * * *" }),
349
- ).not.toThrow();
350
- });
351
-
352
- test("refuses a 6-field (seconds) schedule, naming the field, the value, and the CronJob limit", () => {
353
- expect(() =>
354
- CronWorkload({ name: "backup", image: "backup:1.0", schedule: "0 0 2 * * *" }),
355
- ).toThrow(/schedule "0 0 2 \* \* \*" is 6-field cron.*five fields/s);
356
- });
357
-
358
- test("refuses a malformed schedule", () => {
359
- expect(() =>
360
- CronWorkload({ name: "backup", image: "backup:1.0", schedule: "not a cron" }),
361
- ).toThrow(/schedule "not a cron" is not valid cron syntax/);
362
- });
363
-
364
- test("refuses a blank schedule", () => {
365
- expect(() =>
366
- CronWorkload({ name: "backup", image: "backup:1.0", schedule: "" }),
367
- ).toThrow(/schedule is required/);
368
- });
369
- });
370
-
371
- // ── AutoscaledService ──────────────────────────────────────────────
372
-
373
- describe("AutoscaledService", () => {
374
- const minProps = {
375
- name: "api",
376
- image: "api:1.0",
377
- maxReplicas: 10,
378
- cpuRequest: "100m",
379
- memoryRequest: "128Mi",
380
- };
381
-
382
- test("returns deployment, service, hpa, pdb", () => {
383
- const result = AutoscaledService(minProps);
384
- expect(result.deployment).toBeDefined();
385
- expect(result.service).toBeDefined();
386
- expect(result.hpa).toBeDefined();
387
- expect(result.pdb).toBeDefined();
388
- });
389
-
390
- test("default port is 80", () => {
391
- const result = AutoscaledService(minProps);
392
- const spec = p(result.deployment).spec as any;
393
- const container = spec.template.spec.containers[0];
394
- expect(container.ports[0].containerPort).toBe(80);
395
- });
396
-
397
- test("default minReplicas is 2", () => {
398
- const result = AutoscaledService(minProps);
399
- const spec = p(result.deployment).spec as any;
400
- expect(spec.replicas).toBe(2);
401
- const hpaSpec = p(result.hpa).spec as any;
402
- expect(hpaSpec.minReplicas).toBe(2);
403
- });
404
-
405
- test("HPA scaleTargetRef references the deployment", () => {
406
- const result = AutoscaledService(minProps);
407
- const hpaSpec = p(result.hpa).spec as any;
408
- expect(hpaSpec.scaleTargetRef.kind).toBe("Deployment");
409
- expect(hpaSpec.scaleTargetRef.name).toBe("api");
410
- });
411
-
412
- test("HPA has CPU metric with default 70%", () => {
413
- const result = AutoscaledService(minProps);
414
- const hpaSpec = p(result.hpa).spec as any;
415
- expect(hpaSpec.metrics[0].resource.name).toBe("cpu");
416
- expect(hpaSpec.metrics[0].resource.target.averageUtilization).toBe(70);
417
- });
418
-
419
- test("HPA includes memory metric when targetMemoryPercent set", () => {
420
- const result = AutoscaledService({ ...minProps, targetMemoryPercent: 80 });
421
- const hpaSpec = p(result.hpa).spec as any;
422
- expect(hpaSpec.metrics).toHaveLength(2);
423
- expect(hpaSpec.metrics[1].resource.name).toBe("memory");
424
- expect(hpaSpec.metrics[1].resource.target.averageUtilization).toBe(80);
425
- });
426
-
427
- test("no memory metric by default", () => {
428
- const result = AutoscaledService(minProps);
429
- const hpaSpec = p(result.hpa).spec as any;
430
- expect(hpaSpec.metrics).toHaveLength(1);
431
- });
432
-
433
- test("PDB selector matches deployment pod labels", () => {
434
- const result = AutoscaledService(minProps);
435
- const pdbSpec = p(result.pdb).spec as any;
436
- expect(pdbSpec.selector.matchLabels["app.kubernetes.io/name"]).toBe("api");
437
- expect(pdbSpec.minAvailable).toBe(1);
438
- });
439
-
440
- test("resource requests are always set", () => {
441
- const result = AutoscaledService(minProps);
442
- const spec = p(result.deployment).spec as any;
443
- const container = spec.template.spec.containers[0];
444
- expect(container.resources.requests.cpu).toBe("100m");
445
- expect(container.resources.requests.memory).toBe("128Mi");
446
- });
447
-
448
- test("resource limits only set when provided", () => {
449
- const result = AutoscaledService(minProps);
450
- const spec = p(result.deployment).spec as any;
451
- const container = spec.template.spec.containers[0];
452
- expect(container.resources.limits).toBeUndefined();
453
-
454
- const withLimits = AutoscaledService({ ...minProps, cpuLimit: "1", memoryLimit: "512Mi" });
455
- const spec2 = p(withLimits.deployment).spec as any;
456
- const container2 = spec2.template.spec.containers[0];
457
- expect(container2.resources.limits.cpu).toBe("1");
458
- expect(container2.resources.limits.memory).toBe("512Mi");
459
- });
460
-
461
- test("includes health probes", () => {
462
- const result = AutoscaledService(minProps);
463
- const spec = p(result.deployment).spec as any;
464
- const container = spec.template.spec.containers[0];
465
- expect(container.livenessProbe).toBeDefined();
466
- expect(container.readinessProbe).toBeDefined();
467
- });
468
-
469
- test("service type is ClusterIP", () => {
470
- const result = AutoscaledService(minProps);
471
- const spec = p(result.service).spec as any;
472
- expect(spec.type).toBe("ClusterIP");
473
- });
474
-
475
- test("includes common labels on all resources", () => {
476
- const result = AutoscaledService(minProps);
477
- for (const resource of [result.deployment, result.service, result.hpa, result.pdb]) {
478
- const meta = p(resource).metadata as any;
479
- expect(meta.labels["app.kubernetes.io/name"]).toBe("api");
480
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
481
- }
482
- });
483
-
484
- test("namespace propagated to all resources", () => {
485
- const result = AutoscaledService({ ...minProps, namespace: "prod" });
486
- for (const resource of [result.deployment, result.service, result.hpa, result.pdb]) {
487
- const meta = p(resource).metadata as any;
488
- expect(meta.namespace).toBe("prod");
489
- }
490
- });
491
-
492
- test("env vars passed to container", () => {
493
- const result = AutoscaledService({
494
- ...minProps,
495
- env: [{ name: "LOG_LEVEL", value: "debug" }],
496
- });
497
- const spec = p(result.deployment).spec as any;
498
- const container = spec.template.spec.containers[0];
499
- expect(container.env).toEqual([{ name: "LOG_LEVEL", value: "debug" }]);
500
- });
501
-
502
- test("component labels on each resource", () => {
503
- const result = AutoscaledService(minProps);
504
- expect((p(result.deployment).metadata as any).labels["app.kubernetes.io/component"]).toBe("server");
505
- expect((p(result.service).metadata as any).labels["app.kubernetes.io/component"]).toBe("server");
506
- expect((p(result.hpa).metadata as any).labels["app.kubernetes.io/component"]).toBe("autoscaler");
507
- expect((p(result.pdb).metadata as any).labels["app.kubernetes.io/component"]).toBe("disruption-budget");
508
- });
509
-
510
- test("default probe paths are /healthz and /readyz", () => {
511
- const result = AutoscaledService(minProps);
512
- const spec = p(result.deployment).spec as any;
513
- const container = spec.template.spec.containers[0];
514
- expect(container.livenessProbe.httpGet.path).toBe("/healthz");
515
- expect(container.readinessProbe.httpGet.path).toBe("/readyz");
516
- });
517
-
518
- test("custom probe paths override defaults", () => {
519
- const result = AutoscaledService({
520
- ...minProps,
521
- livenessPath: "/alive",
522
- readinessPath: "/ready",
523
- });
524
- const spec = p(result.deployment).spec as any;
525
- const container = spec.template.spec.containers[0];
526
- expect(container.livenessProbe.httpGet.path).toBe("/alive");
527
- expect(container.readinessProbe.httpGet.path).toBe("/ready");
528
- });
529
-
530
- test("probe targets container port", () => {
531
- const result = AutoscaledService({ ...minProps, port: 8080 });
532
- const spec = p(result.deployment).spec as any;
533
- const container = spec.template.spec.containers[0];
534
- expect(container.livenessProbe.httpGet.port).toBe(8080);
535
- expect(container.readinessProbe.httpGet.port).toBe(8080);
536
- });
537
-
538
- test("topologySpread not present by default", () => {
539
- const result = AutoscaledService(minProps);
540
- const spec = p(result.deployment).spec as any;
541
- expect(spec.template.spec.topologySpreadConstraints).toBeUndefined();
542
- });
543
-
544
- test("topologySpread: true adds zone constraint", () => {
545
- const result = AutoscaledService({ ...minProps, topologySpread: true });
546
- const spec = p(result.deployment).spec as any;
547
- const tsc = spec.template.spec.topologySpreadConstraints;
548
- expect(tsc).toHaveLength(1);
549
- expect(tsc[0].topologyKey).toBe("topology.kubernetes.io/zone");
550
- expect(tsc[0].maxSkew).toBe(1);
551
- expect(tsc[0].whenUnsatisfiable).toBe("DoNotSchedule");
552
- expect(tsc[0].labelSelector.matchLabels["app.kubernetes.io/name"]).toBe("api");
553
- });
554
-
555
- test("topologySpread custom object", () => {
556
- const result = AutoscaledService({
557
- ...minProps,
558
- topologySpread: { maxSkew: 2, topologyKey: "kubernetes.io/hostname" },
559
- });
560
- const spec = p(result.deployment).spec as any;
561
- const tsc = spec.template.spec.topologySpreadConstraints;
562
- expect(tsc[0].maxSkew).toBe(2);
563
- expect(tsc[0].topologyKey).toBe("kubernetes.io/hostname");
564
- });
565
-
566
- test("minAvailable as string percentage", () => {
567
- const result = AutoscaledService({ ...minProps, minAvailable: "50%" });
568
- const pdbSpec = p(result.pdb).spec as any;
569
- expect(pdbSpec.minAvailable).toBe("50%");
570
- });
571
-
572
- test("custom targetCPUPercent", () => {
573
- const result = AutoscaledService({ ...minProps, targetCPUPercent: 85 });
574
- const hpaSpec = p(result.hpa).spec as any;
575
- expect(hpaSpec.metrics[0].resource.target.averageUtilization).toBe(85);
576
- });
577
-
578
- test("pod template labels include extra labels", () => {
579
- const result = AutoscaledService({ ...minProps, labels: { team: "platform" } });
580
- const spec = p(result.deployment).spec as any;
581
- const podLabels = spec.template.metadata.labels;
582
- expect(podLabels.team).toBe("platform");
583
- expect(podLabels["app.kubernetes.io/name"]).toBe("api");
584
- });
585
-
586
- test("serviceAccountName wired into pod spec", () => {
587
- const result = AutoscaledService({ ...minProps, serviceAccountName: "my-sa" });
588
- const spec = p(result.deployment).spec as any;
589
- expect(spec.template.spec.serviceAccountName).toBe("my-sa");
590
- });
591
-
592
- test("no serviceAccountName by default", () => {
593
- const result = AutoscaledService(minProps);
594
- const spec = p(result.deployment).spec as any;
595
- expect(spec.template.spec.serviceAccountName).toBeUndefined();
596
- });
597
-
598
- test("volumes and volumeMounts wired into pod spec", () => {
599
- const result = AutoscaledService({
600
- ...minProps,
601
- volumes: [{ name: "data", emptyDir: {} }],
602
- volumeMounts: [{ name: "data", mountPath: "/data" }],
603
- });
604
- const spec = p(result.deployment).spec as any;
605
- expect(spec.template.spec.volumes).toEqual([{ name: "data", emptyDir: {} }]);
606
- expect(spec.template.spec.containers[0].volumeMounts).toEqual([{ name: "data", mountPath: "/data" }]);
607
- });
608
-
609
- test("tmpDirs generates emptyDir volumes and mounts", () => {
610
- const result = AutoscaledService({
611
- ...minProps,
612
- tmpDirs: ["/tmp", "/var/cache/nginx"],
613
- });
614
- const spec = p(result.deployment).spec as any;
615
- expect(spec.template.spec.volumes).toEqual([
616
- { name: "tmp-0", emptyDir: {} },
617
- { name: "tmp-1", emptyDir: {} },
618
- ]);
619
- expect(spec.template.spec.containers[0].volumeMounts).toEqual([
620
- { name: "tmp-0", mountPath: "/tmp" },
621
- { name: "tmp-1", mountPath: "/var/cache/nginx" },
622
- ]);
623
- });
624
-
625
- test("tmpDirs merges with explicit volumes/volumeMounts", () => {
626
- const result = AutoscaledService({
627
- ...minProps,
628
- volumes: [{ name: "config", configMap: { name: "app-config" } }],
629
- volumeMounts: [{ name: "config", mountPath: "/etc/config" }],
630
- tmpDirs: ["/tmp"],
631
- });
632
- const spec = p(result.deployment).spec as any;
633
- expect(spec.template.spec.volumes).toEqual([
634
- { name: "config", configMap: { name: "app-config" } },
635
- { name: "tmp-0", emptyDir: {} },
636
- ]);
637
- expect(spec.template.spec.containers[0].volumeMounts).toEqual([
638
- { name: "config", mountPath: "/etc/config" },
639
- { name: "tmp-0", mountPath: "/tmp" },
640
- ]);
641
- });
642
- });
643
-
644
- // ── WorkerPool ─────────────────────────────────────────────────────
645
-
646
- describe("WorkerPool", () => {
647
- const minProps = { name: "worker", image: "worker:1.0" };
648
-
649
- test("returns deployment, serviceAccount, role, roleBinding", () => {
650
- const result = WorkerPool(minProps);
651
- expect(result.deployment).toBeDefined();
652
- expect(result.serviceAccount).toBeDefined();
653
- expect(result.role).toBeDefined();
654
- expect(result.roleBinding).toBeDefined();
655
- });
656
-
657
- test("no configMap or hpa by default", () => {
658
- const result = WorkerPool(minProps);
659
- expect(result.configMap).toBeUndefined();
660
- expect(result.hpa).toBeUndefined();
661
- });
662
-
663
- test("default replicas is 1", () => {
664
- const result = WorkerPool(minProps);
665
- const spec = p(result.deployment).spec as any;
666
- expect(spec.replicas).toBe(1);
667
- });
668
-
669
- test("RBAC naming convention", () => {
670
- const result = WorkerPool(minProps);
671
- const saMeta = p(result.serviceAccount).metadata as any;
672
- const roleMeta = p(result.role).metadata as any;
673
- const bindingMeta = p(result.roleBinding).metadata as any;
674
- expect(saMeta.name).toBe("worker-sa");
675
- expect(roleMeta.name).toBe("worker-role");
676
- expect(bindingMeta.name).toBe("worker-binding");
677
- });
678
-
679
- test("default RBAC rules for secrets and configmaps", () => {
680
- const result = WorkerPool(minProps);
681
- const role = p(result.role!) as any;
682
- expect(role.rules[0].resources).toEqual(["secrets", "configmaps"]);
683
- expect(role.rules[0].verbs).toEqual(["get"]);
684
- });
685
-
686
- test("custom RBAC rules are used", () => {
687
- const result = WorkerPool({
688
- ...minProps,
689
- rbacRules: [{ apiGroups: ["batch"], resources: ["jobs"], verbs: ["create"] }],
690
- });
691
- const role = p(result.role!) as any;
692
- expect(role.rules[0].resources).toEqual(["jobs"]);
693
- });
694
-
695
- test("command and args passed through", () => {
696
- const result = WorkerPool({
697
- ...minProps,
698
- command: ["bundle", "exec", "sidekiq"],
699
- args: ["-c", "5"],
700
- });
701
- const spec = p(result.deployment).spec as any;
702
- const container = spec.template.spec.containers[0];
703
- expect(container.command).toEqual(["bundle", "exec", "sidekiq"]);
704
- expect(container.args).toEqual(["-c", "5"]);
705
- });
706
-
707
- test("config creates ConfigMap with envFrom", () => {
708
- const result = WorkerPool({
709
- ...minProps,
710
- config: { REDIS_URL: "redis://redis:6379" },
711
- });
712
- expect(result.configMap).toBeDefined();
713
- const data = (p(result.configMap) as any).data;
714
- expect(data.REDIS_URL).toBe("redis://redis:6379");
715
-
716
- const spec = p(result.deployment).spec as any;
717
- const container = spec.template.spec.containers[0];
718
- expect(container.envFrom[0].configMapRef.name).toBe("worker-config");
719
- });
720
-
721
- test("autoscaling creates HPA and overrides replicas", () => {
722
- const result = WorkerPool({
723
- ...minProps,
724
- autoscaling: { minReplicas: 2, maxReplicas: 8, targetCPUPercent: 60 },
725
- });
726
- expect(result.hpa).toBeDefined();
727
- const hpaSpec = (p(result.hpa) as any).spec;
728
- expect(hpaSpec.minReplicas).toBe(2);
729
- expect(hpaSpec.maxReplicas).toBe(8);
730
- expect(hpaSpec.scaleTargetRef.name).toBe("worker");
731
-
732
- const spec = p(result.deployment).spec as any;
733
- expect(spec.replicas).toBe(2);
734
- });
735
-
736
- test("default resource limits", () => {
737
- const result = WorkerPool(minProps);
738
- const spec = p(result.deployment).spec as any;
739
- const container = spec.template.spec.containers[0];
740
- expect(container.resources.requests.cpu).toBe("100m");
741
- expect(container.resources.requests.memory).toBe("128Mi");
742
- expect(container.resources.limits.cpu).toBe("500m");
743
- expect(container.resources.limits.memory).toBe("256Mi");
744
- });
745
-
746
- test("serviceAccountName on pod spec", () => {
747
- const result = WorkerPool(minProps);
748
- const spec = p(result.deployment).spec as any;
749
- expect(spec.template.spec.serviceAccountName).toBe("worker-sa");
750
- });
751
-
752
- test("includes common labels on all resources", () => {
753
- const result = WorkerPool(minProps);
754
- for (const resource of [result.deployment, result.serviceAccount!, result.role!, result.roleBinding!]) {
755
- const meta = p(resource).metadata as any;
756
- expect(meta.labels["app.kubernetes.io/name"]).toBe("worker");
757
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
758
- }
759
- });
760
-
761
- test("namespace propagated", () => {
762
- const result = WorkerPool({ ...minProps, namespace: "jobs" });
763
- for (const resource of [result.deployment, result.serviceAccount!, result.role!, result.roleBinding!]) {
764
- const meta = p(resource).metadata as any;
765
- expect(meta.namespace).toBe("jobs");
766
- }
767
- });
768
-
769
- test("rbacRules: [] produces no RBAC resources", () => {
770
- const result = WorkerPool({ ...minProps, rbacRules: [] });
771
- expect(result.serviceAccount).toBeUndefined();
772
- expect(result.role).toBeUndefined();
773
- expect(result.roleBinding).toBeUndefined();
774
- const spec = p(result.deployment).spec as any;
775
- expect(spec.template.spec.serviceAccountName).toBeUndefined();
776
- });
777
-
778
- test("rbacRules undefined produces default RBAC", () => {
779
- const result = WorkerPool(minProps);
780
- expect(result.serviceAccount).toBeDefined();
781
- expect(result.role).toBeDefined();
782
- expect(result.roleBinding).toBeDefined();
783
- const role = p(result.role) as any;
784
- expect(role.rules[0].resources).toEqual(["secrets", "configmaps"]);
785
- });
786
-
787
- test("env vars on container", () => {
788
- const result = WorkerPool({
789
- ...minProps,
790
- env: [{ name: "LOG_LEVEL", value: "debug" }],
791
- });
792
- const spec = p(result.deployment).spec as any;
793
- const container = spec.template.spec.containers[0];
794
- expect(container.env).toEqual([{ name: "LOG_LEVEL", value: "debug" }]);
795
- });
796
-
797
- test("ConfigMap carries namespace and labels", () => {
798
- const result = WorkerPool({
799
- ...minProps,
800
- config: { KEY: "val" },
801
- namespace: "jobs",
802
- });
803
- const meta = (p(result.configMap) as any).metadata;
804
- expect(meta.namespace).toBe("jobs");
805
- expect(meta.labels["app.kubernetes.io/name"]).toBe("worker");
806
- });
807
-
808
- test("HPA carries namespace", () => {
809
- const result = WorkerPool({
810
- ...minProps,
811
- autoscaling: { minReplicas: 1, maxReplicas: 5 },
812
- namespace: "jobs",
813
- });
814
- const meta = (p(result.hpa) as any).metadata;
815
- expect(meta.namespace).toBe("jobs");
816
- });
817
-
818
- test("autoscaling default targetCPUPercent is 70", () => {
819
- const result = WorkerPool({
820
- ...minProps,
821
- autoscaling: { minReplicas: 1, maxReplicas: 5 },
822
- });
823
- const hpaSpec = (p(result.hpa) as any).spec;
824
- expect(hpaSpec.metrics[0].resource.target.averageUtilization).toBe(70);
825
- });
826
-
827
- test("component labels on each resource", () => {
828
- const result = WorkerPool({
829
- ...minProps,
830
- config: { K: "V" },
831
- autoscaling: { minReplicas: 1, maxReplicas: 5 },
832
- });
833
- expect((p(result.deployment).metadata as any).labels["app.kubernetes.io/component"]).toBe("worker");
834
- expect((p(result.serviceAccount).metadata as any).labels["app.kubernetes.io/component"]).toBe("worker");
835
- expect((p(result.role).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
836
- expect((p(result.roleBinding).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
837
- expect((p(result.configMap).metadata as any).labels["app.kubernetes.io/component"]).toBe("config");
838
- expect((p(result.hpa).metadata as any).labels["app.kubernetes.io/component"]).toBe("autoscaler");
839
- });
840
- });
841
-
842
- // ── NamespaceEnv ───────────────────────────────────────────────────
843
-
844
- describe("NamespaceEnv", () => {
845
- test("returns namespace only with minimal props", () => {
846
- const result = NamespaceEnv({
847
- name: "team-alpha",
848
- defaultDenyIngress: false,
849
- });
850
- expect(result.namespace).toBeDefined();
851
- expect(result.resourceQuota).toBeUndefined();
852
- expect(result.limitRange).toBeUndefined();
853
- expect(result.networkPolicy).toBeUndefined();
854
- });
855
-
856
- test("default-deny ingress NetworkPolicy created by default", () => {
857
- const result = NamespaceEnv({ name: "team-alpha" });
858
- expect(result.networkPolicy).toBeDefined();
859
- const spec = p(result.networkPolicy).spec as any;
860
- expect(spec.policyTypes).toEqual(["Ingress"]);
861
- expect(spec.podSelector).toEqual({});
862
- });
863
-
864
- test("egress deny when enabled", () => {
865
- const result = NamespaceEnv({
866
- name: "team-alpha",
867
- defaultDenyEgress: true,
868
- });
869
- const spec = p(result.networkPolicy).spec as any;
870
- expect(spec.policyTypes).toContain("Ingress");
871
- expect(spec.policyTypes).toContain("Egress");
872
- });
873
-
874
- test("ResourceQuota created when quota props set", () => {
875
- const result = NamespaceEnv({
876
- name: "team-alpha",
877
- cpuQuota: "8",
878
- memoryQuota: "16Gi",
879
- maxPods: 50,
880
- });
881
- expect(result.resourceQuota).toBeDefined();
882
- const spec = p(result.resourceQuota).spec as any;
883
- expect(spec.hard["limits.cpu"]).toBe("8");
884
- expect(spec.hard["limits.memory"]).toBe("16Gi");
885
- expect(spec.hard.pods).toBe("50");
886
- });
887
-
888
- test("ResourceQuota in correct namespace", () => {
889
- const result = NamespaceEnv({ name: "team-alpha", cpuQuota: "4" });
890
- const meta = p(result.resourceQuota).metadata as any;
891
- expect(meta.namespace).toBe("team-alpha");
892
- expect(meta.name).toBe("team-alpha-quota");
893
- });
894
-
895
- test("LimitRange created when limit defaults set", () => {
896
- const result = NamespaceEnv({
897
- name: "team-alpha",
898
- defaultCpuRequest: "100m",
899
- defaultMemoryRequest: "128Mi",
900
- defaultCpuLimit: "500m",
901
- defaultMemoryLimit: "512Mi",
902
- });
903
- expect(result.limitRange).toBeDefined();
904
- const spec = p(result.limitRange).spec as any;
905
- const limit = spec.limits[0];
906
- expect(limit.type).toBe("Container");
907
- expect(limit.default.cpu).toBe("500m");
908
- expect(limit.default.memory).toBe("512Mi");
909
- expect(limit.defaultRequest.cpu).toBe("100m");
910
- expect(limit.defaultRequest.memory).toBe("128Mi");
911
- });
912
-
913
- test("LimitRange in correct namespace", () => {
914
- const result = NamespaceEnv({ name: "team-alpha", defaultCpuLimit: "1" });
915
- const meta = p(result.limitRange).metadata as any;
916
- expect(meta.namespace).toBe("team-alpha");
917
- expect(meta.name).toBe("team-alpha-limits");
918
- });
919
-
920
- test("includes common labels", () => {
921
- const result = NamespaceEnv({ name: "team-alpha" });
922
- const meta = p(result.namespace).metadata as any;
923
- expect(meta.labels["app.kubernetes.io/name"]).toBe("team-alpha");
924
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
925
- });
926
-
927
- test("namespace resource has no namespace field (cluster-scoped)", () => {
928
- const result = NamespaceEnv({ name: "team-alpha" });
929
- const meta = p(result.namespace).metadata as any;
930
- expect(meta.namespace).toBeUndefined();
931
- });
932
-
933
- test("warns when quota set without limits", () => {
934
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
935
- NamespaceEnv({ name: "warn-test", cpuQuota: "4", defaultDenyIngress: false });
936
- expect(warnSpy).toHaveBeenCalledWith(
937
- expect.stringContaining("ResourceQuota set but no LimitRange defaults"),
938
- );
939
- warnSpy.mockRestore();
940
- });
941
-
942
- test("no warning when both quota and limits set", () => {
943
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
944
- NamespaceEnv({
945
- name: "both-test",
946
- cpuQuota: "4",
947
- defaultCpuRequest: "100m",
948
- defaultDenyIngress: false,
949
- });
950
- expect(warnSpy).not.toHaveBeenCalled();
951
- warnSpy.mockRestore();
952
- });
953
-
954
- test("no warning when limits only (no quota)", () => {
955
- const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
956
- NamespaceEnv({
957
- name: "limits-only",
958
- defaultCpuRequest: "100m",
959
- defaultDenyIngress: false,
960
- });
961
- expect(warnSpy).not.toHaveBeenCalled();
962
- warnSpy.mockRestore();
963
- });
964
-
965
- test("egress-only deny (no ingress)", () => {
966
- const result = NamespaceEnv({
967
- name: "egress-only",
968
- defaultDenyIngress: false,
969
- defaultDenyEgress: true,
970
- });
971
- expect(result.networkPolicy).toBeDefined();
972
- const spec = p(result.networkPolicy).spec as any;
973
- expect(spec.policyTypes).toEqual(["Egress"]);
974
- });
975
-
976
- test("NetworkPolicy namespace is the namespace name", () => {
977
- const result = NamespaceEnv({ name: "team-beta", defaultDenyIngress: true });
978
- const meta = p(result.networkPolicy).metadata as any;
979
- expect(meta.namespace).toBe("team-beta");
980
- });
981
-
982
- test("extra labels on all resources", () => {
983
- const result = NamespaceEnv({
984
- name: "team-gamma",
985
- cpuQuota: "4",
986
- defaultCpuRequest: "100m",
987
- defaultDenyIngress: true,
988
- labels: { env: "staging" },
989
- });
990
- for (const resource of [result.namespace, result.resourceQuota!, result.limitRange!, result.networkPolicy!]) {
991
- const meta = p(resource).metadata as any;
992
- expect(meta.labels.env).toBe("staging");
993
- }
994
- });
995
-
996
- test("component labels on each resource", () => {
997
- const result = NamespaceEnv({
998
- name: "team-delta",
999
- cpuQuota: "4",
1000
- defaultCpuRequest: "100m",
1001
- defaultDenyIngress: true,
1002
- });
1003
- expect((p(result.namespace).metadata as any).labels["app.kubernetes.io/component"]).toBe("namespace");
1004
- expect((p(result.resourceQuota).metadata as any).labels["app.kubernetes.io/component"]).toBe("quota");
1005
- expect((p(result.limitRange).metadata as any).labels["app.kubernetes.io/component"]).toBe("limits");
1006
- expect((p(result.networkPolicy).metadata as any).labels["app.kubernetes.io/component"]).toBe("network-policy");
1007
- });
1008
- });
1009
-
1010
- // ── NodeAgent ──────────────────────────────────────────────────────
1011
-
1012
- describe("NodeAgent", () => {
1013
- const minProps = {
1014
- name: "log-agent",
1015
- image: "fluentd:v1.16",
1016
- rbacRules: [
1017
- { apiGroups: [""], resources: ["pods", "namespaces"], verbs: ["get", "list", "watch"] },
1018
- ],
1019
- };
1020
-
1021
- test("returns daemonSet, serviceAccount, clusterRole, clusterRoleBinding", () => {
1022
- const result = NodeAgent(minProps);
1023
- expect(result.daemonSet).toBeDefined();
1024
- expect(result.serviceAccount).toBeDefined();
1025
- expect(result.clusterRole).toBeDefined();
1026
- expect(result.clusterRoleBinding).toBeDefined();
1027
- });
1028
-
1029
- test("no configMap by default", () => {
1030
- const result = NodeAgent(minProps);
1031
- expect(result.configMap).toBeUndefined();
1032
- });
1033
-
1034
- test("uses ClusterRole/ClusterRoleBinding (not Role)", () => {
1035
- const result = NodeAgent(minProps);
1036
- const binding = p(result.clusterRoleBinding) as any;
1037
- expect(binding.roleRef.kind).toBe("ClusterRole");
1038
- expect(binding.roleRef.apiGroup).toBe("rbac.authorization.k8s.io");
1039
- });
1040
-
1041
- test("ClusterRole/ClusterRoleBinding are cluster-scoped (no namespace)", () => {
1042
- const result = NodeAgent({ ...minProps, namespace: "monitoring" });
1043
- const crMeta = p(result.clusterRole).metadata as any;
1044
- const crbMeta = p(result.clusterRoleBinding).metadata as any;
1045
- expect(crMeta.namespace).toBeUndefined();
1046
- expect(crbMeta.namespace).toBeUndefined();
1047
- });
1048
-
1049
- test("namespaced resources get namespace", () => {
1050
- const result = NodeAgent({ ...minProps, namespace: "monitoring" });
1051
- const dsMeta = p(result.daemonSet).metadata as any;
1052
- const saMeta = p(result.serviceAccount).metadata as any;
1053
- expect(dsMeta.namespace).toBe("monitoring");
1054
- expect(saMeta.namespace).toBe("monitoring");
1055
- });
1056
-
1057
- test("tolerateAllTaints adds Exists toleration by default", () => {
1058
- const result = NodeAgent(minProps);
1059
- const spec = p(result.daemonSet).spec as any;
1060
- const tolerations = spec.template.spec.tolerations;
1061
- expect(tolerations).toEqual([{ operator: "Exists" }]);
1062
- });
1063
-
1064
- test("tolerateAllTaints can be disabled", () => {
1065
- const result = NodeAgent({ ...minProps, tolerateAllTaints: false });
1066
- const spec = p(result.daemonSet).spec as any;
1067
- expect(spec.template.spec.tolerations).toBeUndefined();
1068
- });
1069
-
1070
- test("hostPaths mounted with readOnly true by default", () => {
1071
- const result = NodeAgent({
1072
- ...minProps,
1073
- hostPaths: [{ name: "varlog", hostPath: "/var/log", mountPath: "/var/log" }],
1074
- });
1075
- const spec = p(result.daemonSet).spec as any;
1076
- const volumes = spec.template.spec.volumes;
1077
- expect(volumes[0].name).toBe("varlog");
1078
- expect(volumes[0].hostPath.path).toBe("/var/log");
1079
-
1080
- const mounts = spec.template.spec.containers[0].volumeMounts;
1081
- expect(mounts[0].mountPath).toBe("/var/log");
1082
- expect(mounts[0].readOnly).toBe(true);
1083
- });
1084
-
1085
- test("hostPaths readOnly can be set to false", () => {
1086
- const result = NodeAgent({
1087
- ...minProps,
1088
- hostPaths: [{ name: "data", hostPath: "/data", mountPath: "/data", readOnly: false }],
1089
- });
1090
- const spec = p(result.daemonSet).spec as any;
1091
- const mounts = spec.template.spec.containers[0].volumeMounts;
1092
- expect(mounts[0].readOnly).toBe(false);
1093
- });
1094
-
1095
- test("config creates ConfigMap mounted at /etc/{name}/", () => {
1096
- const result = NodeAgent({
1097
- ...minProps,
1098
- config: { "fluent.conf": "some config" },
1099
- });
1100
- expect(result.configMap).toBeDefined();
1101
- const data = (p(result.configMap) as any).data;
1102
- expect(data["fluent.conf"]).toBe("some config");
1103
-
1104
- const spec = p(result.daemonSet).spec as any;
1105
- const volumes = spec.template.spec.volumes;
1106
- const configVol = volumes.find((v: any) => v.name === "config");
1107
- expect(configVol.configMap.name).toBe("log-agent-config");
1108
-
1109
- const mounts = spec.template.spec.containers[0].volumeMounts;
1110
- const configMount = mounts.find((m: any) => m.name === "config");
1111
- expect(configMount.mountPath).toBe("/etc/log-agent");
1112
- expect(configMount.readOnly).toBe(true);
1113
- });
1114
-
1115
- test("port creates metrics port on container", () => {
1116
- const result = NodeAgent({ ...minProps, port: 9100 });
1117
- const spec = p(result.daemonSet).spec as any;
1118
- const container = spec.template.spec.containers[0];
1119
- expect(container.ports[0].containerPort).toBe(9100);
1120
- expect(container.ports[0].name).toBe("metrics");
1121
- });
1122
-
1123
- test("RBAC naming convention", () => {
1124
- const result = NodeAgent(minProps);
1125
- const saMeta = p(result.serviceAccount).metadata as any;
1126
- const crMeta = p(result.clusterRole).metadata as any;
1127
- const crbMeta = p(result.clusterRoleBinding).metadata as any;
1128
- expect(saMeta.name).toBe("log-agent-sa");
1129
- expect(crMeta.name).toBe("log-agent-role");
1130
- expect(crbMeta.name).toBe("log-agent-binding");
1131
- });
1132
-
1133
- test("RBAC rules passed through to ClusterRole", () => {
1134
- const result = NodeAgent(minProps);
1135
- const cr = p(result.clusterRole) as any;
1136
- expect(cr.rules[0].resources).toEqual(["pods", "namespaces"]);
1137
- });
1138
-
1139
- test("includes common labels on all resources", () => {
1140
- const result = NodeAgent(minProps);
1141
- for (const resource of [result.daemonSet, result.serviceAccount, result.clusterRole, result.clusterRoleBinding]) {
1142
- const meta = p(resource).metadata as any;
1143
- expect(meta.labels["app.kubernetes.io/name"]).toBe("log-agent");
1144
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
1145
- }
1146
- });
1147
-
1148
- test("env vars passed to container", () => {
1149
- const result = NodeAgent({
1150
- ...minProps,
1151
- env: [{ name: "LOG_LEVEL", value: "info" }],
1152
- });
1153
- const spec = p(result.daemonSet).spec as any;
1154
- const container = spec.template.spec.containers[0];
1155
- expect(container.env).toEqual([{ name: "LOG_LEVEL", value: "info" }]);
1156
- });
1157
-
1158
- test("serviceAccountName on pod spec", () => {
1159
- const result = NodeAgent(minProps);
1160
- const spec = p(result.daemonSet).spec as any;
1161
- expect(spec.template.spec.serviceAccountName).toBe("log-agent-sa");
1162
- });
1163
-
1164
- test("default resource requests and limits on container", () => {
1165
- const result = NodeAgent(minProps);
1166
- const spec = p(result.daemonSet).spec as any;
1167
- const container = spec.template.spec.containers[0];
1168
- expect(container.resources.requests.cpu).toBe("50m");
1169
- expect(container.resources.requests.memory).toBe("64Mi");
1170
- expect(container.resources.limits.cpu).toBe("200m");
1171
- expect(container.resources.limits.memory).toBe("128Mi");
1172
- });
1173
-
1174
- test("custom resource limits", () => {
1175
- const result = NodeAgent({
1176
- ...minProps,
1177
- cpuRequest: "100m",
1178
- memoryRequest: "256Mi",
1179
- cpuLimit: "500m",
1180
- memoryLimit: "512Mi",
1181
- });
1182
- const spec = p(result.daemonSet).spec as any;
1183
- const container = spec.template.spec.containers[0];
1184
- expect(container.resources.requests.cpu).toBe("100m");
1185
- expect(container.resources.requests.memory).toBe("256Mi");
1186
- expect(container.resources.limits.cpu).toBe("500m");
1187
- expect(container.resources.limits.memory).toBe("512Mi");
1188
- });
1189
-
1190
- test("multiple hostPaths", () => {
1191
- const result = NodeAgent({
1192
- ...minProps,
1193
- hostPaths: [
1194
- { name: "varlog", hostPath: "/var/log", mountPath: "/var/log" },
1195
- { name: "run", hostPath: "/run", mountPath: "/run", readOnly: false },
1196
- ],
1197
- });
1198
- const spec = p(result.daemonSet).spec as any;
1199
- expect(spec.template.spec.volumes).toHaveLength(2);
1200
- expect(spec.template.spec.containers[0].volumeMounts).toHaveLength(2);
1201
- expect(spec.template.spec.containers[0].volumeMounts[1].readOnly).toBe(false);
1202
- });
1203
-
1204
- test("configMap carries namespace", () => {
1205
- const result = NodeAgent({
1206
- ...minProps,
1207
- config: { key: "val" },
1208
- namespace: "monitoring",
1209
- });
1210
- const meta = (p(result.configMap) as any).metadata;
1211
- expect(meta.namespace).toBe("monitoring");
1212
- });
1213
-
1214
- test("component labels on each resource", () => {
1215
- const result = NodeAgent({
1216
- ...minProps,
1217
- config: { key: "val" },
1218
- });
1219
- expect((p(result.daemonSet).metadata as any).labels["app.kubernetes.io/component"]).toBe("agent");
1220
- expect((p(result.serviceAccount).metadata as any).labels["app.kubernetes.io/component"]).toBe("agent");
1221
- expect((p(result.clusterRole).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
1222
- expect((p(result.clusterRoleBinding).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
1223
- expect((p(result.configMap).metadata as any).labels["app.kubernetes.io/component"]).toBe("config");
1224
- });
1225
- });
1226
-
1227
- // ── Hardening Additions ─────────────────────────────────────────────
1228
-
1229
- describe("WebApp hardening", () => {
1230
- test("PDB created when minAvailable set", () => {
1231
- const result = WebApp({ name: "app", image: "app:1.0", minAvailable: 1 });
1232
- expect(result.pdb).toBeDefined();
1233
- const spec = p(result.pdb).spec as any;
1234
- expect(spec.minAvailable).toBe(1);
1235
- expect(spec.selector.matchLabels["app.kubernetes.io/name"]).toBe("app");
1236
- });
1237
-
1238
- test("no PDB by default", () => {
1239
- const result = WebApp({ name: "app", image: "app:1.0" });
1240
- expect(result.pdb).toBeUndefined();
1241
- });
1242
-
1243
- test("initContainers passed through", () => {
1244
- const result = WebApp({
1245
- name: "app",
1246
- image: "app:1.0",
1247
- initContainers: [{ name: "migrate", image: "migrate:1.0", command: ["./migrate.sh"] }],
1248
- });
1249
- const spec = p(result.deployment).spec as any;
1250
- expect(spec.template.spec.initContainers).toHaveLength(1);
1251
- expect(spec.template.spec.initContainers[0].name).toBe("migrate");
1252
- });
1253
-
1254
- test("securityContext passed through", () => {
1255
- const result = WebApp({
1256
- name: "app",
1257
- image: "app:1.0",
1258
- securityContext: { runAsNonRoot: true, readOnlyRootFilesystem: true },
1259
- });
1260
- const spec = p(result.deployment).spec as any;
1261
- const container = spec.template.spec.containers[0];
1262
- expect(container.securityContext.runAsNonRoot).toBe(true);
1263
- });
1264
-
1265
- test("securityContext supports PSS restricted fields", () => {
1266
- const result = WebApp({
1267
- name: "app",
1268
- image: "app:1.0",
1269
- securityContext: {
1270
- runAsNonRoot: true,
1271
- readOnlyRootFilesystem: true,
1272
- allowPrivilegeEscalation: false,
1273
- capabilities: { drop: ["ALL"] },
1274
- seccompProfile: { type: "RuntimeDefault" },
1275
- },
1276
- });
1277
- const spec = p(result.deployment).spec as any;
1278
- const sc = spec.template.spec.containers[0].securityContext;
1279
- expect(sc.allowPrivilegeEscalation).toBe(false);
1280
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
1281
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
1282
- });
1283
-
1284
- test("terminationGracePeriodSeconds set", () => {
1285
- const result = WebApp({ name: "app", image: "app:1.0", terminationGracePeriodSeconds: 60 });
1286
- const spec = p(result.deployment).spec as any;
1287
- expect(spec.template.spec.terminationGracePeriodSeconds).toBe(60);
1288
- });
1289
-
1290
- test("priorityClassName set", () => {
1291
- const result = WebApp({ name: "app", image: "app:1.0", priorityClassName: "high-priority" });
1292
- const spec = p(result.deployment).spec as any;
1293
- expect(spec.template.spec.priorityClassName).toBe("high-priority");
1294
- });
1295
-
1296
- test("multi-path ingress", () => {
1297
- const result = WebApp({
1298
- name: "app",
1299
- image: "app:1.0",
1300
- ingressHost: "app.example.com",
1301
- ingressPaths: [
1302
- { path: "/api", serviceName: "api", servicePort: 8080 },
1303
- { path: "/web", serviceName: "web", servicePort: 3000 },
1304
- ],
1305
- });
1306
- const spec = p(result.ingress).spec as any;
1307
- expect(spec.rules[0].http.paths).toHaveLength(2);
1308
- expect(spec.rules[0].http.paths[0].path).toBe("/api");
1309
- expect(spec.rules[0].http.paths[1].backend.service.name).toBe("web");
1310
- });
1311
- });
1312
-
1313
- describe("StatefulApp hardening", () => {
1314
- test("PDB created when minAvailable set", () => {
1315
- const result = StatefulApp({ name: "db", image: "postgres:16", minAvailable: 1 });
1316
- expect(result.pdb).toBeDefined();
1317
- const spec = p(result.pdb).spec as any;
1318
- expect(spec.minAvailable).toBe(1);
1319
- });
1320
-
1321
- test("initContainers passed through", () => {
1322
- const result = StatefulApp({
1323
- name: "db",
1324
- image: "postgres:16",
1325
- initContainers: [{ name: "init", image: "init:1.0" }],
1326
- });
1327
- const spec = p(result.statefulSet).spec as any;
1328
- expect(spec.template.spec.initContainers).toHaveLength(1);
1329
- });
1330
-
1331
- test("securityContext passed through", () => {
1332
- const result = StatefulApp({
1333
- name: "db",
1334
- image: "postgres:16",
1335
- securityContext: { runAsNonRoot: true },
1336
- });
1337
- const spec = p(result.statefulSet).spec as any;
1338
- expect(spec.template.spec.containers[0].securityContext.runAsNonRoot).toBe(true);
1339
- });
1340
-
1341
- test("securityContext supports PSS restricted fields", () => {
1342
- const result = StatefulApp({
1343
- name: "db",
1344
- image: "postgres:16",
1345
- securityContext: {
1346
- runAsNonRoot: true,
1347
- allowPrivilegeEscalation: false,
1348
- capabilities: { drop: ["ALL"] },
1349
- seccompProfile: { type: "RuntimeDefault" },
1350
- },
1351
- });
1352
- const spec = p(result.statefulSet).spec as any;
1353
- const sc = spec.template.spec.containers[0].securityContext;
1354
- expect(sc.allowPrivilegeEscalation).toBe(false);
1355
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
1356
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
1357
- });
1358
- });
1359
-
1360
- describe("WorkerPool hardening", () => {
1361
- test("PDB created when minAvailable set", () => {
1362
- const result = WorkerPool({ name: "w", image: "w:1.0", minAvailable: 1 });
1363
- expect(result.pdb).toBeDefined();
1364
- const spec = p(result.pdb).spec as any;
1365
- expect(spec.minAvailable).toBe(1);
1366
- });
1367
-
1368
- test("securityContext on container", () => {
1369
- const result = WorkerPool({
1370
- name: "w",
1371
- image: "w:1.0",
1372
- securityContext: { runAsNonRoot: true },
1373
- });
1374
- const spec = p(result.deployment).spec as any;
1375
- expect(spec.template.spec.containers[0].securityContext.runAsNonRoot).toBe(true);
1376
- });
1377
-
1378
- test("securityContext supports PSS restricted fields", () => {
1379
- const result = WorkerPool({
1380
- name: "w",
1381
- image: "w:1.0",
1382
- securityContext: {
1383
- runAsNonRoot: true,
1384
- allowPrivilegeEscalation: false,
1385
- capabilities: { drop: ["ALL"] },
1386
- seccompProfile: { type: "RuntimeDefault" },
1387
- },
1388
- });
1389
- const spec = p(result.deployment).spec as any;
1390
- const sc = spec.template.spec.containers[0].securityContext;
1391
- expect(sc.allowPrivilegeEscalation).toBe(false);
1392
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
1393
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
1394
- });
1395
- });
1396
-
1397
- describe("AutoscaledService hardening", () => {
1398
- const minProps = { name: "api", image: "api:1.0", maxReplicas: 10, cpuRequest: "100m", memoryRequest: "128Mi" };
1399
-
1400
- test("initContainers passed through", () => {
1401
- const result = AutoscaledService({
1402
- ...minProps,
1403
- initContainers: [{ name: "migrate", image: "m:1.0" }],
1404
- });
1405
- const spec = p(result.deployment).spec as any;
1406
- expect(spec.template.spec.initContainers).toHaveLength(1);
1407
- });
1408
-
1409
- test("securityContext on container", () => {
1410
- const result = AutoscaledService({
1411
- ...minProps,
1412
- securityContext: { runAsNonRoot: true },
1413
- });
1414
- const spec = p(result.deployment).spec as any;
1415
- expect(spec.template.spec.containers[0].securityContext.runAsNonRoot).toBe(true);
1416
- });
1417
-
1418
- test("securityContext supports PSS restricted fields", () => {
1419
- const result = AutoscaledService({
1420
- ...minProps,
1421
- securityContext: {
1422
- runAsNonRoot: true,
1423
- allowPrivilegeEscalation: false,
1424
- capabilities: { drop: ["ALL"] },
1425
- seccompProfile: { type: "RuntimeDefault" },
1426
- },
1427
- });
1428
- const spec = p(result.deployment).spec as any;
1429
- const sc = spec.template.spec.containers[0].securityContext;
1430
- expect(sc.allowPrivilegeEscalation).toBe(false);
1431
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
1432
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
1433
- });
1434
-
1435
- test("terminationGracePeriodSeconds set", () => {
1436
- const result = AutoscaledService({ ...minProps, terminationGracePeriodSeconds: 30 });
1437
- const spec = p(result.deployment).spec as any;
1438
- expect(spec.template.spec.terminationGracePeriodSeconds).toBe(30);
1439
- });
1440
- });
1441
-
1442
- // ── BatchJob ────────────────────────────────────────────────────────
1443
-
1444
- describe("BatchJob", () => {
1445
- const minProps = { name: "migrate", image: "migrate:1.0" };
1446
-
1447
- test("returns job with default RBAC", () => {
1448
- const result = BatchJob(minProps);
1449
- expect(result.job).toBeDefined();
1450
- expect(result.serviceAccount).toBeDefined();
1451
- expect(result.role).toBeDefined();
1452
- expect(result.roleBinding).toBeDefined();
1453
- });
1454
-
1455
- test("default backoffLimit is 6", () => {
1456
- const result = BatchJob(minProps);
1457
- const spec = p(result.job).spec as any;
1458
- expect(spec.backoffLimit).toBe(6);
1459
- });
1460
-
1461
- test("custom backoffLimit and ttl", () => {
1462
- const result = BatchJob({ ...minProps, backoffLimit: 3, ttlSecondsAfterFinished: 3600 });
1463
- const spec = p(result.job).spec as any;
1464
- expect(spec.backoffLimit).toBe(3);
1465
- expect(spec.ttlSecondsAfterFinished).toBe(3600);
1466
- });
1467
-
1468
- test("parallelism and completions", () => {
1469
- const result = BatchJob({ ...minProps, parallelism: 3, completions: 10 });
1470
- const spec = p(result.job).spec as any;
1471
- expect(spec.parallelism).toBe(3);
1472
- expect(spec.completions).toBe(10);
1473
- });
1474
-
1475
- test("rbacRules: [] skips RBAC", () => {
1476
- const result = BatchJob({ ...minProps, rbacRules: [] });
1477
- expect(result.serviceAccount).toBeUndefined();
1478
- expect(result.role).toBeUndefined();
1479
- expect(result.roleBinding).toBeUndefined();
1480
- });
1481
-
1482
- test("command and args passed through", () => {
1483
- const result = BatchJob({ ...minProps, command: ["python"], args: ["migrate.py"] });
1484
- const spec = p(result.job).spec as any;
1485
- const container = spec.template.spec.containers[0];
1486
- expect(container.command).toEqual(["python"]);
1487
- expect(container.args).toEqual(["migrate.py"]);
1488
- });
1489
-
1490
- test("namespace propagated", () => {
1491
- const result = BatchJob({ ...minProps, namespace: "jobs" });
1492
- expect((p(result.job).metadata as any).namespace).toBe("jobs");
1493
- expect((p(result.serviceAccount).metadata as any).namespace).toBe("jobs");
1494
- });
1495
-
1496
- test("component labels", () => {
1497
- const result = BatchJob(minProps);
1498
- expect((p(result.job).metadata as any).labels["app.kubernetes.io/component"]).toBe("batch");
1499
- expect((p(result.role).metadata as any).labels["app.kubernetes.io/component"]).toBe("rbac");
1500
- });
1501
- });
1502
-
1503
- // ── SecureIngress ───────────────────────────────────────────────────
1504
-
1505
- describe("SecureIngress", () => {
1506
- const minProps = {
1507
- name: "app-ingress",
1508
- hosts: [{ hostname: "app.example.com", paths: [{ path: "/", serviceName: "app", servicePort: 80 }] }],
1509
- };
1510
-
1511
- test("returns ingress without certificate by default", () => {
1512
- const result = SecureIngress(minProps);
1513
- expect(result.ingress).toBeDefined();
1514
- expect(result.certificate).toBeUndefined();
1515
- });
1516
-
1517
- test("creates certificate when clusterIssuer set", () => {
1518
- const result = SecureIngress({ ...minProps, clusterIssuer: "letsencrypt-prod" });
1519
- expect(result.certificate).toBeDefined();
1520
- // A real cert-manager Certificate, not the former Ingress-proxy placeholder.
1521
- expect(result.certificate!.constructor.name).toBe("Certificate");
1522
- const certSpec = p(result.certificate!).spec as any;
1523
- expect(certSpec.issuerRef.name).toBe("letsencrypt-prod");
1524
- expect(certSpec.dnsNames).toEqual(["app.example.com"]);
1525
- });
1526
-
1527
- test("TLS on ingress when clusterIssuer set", () => {
1528
- const result = SecureIngress({ ...minProps, clusterIssuer: "letsencrypt-prod" });
1529
- const spec = p(result.ingress).spec as any;
1530
- expect(spec.tls).toBeDefined();
1531
- expect(spec.tls[0].hosts).toEqual(["app.example.com"]);
1532
- });
1533
-
1534
- test("multi-host support", () => {
1535
- const result = SecureIngress({
1536
- name: "multi",
1537
- hosts: [
1538
- { hostname: "api.example.com", paths: [{ path: "/", serviceName: "api", servicePort: 80 }] },
1539
- { hostname: "admin.example.com", paths: [{ path: "/", serviceName: "admin", servicePort: 80 }] },
1540
- ],
1541
- clusterIssuer: "letsencrypt-prod",
1542
- });
1543
- const spec = p(result.ingress).spec as any;
1544
- expect(spec.rules).toHaveLength(2);
1545
- const certSpec = p(result.certificate!).spec as any;
1546
- expect(certSpec.dnsNames).toHaveLength(2);
1547
- });
1548
-
1549
- test("multi-path support", () => {
1550
- const result = SecureIngress({
1551
- name: "multi-path",
1552
- hosts: [{
1553
- hostname: "app.example.com",
1554
- paths: [
1555
- { path: "/api", serviceName: "api", servicePort: 8080 },
1556
- { path: "/web", serviceName: "web", servicePort: 3000 },
1557
- ],
1558
- }],
1559
- });
1560
- const spec = p(result.ingress).spec as any;
1561
- expect(spec.rules[0].http.paths).toHaveLength(2);
1562
- });
1563
-
1564
- test("ingressClassName set", () => {
1565
- const result = SecureIngress({ ...minProps, ingressClassName: "nginx" });
1566
- const spec = p(result.ingress).spec as any;
1567
- expect(spec.ingressClassName).toBe("nginx");
1568
- });
1569
-
1570
- test("cert-manager annotation added", () => {
1571
- const result = SecureIngress({ ...minProps, clusterIssuer: "letsencrypt-prod" });
1572
- const meta = p(result.ingress).metadata as any;
1573
- expect(meta.annotations["cert-manager.io/cluster-issuer"]).toBe("letsencrypt-prod");
1574
- });
1575
- });
1576
-
1577
- // ── ConfiguredApp ───────────────────────────────────────────────────
1578
-
1579
- describe("ConfiguredApp", () => {
1580
- const minProps = { name: "api", image: "api:1.0" };
1581
-
1582
- test("returns deployment and service", () => {
1583
- const result = ConfiguredApp(minProps);
1584
- expect(result.deployment).toBeDefined();
1585
- expect(result.service).toBeDefined();
1586
- expect(result.configMap).toBeUndefined();
1587
- });
1588
-
1589
- test("creates ConfigMap when configData provided", () => {
1590
- const result = ConfiguredApp({ ...minProps, configData: { "app.conf": "key=val" }, configMountPath: "/etc/app" });
1591
- expect(result.configMap).toBeDefined();
1592
- expect((p(result.configMap) as any).data["app.conf"]).toBe("key=val");
1593
- });
1594
-
1595
- test("configMap volume mounted", () => {
1596
- const result = ConfiguredApp({ ...minProps, configData: { "k": "v" }, configMountPath: "/etc/app" });
1597
- const spec = p(result.deployment).spec as any;
1598
- const container = spec.template.spec.containers[0];
1599
- expect(container.volumeMounts).toHaveLength(1);
1600
- expect(container.volumeMounts[0].mountPath).toBe("/etc/app");
1601
- expect(spec.template.spec.volumes[0].configMap.name).toBe("api-config");
1602
- });
1603
-
1604
- test("secret volume mounted", () => {
1605
- const result = ConfiguredApp({ ...minProps, secretName: "creds", secretMountPath: "/secrets" });
1606
- const spec = p(result.deployment).spec as any;
1607
- const container = spec.template.spec.containers[0];
1608
- expect(container.volumeMounts[0].mountPath).toBe("/secrets");
1609
- expect(spec.template.spec.volumes[0].secret.secretName).toBe("creds");
1610
- });
1611
-
1612
- test("envFrom with configMapRef and secretRef", () => {
1613
- const result = ConfiguredApp({
1614
- ...minProps,
1615
- envFrom: { configMapRef: "my-config", secretRef: "my-secret" },
1616
- });
1617
- const spec = p(result.deployment).spec as any;
1618
- const container = spec.template.spec.containers[0];
1619
- expect(container.envFrom).toHaveLength(2);
1620
- expect(container.envFrom[0].configMapRef.name).toBe("my-config");
1621
- expect(container.envFrom[1].secretRef.name).toBe("my-secret");
1622
- });
1623
-
1624
- test("initContainers supported", () => {
1625
- const result = ConfiguredApp({
1626
- ...minProps,
1627
- initContainers: [{ name: "init", image: "init:1.0", command: ["sh"] }],
1628
- });
1629
- const spec = p(result.deployment).spec as any;
1630
- expect(spec.template.spec.initContainers).toHaveLength(1);
1631
- });
1632
-
1633
- test("namespace propagated", () => {
1634
- const result = ConfiguredApp({ ...minProps, namespace: "prod" });
1635
- expect((p(result.deployment).metadata as any).namespace).toBe("prod");
1636
- expect((p(result.service).metadata as any).namespace).toBe("prod");
1637
- });
1638
- });
1639
-
1640
- // ── SidecarApp ──────────────────────────────────────────────────────
1641
-
1642
- describe("SidecarApp", () => {
1643
- const minProps = {
1644
- name: "api",
1645
- image: "api:1.0",
1646
- sidecars: [{ name: "envoy", image: "envoy:v1.28" }],
1647
- };
1648
-
1649
- test("returns deployment and service", () => {
1650
- const result = SidecarApp(minProps);
1651
- expect(result.deployment).toBeDefined();
1652
- expect(result.service).toBeDefined();
1653
- });
1654
-
1655
- test("has multiple containers", () => {
1656
- const result = SidecarApp(minProps);
1657
- const spec = p(result.deployment).spec as any;
1658
- expect(spec.template.spec.containers).toHaveLength(2);
1659
- expect(spec.template.spec.containers[0].name).toBe("api");
1660
- expect(spec.template.spec.containers[1].name).toBe("envoy");
1661
- });
1662
-
1663
- test("sidecar ports passed through", () => {
1664
- const result = SidecarApp({
1665
- ...minProps,
1666
- sidecars: [{ name: "envoy", image: "envoy:v1.28", ports: [{ containerPort: 9901, name: "admin" }] }],
1667
- });
1668
- const spec = p(result.deployment).spec as any;
1669
- expect(spec.template.spec.containers[1].ports[0].containerPort).toBe(9901);
1670
- });
1671
-
1672
- test("initContainers supported", () => {
1673
- const result = SidecarApp({
1674
- ...minProps,
1675
- initContainers: [{ name: "migrate", image: "m:1.0", command: ["./migrate.sh"] }],
1676
- });
1677
- const spec = p(result.deployment).spec as any;
1678
- expect(spec.template.spec.initContainers).toHaveLength(1);
1679
- });
1680
-
1681
- test("sharedVolumes creates volumes", () => {
1682
- const result = SidecarApp({
1683
- ...minProps,
1684
- sharedVolumes: [{ name: "tmp" }, { name: "config", configMapName: "my-config" }],
1685
- });
1686
- const spec = p(result.deployment).spec as any;
1687
- expect(spec.template.spec.volumes).toHaveLength(2);
1688
- expect(spec.template.spec.volumes[0].emptyDir).toBeDefined();
1689
- expect(spec.template.spec.volumes[1].configMap.name).toBe("my-config");
1690
- });
1691
-
1692
- test("common labels on all resources", () => {
1693
- const result = SidecarApp(minProps);
1694
- expect((p(result.deployment).metadata as any).labels["app.kubernetes.io/managed-by"]).toBe("chant");
1695
- expect((p(result.service).metadata as any).labels["app.kubernetes.io/managed-by"]).toBe("chant");
1696
- });
1697
- });
1698
-
1699
- // ── MonitoredService ────────────────────────────────────────────────
1700
-
1701
- describe("MonitoredService", () => {
1702
- const minProps = { name: "api", image: "api:1.0" };
1703
-
1704
- test("returns deployment, service, serviceMonitor", () => {
1705
- const result = MonitoredService(minProps);
1706
- expect(result.deployment).toBeDefined();
1707
- expect(result.service).toBeDefined();
1708
- expect(result.serviceMonitor).toBeDefined();
1709
- expect(result.prometheusRule).toBeUndefined();
1710
- });
1711
-
1712
- test("prometheusRule created when alertRules provided", () => {
1713
- const result = MonitoredService({
1714
- ...minProps,
1715
- alertRules: [{ name: "HighError", expr: "rate(errors[5m]) > 0.1", severity: "critical" }],
1716
- });
1717
- expect(result.prometheusRule).toBeDefined();
1718
- const spec = p(result.prometheusRule!).spec as any;
1719
- expect(spec.groups[0].rules[0].alert).toBe("HighError");
1720
- expect(spec.groups[0].rules[0].labels.severity).toBe("critical");
1721
- });
1722
-
1723
- test("serviceMonitor and prometheusRule emit the correct CRD kind (not Deployment)", () => {
1724
- const result = MonitoredService({ ...minProps, alertRules: [{ name: "A", expr: "1" }] });
1725
- expect((result.serviceMonitor as any).entityType).toBe("K8s::Monitoring::ServiceMonitor");
1726
- expect((result.prometheusRule as any).entityType).toBe("K8s::Monitoring::PrometheusRule");
1727
- });
1728
-
1729
- test("serviceMonitor has correct selector and endpoint", () => {
1730
- const result = MonitoredService({ ...minProps, metricsPort: 9090, metricsPath: "/metrics", scrapeInterval: "15s" });
1731
- const spec = p(result.serviceMonitor).spec as any;
1732
- expect(spec.selector.matchLabels["app.kubernetes.io/name"]).toBe("api");
1733
- expect(spec.endpoints[0].port).toBe("metrics");
1734
- expect(spec.endpoints[0].path).toBe("/metrics");
1735
- expect(spec.endpoints[0].interval).toBe("15s");
1736
- });
1737
-
1738
- test("separate metrics port on container and service", () => {
1739
- const result = MonitoredService({ ...minProps, port: 8080, metricsPort: 9090 });
1740
- const spec = p(result.deployment).spec as any;
1741
- const ports = spec.template.spec.containers[0].ports;
1742
- expect(ports).toHaveLength(2);
1743
- expect(ports[0].containerPort).toBe(8080);
1744
- expect(ports[1].containerPort).toBe(9090);
1745
- });
1746
-
1747
- test("component labels", () => {
1748
- const result = MonitoredService({ ...minProps, alertRules: [{ name: "A", expr: "1" }] });
1749
- expect((p(result.serviceMonitor).metadata as any).labels["app.kubernetes.io/component"]).toBe("monitoring");
1750
- expect((p(result.prometheusRule!).metadata as any).labels["app.kubernetes.io/component"]).toBe("monitoring");
1751
- });
1752
- });
1753
-
1754
- // ── NetworkIsolatedApp ──────────────────────────────────────────────
1755
-
1756
- describe("NetworkIsolatedApp", () => {
1757
- const minProps = { name: "api", image: "api:1.0" };
1758
-
1759
- test("returns deployment, service, networkPolicy", () => {
1760
- const result = NetworkIsolatedApp(minProps);
1761
- expect(result.deployment).toBeDefined();
1762
- expect(result.service).toBeDefined();
1763
- expect(result.networkPolicy).toBeDefined();
1764
- });
1765
-
1766
- test("networkPolicy podSelector matches app", () => {
1767
- const result = NetworkIsolatedApp(minProps);
1768
- const spec = p(result.networkPolicy).spec as any;
1769
- expect(spec.podSelector.matchLabels["app.kubernetes.io/name"]).toBe("api");
1770
- });
1771
-
1772
- test("ingress rules created", () => {
1773
- const result = NetworkIsolatedApp({
1774
- ...minProps,
1775
- allowIngressFrom: [{ podSelector: { "app.kubernetes.io/name": "frontend" } }],
1776
- });
1777
- const spec = p(result.networkPolicy).spec as any;
1778
- expect(spec.policyTypes).toContain("Ingress");
1779
- expect(spec.ingress[0].from[0].podSelector.matchLabels["app.kubernetes.io/name"]).toBe("frontend");
1780
- });
1781
-
1782
- test("egress rules with ports", () => {
1783
- const result = NetworkIsolatedApp({
1784
- ...minProps,
1785
- allowEgressTo: [{ podSelector: { "app.kubernetes.io/name": "db" }, ports: [{ port: 5432 }] }],
1786
- });
1787
- const spec = p(result.networkPolicy).spec as any;
1788
- expect(spec.policyTypes).toContain("Egress");
1789
- expect(spec.egress[0].ports[0].port).toBe(5432);
1790
- });
1791
-
1792
- test("namespace propagated", () => {
1793
- const result = NetworkIsolatedApp({ ...minProps, namespace: "prod" });
1794
- expect((p(result.networkPolicy).metadata as any).namespace).toBe("prod");
1795
- });
1796
-
1797
- test("component label on networkPolicy", () => {
1798
- const result = NetworkIsolatedApp(minProps);
1799
- expect((p(result.networkPolicy).metadata as any).labels["app.kubernetes.io/component"]).toBe("network-policy");
1800
- });
1801
- });
1802
-
1803
- // ── IrsaServiceAccount ──────────────────────────────────────────────
1804
-
1805
- describe("IrsaServiceAccount", () => {
1806
- const minProps = { name: "app-sa", iamRoleArn: "arn:aws:iam::123456789012:role/app-role" };
1807
-
1808
- test("returns serviceAccount with IRSA annotation", () => {
1809
- const result = IrsaServiceAccount(minProps);
1810
- expect(result.serviceAccount).toBeDefined();
1811
- const meta = p(result.serviceAccount).metadata as any;
1812
- expect(meta.annotations["eks.amazonaws.com/role-arn"]).toBe("arn:aws:iam::123456789012:role/app-role");
1813
- });
1814
-
1815
- test("no RBAC by default", () => {
1816
- const result = IrsaServiceAccount(minProps);
1817
- expect(result.role).toBeUndefined();
1818
- expect(result.roleBinding).toBeUndefined();
1819
- });
1820
-
1821
- test("RBAC created when rules provided", () => {
1822
- const result = IrsaServiceAccount({
1823
- ...minProps,
1824
- rbacRules: [{ apiGroups: [""], resources: ["secrets"], verbs: ["get"] }],
1825
- });
1826
- expect(result.role).toBeDefined();
1827
- expect(result.roleBinding).toBeDefined();
1828
- const role = p(result.role) as any;
1829
- expect(role.rules[0].resources).toEqual(["secrets"]);
1830
- });
1831
-
1832
- test("namespace propagated", () => {
1833
- const result = IrsaServiceAccount({ ...minProps, namespace: "prod" });
1834
- expect((p(result.serviceAccount).metadata as any).namespace).toBe("prod");
1835
- });
1836
-
1837
- test("component labels", () => {
1838
- const result = IrsaServiceAccount(minProps);
1839
- expect((p(result.serviceAccount).metadata as any).labels["app.kubernetes.io/component"]).toBe("service-account");
1840
- });
1841
- });
1842
-
1843
- // ── AlbIngress ──────────────────────────────────────────────────────
1844
-
1845
- describe("AlbIngress", () => {
1846
- const minProps = {
1847
- name: "api-ingress",
1848
- hosts: [{ hostname: "api.example.com", paths: [{ path: "/", serviceName: "api", servicePort: 80 }] }],
1849
- };
1850
-
1851
- test("returns ingress with ALB annotations", () => {
1852
- const result = AlbIngress(minProps);
1853
- expect(result.ingress).toBeDefined();
1854
- const meta = p(result.ingress).metadata as any;
1855
- expect(meta.annotations["alb.ingress.kubernetes.io/scheme"]).toBe("internet-facing");
1856
- expect(meta.annotations["alb.ingress.kubernetes.io/target-type"]).toBe("ip");
1857
- });
1858
-
1859
- test("ingressClassName is alb", () => {
1860
- const result = AlbIngress(minProps);
1861
- const spec = p(result.ingress).spec as any;
1862
- expect(spec.ingressClassName).toBe("alb");
1863
- });
1864
-
1865
- test("certificate ARN sets TLS annotations", () => {
1866
- const result = AlbIngress({ ...minProps, certificateArn: "arn:aws:acm:us-east-1:123:cert/abc" });
1867
- const meta = p(result.ingress).metadata as any;
1868
- expect(meta.annotations["alb.ingress.kubernetes.io/certificate-arn"]).toBe("arn:aws:acm:us-east-1:123:cert/abc");
1869
- expect(meta.annotations["alb.ingress.kubernetes.io/ssl-redirect"]).toBe("443");
1870
- });
1871
-
1872
- test("groupName annotation set", () => {
1873
- const result = AlbIngress({ ...minProps, groupName: "shared-alb" });
1874
- const meta = p(result.ingress).metadata as any;
1875
- expect(meta.annotations["alb.ingress.kubernetes.io/group.name"]).toBe("shared-alb");
1876
- });
1877
-
1878
- test("WAF ACL annotation set", () => {
1879
- const result = AlbIngress({ ...minProps, wafAclArn: "arn:aws:wafv2:us-east-1:123:regional/webacl/abc" });
1880
- const meta = p(result.ingress).metadata as any;
1881
- expect(meta.annotations["alb.ingress.kubernetes.io/wafv2-acl-arn"]).toBe("arn:aws:wafv2:us-east-1:123:regional/webacl/abc");
1882
- });
1883
-
1884
- test("internal scheme", () => {
1885
- const result = AlbIngress({ ...minProps, scheme: "internal" });
1886
- const meta = p(result.ingress).metadata as any;
1887
- expect(meta.annotations["alb.ingress.kubernetes.io/scheme"]).toBe("internal");
1888
- });
1889
-
1890
- test("empty-string certificateArn does NOT set ssl-redirect", () => {
1891
- const result = AlbIngress({ ...minProps, certificateArn: "" });
1892
- const meta = p(result.ingress).metadata as any;
1893
- expect(meta.annotations["alb.ingress.kubernetes.io/ssl-redirect"]).toBeUndefined();
1894
- expect(meta.annotations["alb.ingress.kubernetes.io/certificate-arn"]).toBeUndefined();
1895
- });
1896
-
1897
- test("explicit sslRedirect: true overrides empty certificateArn", () => {
1898
- const result = AlbIngress({ ...minProps, certificateArn: "", sslRedirect: true });
1899
- const meta = p(result.ingress).metadata as any;
1900
- expect(meta.annotations["alb.ingress.kubernetes.io/ssl-redirect"]).toBe("443");
1901
- });
1902
-
1903
- test("explicit sslRedirect: false suppresses redirect even with cert", () => {
1904
- const result = AlbIngress({ ...minProps, certificateArn: "arn:aws:acm:us-east-1:123:cert/abc", sslRedirect: false });
1905
- const meta = p(result.ingress).metadata as any;
1906
- expect(meta.annotations["alb.ingress.kubernetes.io/ssl-redirect"]).toBeUndefined();
1907
- });
1908
- });
1909
-
1910
- // ── GceIngress ──────────────────────────────────────────────────────
1911
-
1912
- describe("GceIngress", () => {
1913
- const minProps = {
1914
- name: "api-ingress",
1915
- hosts: [{ hostname: "api.example.com", paths: [{ path: "/", serviceName: "api", servicePort: 80 }] }],
1916
- };
1917
-
1918
- test("returns ingress with GCE annotations", () => {
1919
- const result = GceIngress(minProps);
1920
- expect(result.ingress).toBeDefined();
1921
- const meta = p(result.ingress).metadata as any;
1922
- expect(meta.annotations["kubernetes.io/ingress.class"]).toBe("gce");
1923
- });
1924
-
1925
- test("static IP annotation set", () => {
1926
- const result = GceIngress({ ...minProps, staticIpName: "microservice-ip" });
1927
- const meta = p(result.ingress).metadata as any;
1928
- expect(meta.annotations["kubernetes.io/ingress.global-static-ip-name"]).toBe("microservice-ip");
1929
- });
1930
-
1931
- test("managed certificate annotation set", () => {
1932
- const result = GceIngress({ ...minProps, managedCertificate: "api-cert" });
1933
- const meta = p(result.ingress).metadata as any;
1934
- expect(meta.annotations["networking.gke.io/managed-certificates"]).toBe("api-cert");
1935
- });
1936
-
1937
- test("frontendConfig annotation set", () => {
1938
- const result = GceIngress({ ...minProps, frontendConfig: "my-frontend" });
1939
- const meta = p(result.ingress).metadata as any;
1940
- expect(meta.annotations["networking.gke.io/v1beta1.FrontendConfig"]).toBe("my-frontend");
1941
- });
1942
-
1943
- test("managedCertificate sets default FrontendConfig for ssl redirect", () => {
1944
- const result = GceIngress({ ...minProps, managedCertificate: "api-cert" });
1945
- const meta = p(result.ingress).metadata as any;
1946
- expect(meta.annotations["networking.gke.io/v1beta1.FrontendConfig"]).toBe("api-ingress-frontend-config");
1947
- });
1948
-
1949
- test("explicit sslRedirect: false suppresses FrontendConfig even with cert", () => {
1950
- const result = GceIngress({ ...minProps, managedCertificate: "api-cert", sslRedirect: false });
1951
- const meta = p(result.ingress).metadata as any;
1952
- expect(meta.annotations["networking.gke.io/v1beta1.FrontendConfig"]).toBeUndefined();
1953
- });
1954
-
1955
- test("explicit sslRedirect: true sets default FrontendConfig without cert", () => {
1956
- const result = GceIngress({ ...minProps, sslRedirect: true });
1957
- const meta = p(result.ingress).metadata as any;
1958
- expect(meta.annotations["networking.gke.io/v1beta1.FrontendConfig"]).toBe("api-ingress-frontend-config");
1959
- });
1960
-
1961
- test("namespace is set when provided", () => {
1962
- const result = GceIngress({ ...minProps, namespace: "production" });
1963
- const meta = p(result.ingress).metadata as any;
1964
- expect(meta.namespace).toBe("production");
1965
- });
1966
-
1967
- test("host rules are mapped correctly", () => {
1968
- const result = GceIngress(minProps);
1969
- const spec = p(result.ingress).spec as any;
1970
- expect(spec.rules).toHaveLength(1);
1971
- expect(spec.rules[0].host).toBe("api.example.com");
1972
- expect(spec.rules[0].http.paths[0].backend.service.name).toBe("api");
1973
- });
1974
-
1975
- test("labels include component: ingress", () => {
1976
- const result = GceIngress(minProps);
1977
- const meta = p(result.ingress).metadata as any;
1978
- expect(meta.labels["app.kubernetes.io/component"]).toBe("ingress");
1979
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
1980
- });
1981
- });
1982
-
1983
- // ── EbsStorageClass ─────────────────────────────────────────────────
1984
-
1985
- describe("EbsStorageClass", () => {
1986
- test("returns storageClass with EBS provisioner", () => {
1987
- const result = EbsStorageClass({ name: "gp3" });
1988
- expect(result.storageClass).toBeDefined();
1989
- expect((p(result.storageClass) as any).provisioner).toBe("ebs.csi.aws.com");
1990
- });
1991
-
1992
- test("default type is gp3", () => {
1993
- const result = EbsStorageClass({ name: "default" });
1994
- expect((p(result.storageClass) as any).parameters.type).toBe("gp3");
1995
- });
1996
-
1997
- test("encryption enabled by default", () => {
1998
- const result = EbsStorageClass({ name: "enc" });
1999
- expect((p(result.storageClass) as any).parameters.encrypted).toBe("true");
2000
- });
2001
-
2002
- test("custom parameters", () => {
2003
- const result = EbsStorageClass({ name: "custom", type: "io2", iops: "5000", throughput: "250" });
2004
- const params = (p(result.storageClass) as any).parameters;
2005
- expect(params.type).toBe("io2");
2006
- expect(params.iops).toBe("5000");
2007
- expect(params.throughput).toBe("250");
2008
- });
2009
-
2010
- test("allowVolumeExpansion default true", () => {
2011
- const result = EbsStorageClass({ name: "exp" });
2012
- expect((p(result.storageClass) as any).allowVolumeExpansion).toBe(true);
2013
- });
2014
-
2015
- test("storageClass is cluster-scoped (no namespace)", () => {
2016
- const result = EbsStorageClass({ name: "sc" });
2017
- expect((p(result.storageClass).metadata as any).namespace).toBeUndefined();
2018
- });
2019
-
2020
- test("numeric iops and throughput coerced to strings", () => {
2021
- const result = EbsStorageClass({ name: "perf", iops: 5000, throughput: 250 });
2022
- const params = (p(result.storageClass) as any).parameters;
2023
- expect(params.iops).toBe("5000");
2024
- expect(params.throughput).toBe("250");
2025
- });
2026
-
2027
- test("string iops and throughput passed through", () => {
2028
- const result = EbsStorageClass({ name: "perf", iops: "3000", throughput: "125" });
2029
- const params = (p(result.storageClass) as any).parameters;
2030
- expect(params.iops).toBe("3000");
2031
- expect(params.throughput).toBe("125");
2032
- });
2033
- });
2034
-
2035
- // ── EfsStorageClass ─────────────────────────────────────────────────
2036
-
2037
- describe("EfsStorageClass", () => {
2038
- test("returns storageClass with EFS provisioner", () => {
2039
- const result = EfsStorageClass({ name: "efs", fileSystemId: "fs-123" });
2040
- expect((p(result.storageClass) as any).provisioner).toBe("efs.csi.aws.com");
2041
- });
2042
-
2043
- test("fileSystemId in parameters", () => {
2044
- const result = EfsStorageClass({ name: "efs", fileSystemId: "fs-abc" });
2045
- expect((p(result.storageClass) as any).parameters.fileSystemId).toBe("fs-abc");
2046
- });
2047
-
2048
- test("default provisioningMode is efs-ap", () => {
2049
- const result = EfsStorageClass({ name: "efs", fileSystemId: "fs-123" });
2050
- expect((p(result.storageClass) as any).parameters.provisioningMode).toBe("efs-ap");
2051
- });
2052
- });
2053
-
2054
- // ── FluentBitAgent ──────────────────────────────────────────────────
2055
-
2056
- describe("FluentBitAgent", () => {
2057
- const minProps = { logGroup: "/aws/eks/cluster/containers", region: "us-east-1", clusterName: "cluster" };
2058
-
2059
- test("returns all 5 resources", () => {
2060
- const result = FluentBitAgent(minProps);
2061
- expect(result.daemonSet).toBeDefined();
2062
- expect(result.serviceAccount).toBeDefined();
2063
- expect(result.clusterRole).toBeDefined();
2064
- expect(result.clusterRoleBinding).toBeDefined();
2065
- expect(result.configMap).toBeDefined();
2066
- });
2067
-
2068
- test("default namespace is amazon-cloudwatch", () => {
2069
- const result = FluentBitAgent(minProps);
2070
- expect((p(result.daemonSet).metadata as any).namespace).toBe("amazon-cloudwatch");
2071
- });
2072
-
2073
- test("configMap contains fluent-bit config with region", () => {
2074
- const result = FluentBitAgent(minProps);
2075
- const data = (p(result.configMap) as any).data;
2076
- expect(data["fluent-bit.conf"]).toContain("us-east-1");
2077
- expect(data["fluent-bit.conf"]).toContain("/aws/eks/cluster/containers");
2078
- });
2079
-
2080
- test("tolerations for all nodes", () => {
2081
- const result = FluentBitAgent(minProps);
2082
- const spec = p(result.daemonSet).spec as any;
2083
- expect(spec.template.spec.tolerations).toEqual([{ operator: "Exists" }]);
2084
- });
2085
-
2086
- test("clusterRole is cluster-scoped", () => {
2087
- const result = FluentBitAgent(minProps);
2088
- expect((p(result.clusterRole).metadata as any).namespace).toBeUndefined();
2089
- });
2090
-
2091
- test("IRSA annotation when iamRoleArn set", () => {
2092
- const result = FluentBitAgent({ ...minProps, iamRoleArn: "arn:aws:iam::123456789012:role/fb-role" });
2093
- const meta = p(result.serviceAccount).metadata as any;
2094
- expect(meta.annotations["eks.amazonaws.com/role-arn"]).toBe("arn:aws:iam::123456789012:role/fb-role");
2095
- });
2096
-
2097
- test("no annotation when iamRoleArn omitted", () => {
2098
- const result = FluentBitAgent(minProps);
2099
- const meta = p(result.serviceAccount).metadata as any;
2100
- expect(meta.annotations).toBeUndefined();
2101
- });
2102
- });
2103
-
2104
- // ── ExternalDnsAgent ────────────────────────────────────────────────
2105
-
2106
- describe("ExternalDnsAgent", () => {
2107
- const minProps = {
2108
- iamRoleArn: "arn:aws:iam::123456789012:role/external-dns",
2109
- domainFilters: ["example.com"],
2110
- };
2111
-
2112
- test("returns deployment, serviceAccount, clusterRole, clusterRoleBinding", () => {
2113
- const result = ExternalDnsAgent(minProps);
2114
- expect(result.deployment).toBeDefined();
2115
- expect(result.serviceAccount).toBeDefined();
2116
- expect(result.clusterRole).toBeDefined();
2117
- expect(result.clusterRoleBinding).toBeDefined();
2118
- });
2119
-
2120
- test("IRSA annotation on serviceAccount", () => {
2121
- const result = ExternalDnsAgent(minProps);
2122
- const meta = p(result.serviceAccount).metadata as any;
2123
- expect(meta.annotations["eks.amazonaws.com/role-arn"]).toBe("arn:aws:iam::123456789012:role/external-dns");
2124
- });
2125
-
2126
- test("domain filter in args", () => {
2127
- const result = ExternalDnsAgent(minProps);
2128
- const spec = p(result.deployment).spec as any;
2129
- const args = spec.template.spec.containers[0].args;
2130
- expect(args).toContain("--domain-filter=example.com");
2131
- });
2132
-
2133
- test("txtOwnerId in args when set", () => {
2134
- const result = ExternalDnsAgent({ ...minProps, txtOwnerId: "my-cluster" });
2135
- const spec = p(result.deployment).spec as any;
2136
- const args = spec.template.spec.containers[0].args;
2137
- expect(args).toContain("--txt-owner-id=my-cluster");
2138
- });
2139
-
2140
- test("default namespace is kube-system", () => {
2141
- const result = ExternalDnsAgent(minProps);
2142
- expect((p(result.deployment).metadata as any).namespace).toBe("kube-system");
2143
- });
2144
-
2145
- test("replicas is 1", () => {
2146
- const result = ExternalDnsAgent(minProps);
2147
- const spec = p(result.deployment).spec as any;
2148
- expect(spec.replicas).toBe(1);
2149
- });
2150
- });
2151
-
2152
- // ── AdotCollector ───────────────────────────────────────────────────
2153
-
2154
- describe("AdotCollector", () => {
2155
- const minProps = { region: "us-east-1", clusterName: "cluster" };
2156
-
2157
- test("returns all 5 resources", () => {
2158
- const result = AdotCollector(minProps);
2159
- expect(result.daemonSet).toBeDefined();
2160
- expect(result.serviceAccount).toBeDefined();
2161
- expect(result.clusterRole).toBeDefined();
2162
- expect(result.clusterRoleBinding).toBeDefined();
2163
- expect(result.configMap).toBeDefined();
2164
- });
2165
-
2166
- test("default namespace is amazon-metrics", () => {
2167
- const result = AdotCollector(minProps);
2168
- expect((p(result.daemonSet).metadata as any).namespace).toBe("amazon-metrics");
2169
- });
2170
-
2171
- test("configMap contains ADOT config with region", () => {
2172
- const result = AdotCollector(minProps);
2173
- const data = (p(result.configMap) as any).data;
2174
- expect(data["config.yaml"]).toContain("us-east-1");
2175
- expect(data["config.yaml"]).toContain("cluster");
2176
- });
2177
-
2178
- test("OTLP ports on container", () => {
2179
- const result = AdotCollector(minProps);
2180
- const spec = p(result.daemonSet).spec as any;
2181
- const ports = spec.template.spec.containers[0].ports;
2182
- expect(ports).toHaveLength(2);
2183
- expect(ports[0].containerPort).toBe(4317);
2184
- expect(ports[1].containerPort).toBe(4318);
2185
- });
2186
-
2187
- test("tolerations for all nodes", () => {
2188
- const result = AdotCollector(minProps);
2189
- const spec = p(result.daemonSet).spec as any;
2190
- expect(spec.template.spec.tolerations).toEqual([{ operator: "Exists" }]);
2191
- });
2192
-
2193
- test("custom exporters", () => {
2194
- const result = AdotCollector({ ...minProps, exporters: ["prometheus"] });
2195
- const data = (p(result.configMap) as any).data;
2196
- expect(data["config.yaml"]).toContain("prometheusremotewrite");
2197
- });
2198
-
2199
- test("IRSA annotation when iamRoleArn set", () => {
2200
- const result = AdotCollector({ ...minProps, iamRoleArn: "arn:aws:iam::123456789012:role/adot-role" });
2201
- const meta = p(result.serviceAccount).metadata as any;
2202
- expect(meta.annotations["eks.amazonaws.com/role-arn"]).toBe("arn:aws:iam::123456789012:role/adot-role");
2203
- });
2204
-
2205
- test("no annotation when iamRoleArn omitted", () => {
2206
- const result = AdotCollector(minProps);
2207
- const meta = p(result.serviceAccount).metadata as any;
2208
- expect(meta.annotations).toBeUndefined();
2209
- });
2210
- });
2211
-
2212
- // ── MetricsServer ──────────────────────────────────────────────────
2213
-
2214
- describe("MetricsServer", () => {
2215
- test("returns all 8 resources", () => {
2216
- const result = MetricsServer({});
2217
- expect(result.deployment).toBeDefined();
2218
- expect(result.service).toBeDefined();
2219
- expect(result.serviceAccount).toBeDefined();
2220
- expect(result.clusterRole).toBeDefined();
2221
- expect(result.clusterRoleBinding).toBeDefined();
2222
- expect(result.aggregatedClusterRole).toBeDefined();
2223
- expect(result.authDelegatorBinding).toBeDefined();
2224
- expect(result.apiService).toBeDefined();
2225
- });
2226
-
2227
- test("default namespace is kube-system", () => {
2228
- const result = MetricsServer({});
2229
- expect((p(result.deployment).metadata as any).namespace).toBe("kube-system");
2230
- expect((p(result.service).metadata as any).namespace).toBe("kube-system");
2231
- expect((p(result.serviceAccount).metadata as any).namespace).toBe("kube-system");
2232
- });
2233
-
2234
- test("service targets port 10250", () => {
2235
- const result = MetricsServer({});
2236
- const spec = p(result.service).spec as any;
2237
- expect(spec.ports[0].port).toBe(443);
2238
- expect(spec.ports[0].targetPort).toBe(10250);
2239
- });
2240
-
2241
- test("deployment container has correct image and args", () => {
2242
- const result = MetricsServer({});
2243
- const spec = p(result.deployment).spec as any;
2244
- const container = spec.template.spec.containers[0];
2245
- expect(container.image).toBe("registry.k8s.io/metrics-server/metrics-server:v0.7.2");
2246
- expect(container.args).toContain("--secure-port=10250");
2247
- expect(container.args).toContain("--kubelet-use-node-status-port");
2248
- expect(container.args).toContain("--metric-resolution=15s");
2249
- });
2250
-
2251
- test("clusterRole has nodes/metrics access", () => {
2252
- const result = MetricsServer({});
2253
- const rules = p(result.clusterRole).rules as any[];
2254
- const nodeMetricsRule = rules.find((r: any) => r.resources?.includes("nodes/metrics"));
2255
- expect(nodeMetricsRule).toBeDefined();
2256
- });
2257
-
2258
- test("apiService references correct service", () => {
2259
- const result = MetricsServer({});
2260
- const spec = (p(result.apiService) as any).spec;
2261
- expect(spec.service.name).toBe("metrics-server");
2262
- expect(spec.service.namespace).toBe("kube-system");
2263
- expect(spec.group).toBe("metrics.k8s.io");
2264
- expect(spec.version).toBe("v1beta1");
2265
- });
2266
-
2267
- test("aggregated clusterRole has aggregate labels", () => {
2268
- const result = MetricsServer({});
2269
- const labels = (p(result.aggregatedClusterRole).metadata as any).labels;
2270
- expect(labels["rbac.authorization.k8s.io/aggregate-to-admin"]).toBe("true");
2271
- expect(labels["rbac.authorization.k8s.io/aggregate-to-view"]).toBe("true");
2272
- });
2273
-
2274
- test("custom image and replicas", () => {
2275
- const result = MetricsServer({ image: "custom:v1", replicas: 2 });
2276
- const spec = p(result.deployment).spec as any;
2277
- expect(spec.replicas).toBe(2);
2278
- expect(spec.template.spec.containers[0].image).toBe("custom:v1");
2279
- });
2280
- });
2281
-
2282
- // ── PSS restricted securityContext passthrough tests ─────────────
2283
-
2284
- const pssSecurityContext = {
2285
- runAsNonRoot: true,
2286
- readOnlyRootFilesystem: true,
2287
- allowPrivilegeEscalation: false,
2288
- capabilities: { drop: ["ALL"] },
2289
- seccompProfile: { type: "RuntimeDefault" },
2290
- };
2291
-
2292
- describe("BatchJob securityContext", () => {
2293
- test("securityContext passed through to container", () => {
2294
- const result = BatchJob({
2295
- name: "migrate",
2296
- image: "migrate:1.0",
2297
- securityContext: pssSecurityContext,
2298
- });
2299
- const spec = p(result.job).spec as any;
2300
- const sc = spec.template.spec.containers[0].securityContext;
2301
- expect(sc.runAsNonRoot).toBe(true);
2302
- expect(sc.allowPrivilegeEscalation).toBe(false);
2303
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2304
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2305
- });
2306
- });
2307
-
2308
- describe("CronWorkload securityContext", () => {
2309
- test("securityContext passed through to container", () => {
2310
- const result = CronWorkload({
2311
- name: "backup",
2312
- image: "backup:1.0",
2313
- schedule: "0 2 * * *",
2314
- securityContext: pssSecurityContext,
2315
- });
2316
- const spec = p(result.cronJob).spec as any;
2317
- const sc = spec.jobTemplate.spec.template.spec.containers[0].securityContext;
2318
- expect(sc.runAsNonRoot).toBe(true);
2319
- expect(sc.allowPrivilegeEscalation).toBe(false);
2320
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2321
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2322
- });
2323
- });
2324
-
2325
- describe("NodeAgent securityContext", () => {
2326
- test("securityContext passed through to container", () => {
2327
- const result = NodeAgent({
2328
- name: "agent",
2329
- image: "agent:1.0",
2330
- rbacRules: [{ apiGroups: [""], resources: ["pods"], verbs: ["get"] }],
2331
- securityContext: pssSecurityContext,
2332
- });
2333
- const spec = p(result.daemonSet).spec as any;
2334
- const sc = spec.template.spec.containers[0].securityContext;
2335
- expect(sc.runAsNonRoot).toBe(true);
2336
- expect(sc.allowPrivilegeEscalation).toBe(false);
2337
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2338
- });
2339
- });
2340
-
2341
- describe("ConfiguredApp securityContext", () => {
2342
- test("securityContext passed through to container", () => {
2343
- const result = ConfiguredApp({
2344
- name: "api",
2345
- image: "api:1.0",
2346
- securityContext: pssSecurityContext,
2347
- });
2348
- const spec = p(result.deployment).spec as any;
2349
- const sc = spec.template.spec.containers[0].securityContext;
2350
- expect(sc.runAsNonRoot).toBe(true);
2351
- expect(sc.allowPrivilegeEscalation).toBe(false);
2352
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2353
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2354
- });
2355
- });
2356
-
2357
- describe("SidecarApp securityContext", () => {
2358
- test("securityContext passed through to primary container", () => {
2359
- const result = SidecarApp({
2360
- name: "api",
2361
- image: "api:1.0",
2362
- sidecars: [{ name: "envoy", image: "envoy:1.0" }],
2363
- securityContext: pssSecurityContext,
2364
- });
2365
- const spec = p(result.deployment).spec as any;
2366
- const sc = spec.template.spec.containers[0].securityContext;
2367
- expect(sc.runAsNonRoot).toBe(true);
2368
- expect(sc.allowPrivilegeEscalation).toBe(false);
2369
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2370
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2371
- });
2372
- });
2373
-
2374
- describe("NetworkIsolatedApp securityContext", () => {
2375
- test("securityContext passed through to container", () => {
2376
- const result = NetworkIsolatedApp({
2377
- name: "api",
2378
- image: "api:1.0",
2379
- securityContext: pssSecurityContext,
2380
- });
2381
- const spec = p(result.deployment).spec as any;
2382
- const sc = spec.template.spec.containers[0].securityContext;
2383
- expect(sc.runAsNonRoot).toBe(true);
2384
- expect(sc.allowPrivilegeEscalation).toBe(false);
2385
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2386
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2387
- });
2388
- });
2389
-
2390
- describe("MonitoredService securityContext", () => {
2391
- test("securityContext passed through to container", () => {
2392
- const result = MonitoredService({
2393
- name: "api",
2394
- image: "api:1.0",
2395
- securityContext: pssSecurityContext,
2396
- });
2397
- const spec = p(result.deployment).spec as any;
2398
- const sc = spec.template.spec.containers[0].securityContext;
2399
- expect(sc.runAsNonRoot).toBe(true);
2400
- expect(sc.allowPrivilegeEscalation).toBe(false);
2401
- expect(sc.capabilities).toEqual({ drop: ["ALL"] });
2402
- expect(sc.seccompProfile).toEqual({ type: "RuntimeDefault" });
2403
- });
2404
- });
2405
-
2406
- // ── Infrastructure composites: hardcoded security defaults ──────
2407
-
2408
- describe("ExternalDnsAgent security defaults", () => {
2409
- test("container has hardcoded PSS-safe securityContext", () => {
2410
- const result = ExternalDnsAgent({
2411
- iamRoleArn: "arn:aws:iam::123456789012:role/test",
2412
- domainFilters: ["example.com"],
2413
- });
2414
- const spec = p(result.deployment).spec as any;
2415
- const sc = spec.template.spec.containers[0].securityContext;
2416
- expect(sc.runAsNonRoot).toBe(true);
2417
- expect(sc.readOnlyRootFilesystem).toBe(true);
2418
- expect(sc.allowPrivilegeEscalation).toBe(false);
2419
- });
2420
- });
2421
-
2422
- describe("FluentBitAgent security defaults", () => {
2423
- test("container runs as root (needs host log access) with other PSS hardening", () => {
2424
- const result = FluentBitAgent({
2425
- logGroup: "/aws/eks/test/containers",
2426
- region: "us-east-1",
2427
- clusterName: "test",
2428
- });
2429
- const spec = p(result.daemonSet).spec as any;
2430
- const sc = spec.template.spec.containers[0].securityContext;
2431
- expect(sc.runAsUser).toBe(0);
2432
- expect(sc.runAsNonRoot).toBeUndefined();
2433
- expect(sc.readOnlyRootFilesystem).toBe(true);
2434
- expect(sc.allowPrivilegeEscalation).toBe(false);
2435
- });
2436
- });
2437
-
2438
- describe("AdotCollector security defaults", () => {
2439
- test("container runs as non-root with explicit UID (ADOT 'aoc' user)", () => {
2440
- const result = AdotCollector({
2441
- region: "us-east-1",
2442
- clusterName: "test",
2443
- });
2444
- const spec = p(result.daemonSet).spec as any;
2445
- const sc = spec.template.spec.containers[0].securityContext;
2446
- expect(sc.runAsNonRoot).toBe(true);
2447
- expect(sc.runAsUser).toBe(10001);
2448
- expect(sc.readOnlyRootFilesystem).toBe(true);
2449
- expect(sc.allowPrivilegeEscalation).toBe(false);
2450
- });
2451
- });
2452
-
2453
- // ── Phase 3B: Composite serialization smoke tests ───────────────
2454
-
2455
- describe("Composite YAML serialization smoke tests", () => {
2456
- function serializeCompositeProps(composite: Record<string, unknown>): string {
2457
- return Object.values(composite)
2458
- .filter((v) => v != null && typeof v === "object" && p(v as any) != null)
2459
- .map((v) => emitYAML(p(v as any), 0))
2460
- .join("\n---\n");
2461
- }
2462
-
2463
- test("ExternalDnsAgent serializes to valid YAML", () => {
2464
- const result = ExternalDnsAgent({
2465
- iamRoleArn: "arn:aws:iam::123456789012:role/test",
2466
- domainFilters: ["example.com"],
2467
- });
2468
- const yaml = serializeCompositeProps(result as any);
2469
- expect(yaml).toContain("external-dns");
2470
- expect(yaml).not.toContain("[object Object]");
2471
- });
2472
-
2473
- test("FluentBitAgent serializes multiline config correctly", () => {
2474
- const result = FluentBitAgent({
2475
- logGroup: "/aws/eks/test/containers",
2476
- region: "us-east-1",
2477
- clusterName: "test",
2478
- });
2479
- const yaml = serializeCompositeProps(result as any);
2480
- // Multiline config should use | block scalar, not flatten
2481
- expect(yaml).toContain("|");
2482
- expect(yaml).toContain("[SERVICE]");
2483
- expect(yaml).toContain("[INPUT]");
2484
- expect(yaml).not.toContain("\\n");
2485
- });
2486
-
2487
- test("AdotCollector serializes multiline config correctly", () => {
2488
- const result = AdotCollector({
2489
- region: "us-east-1",
2490
- clusterName: "test",
2491
- });
2492
- const yaml = serializeCompositeProps(result as any);
2493
- expect(yaml).toContain("|");
2494
- expect(yaml).toContain("receivers:");
2495
- expect(yaml).toContain("exporters:");
2496
- expect(yaml).not.toContain("\\n");
2497
- });
2498
-
2499
- test("MetricsServer serializes to valid YAML", () => {
2500
- const result = MetricsServer({});
2501
- const yaml = serializeCompositeProps(result as any);
2502
- expect(yaml).toContain("metrics-server");
2503
- expect(yaml).not.toContain("[object Object]");
2504
- });
2505
- });
2506
-
2507
- // ── Phase 4A: MetricsServer RBAC completeness ──────────────────
2508
-
2509
- describe("MetricsServer RBAC completeness", () => {
2510
- test("clusterRole includes configmaps resource", () => {
2511
- const result = MetricsServer({});
2512
- const rules = p(result.clusterRole).rules as any[];
2513
- const hasConfigmaps = rules.some((r: any) => r.resources?.includes("configmaps"));
2514
- expect(hasConfigmaps).toBe(true);
2515
- });
2516
- });
2517
-
2518
- // ── Phase 4B: AdotCollector command vs args ─────────────────────
2519
-
2520
- describe("AdotCollector command vs args", () => {
2521
- test("container uses args (not command) for config flag", () => {
2522
- const result = AdotCollector({
2523
- region: "us-east-1",
2524
- clusterName: "test",
2525
- });
2526
- const spec = p(result.daemonSet).spec as any;
2527
- const container = spec.template.spec.containers[0];
2528
- // Config flag should be in args, not command
2529
- expect(container.args).toContain("--config=/etc/adot/config.yaml");
2530
- expect(container.command).toBeUndefined();
2531
- });
2532
- });
2533
-
2534
- // ── Phase 4C: AdotCollector pipeline exporter separation ────────
2535
-
2536
- describe("AdotCollector pipeline exporter separation", () => {
2537
- test("metrics pipeline does NOT include awsxray", () => {
2538
- const result = AdotCollector({
2539
- region: "us-east-1",
2540
- clusterName: "test",
2541
- exporters: ["cloudwatch", "xray"],
2542
- });
2543
- const config = (p(result.configMap) as any).data["config.yaml"] as string;
2544
- // Extract metrics pipeline exporters line
2545
- const metricsMatch = config.match(/metrics:\s*\n\s*receivers:.*\n\s*processors:.*\n\s*exporters:\s*\[([^\]]+)\]/);
2546
- expect(metricsMatch).toBeDefined();
2547
- const metricsExporters = metricsMatch![1];
2548
- expect(metricsExporters).not.toContain("awsxray");
2549
- expect(metricsExporters).toContain("awsemf");
2550
- });
2551
-
2552
- test("traces pipeline does NOT include awsemf", () => {
2553
- const result = AdotCollector({
2554
- region: "us-east-1",
2555
- clusterName: "test",
2556
- exporters: ["cloudwatch", "xray"],
2557
- });
2558
- const config = (p(result.configMap) as any).data["config.yaml"] as string;
2559
- // Extract traces pipeline exporters line
2560
- const tracesMatch = config.match(/traces:\s*\n\s*receivers:.*\n\s*processors:.*\n\s*exporters:\s*\[([^\]]+)\]/);
2561
- expect(tracesMatch).toBeDefined();
2562
- const tracesExporters = tracesMatch![1];
2563
- expect(tracesExporters).not.toContain("awsemf");
2564
- expect(tracesExporters).toContain("awsxray");
2565
- });
2566
-
2567
- test("cloudwatch-only: traces pipeline falls back to valid default", () => {
2568
- const result = AdotCollector({
2569
- region: "us-east-1",
2570
- clusterName: "test",
2571
- exporters: ["cloudwatch"],
2572
- });
2573
- const config = (p(result.configMap) as any).data["config.yaml"] as string;
2574
- // Traces pipeline should still have an exporter (fallback to awsxray)
2575
- const tracesMatch = config.match(/traces:\s*\n\s*receivers:.*\n\s*processors:.*\n\s*exporters:\s*\[([^\]]+)\]/);
2576
- expect(tracesMatch).toBeDefined();
2577
- const tracesExporters = tracesMatch![1].trim();
2578
- expect(tracesExporters.length).toBeGreaterThan(0);
2579
- });
2580
- });
2581
-
2582
- // ── Phase 4D: AdotCollector config parseable as YAML ────────────
2583
-
2584
- describe("AdotCollector config structure", () => {
2585
- test("generated config has required top-level sections", () => {
2586
- const result = AdotCollector({
2587
- region: "us-east-1",
2588
- clusterName: "test",
2589
- });
2590
- const config = (p(result.configMap) as any).data["config.yaml"] as string;
2591
- expect(config).toContain("receivers:");
2592
- expect(config).toContain("exporters:");
2593
- expect(config).toContain("processors:");
2594
- expect(config).toContain("service:");
2595
- expect(config).toContain("pipelines:");
2596
- expect(config).toContain("metrics:");
2597
- expect(config).toContain("traces:");
2598
- });
2599
- });
2600
-
2601
- // ── WorkloadIdentityServiceAccount ──────────────────────────────────
2602
-
2603
- describe("WorkloadIdentityServiceAccount", () => {
2604
- const minProps = { name: "app-sa", gcpServiceAccountEmail: "sa@my-project.iam.gserviceaccount.com" };
2605
-
2606
- test("returns serviceAccount with Workload Identity annotation", () => {
2607
- const result = WorkloadIdentityServiceAccount(minProps);
2608
- expect(result.serviceAccount).toBeDefined();
2609
- const meta = p(result.serviceAccount).metadata as any;
2610
- expect(meta.annotations["iam.gke.io/gcp-service-account"]).toBe("sa@my-project.iam.gserviceaccount.com");
2611
- });
2612
-
2613
- test("no RBAC by default", () => {
2614
- const result = WorkloadIdentityServiceAccount(minProps);
2615
- expect(result.role).toBeUndefined();
2616
- expect(result.roleBinding).toBeUndefined();
2617
- });
2618
-
2619
- test("RBAC created when rules provided", () => {
2620
- const result = WorkloadIdentityServiceAccount({
2621
- ...minProps,
2622
- rbacRules: [{ apiGroups: [""], resources: ["secrets"], verbs: ["get"] }],
2623
- });
2624
- expect(result.role).toBeDefined();
2625
- expect(result.roleBinding).toBeDefined();
2626
- const role = p(result.role) as any;
2627
- expect(role.rules[0].resources).toEqual(["secrets"]);
2628
- });
2629
-
2630
- test("namespace propagated", () => {
2631
- const result = WorkloadIdentityServiceAccount({ ...minProps, namespace: "prod" });
2632
- expect((p(result.serviceAccount).metadata as any).namespace).toBe("prod");
2633
- });
2634
-
2635
- test("component labels", () => {
2636
- const result = WorkloadIdentityServiceAccount(minProps);
2637
- expect((p(result.serviceAccount).metadata as any).labels["app.kubernetes.io/component"]).toBe("service-account");
2638
- });
2639
- });
2640
-
2641
- // ── GcePdStorageClass ───────────────────────────────────────────────
2642
-
2643
- describe("GcePdStorageClass", () => {
2644
- test("returns storageClass with GCE PD provisioner", () => {
2645
- const result = GcePdStorageClass({ name: "pd-balanced" });
2646
- expect(result.storageClass).toBeDefined();
2647
- expect((p(result.storageClass) as any).provisioner).toBe("pd.csi.storage.gke.io");
2648
- });
2649
-
2650
- test("default type is pd-balanced", () => {
2651
- const result = GcePdStorageClass({ name: "default" });
2652
- expect((p(result.storageClass) as any).parameters.type).toBe("pd-balanced");
2653
- });
2654
-
2655
- test("custom type", () => {
2656
- const result = GcePdStorageClass({ name: "ssd", type: "pd-ssd" });
2657
- expect((p(result.storageClass) as any).parameters.type).toBe("pd-ssd");
2658
- });
2659
-
2660
- test("regional-pd replication type", () => {
2661
- const result = GcePdStorageClass({ name: "regional", replicationType: "regional-pd" });
2662
- expect((p(result.storageClass) as any).parameters["replication-type"]).toBe("regional-pd");
2663
- });
2664
-
2665
- test("no replication-type param when none", () => {
2666
- const result = GcePdStorageClass({ name: "default" });
2667
- expect((p(result.storageClass) as any).parameters["replication-type"]).toBeUndefined();
2668
- });
2669
-
2670
- test("allowVolumeExpansion default true", () => {
2671
- const result = GcePdStorageClass({ name: "exp" });
2672
- expect((p(result.storageClass) as any).allowVolumeExpansion).toBe(true);
2673
- });
2674
-
2675
- test("storageClass is cluster-scoped (no namespace)", () => {
2676
- const result = GcePdStorageClass({ name: "sc" });
2677
- expect((p(result.storageClass).metadata as any).namespace).toBeUndefined();
2678
- });
2679
- });
2680
-
2681
- // ── FilestoreStorageClass ───────────────────────────────────────────
2682
-
2683
- describe("FilestoreStorageClass", () => {
2684
- test("returns storageClass with Filestore provisioner", () => {
2685
- const result = FilestoreStorageClass({ name: "filestore" });
2686
- expect((p(result.storageClass) as any).provisioner).toBe("filestore.csi.storage.gke.io");
2687
- });
2688
-
2689
- test("default tier is standard", () => {
2690
- const result = FilestoreStorageClass({ name: "fs" });
2691
- expect((p(result.storageClass) as any).parameters.tier).toBe("standard");
2692
- });
2693
-
2694
- test("custom tier", () => {
2695
- const result = FilestoreStorageClass({ name: "premium-fs", tier: "premium" });
2696
- expect((p(result.storageClass) as any).parameters.tier).toBe("premium");
2697
- });
2698
-
2699
- test("network parameter set when provided", () => {
2700
- const result = FilestoreStorageClass({ name: "fs", network: "my-vpc" });
2701
- expect((p(result.storageClass) as any).parameters.network).toBe("my-vpc");
2702
- });
2703
-
2704
- test("no network parameter by default", () => {
2705
- const result = FilestoreStorageClass({ name: "fs" });
2706
- expect((p(result.storageClass) as any).parameters.network).toBeUndefined();
2707
- });
2708
- });
2709
-
2710
- // ── GkeGateway ──────────────────────────────────────────────────────
2711
-
2712
- describe("GkeGateway", () => {
2713
- const minProps = {
2714
- name: "api-gateway",
2715
- hosts: [{ hostname: "api.example.com", paths: [{ path: "/", serviceName: "api", servicePort: 80 }] }],
2716
- };
2717
-
2718
- test("returns gateway and httpRoute", () => {
2719
- const result = GkeGateway(minProps);
2720
- expect(result.gateway).toBeDefined();
2721
- expect(result.httpRoute).toBeDefined();
2722
- });
2723
-
2724
- test("default gatewayClassName", () => {
2725
- const result = GkeGateway(minProps);
2726
- const spec = p(result.gateway).spec as any;
2727
- expect(spec.gatewayClassName).toBe("gke-l7-global-external-managed");
2728
- });
2729
-
2730
- test("custom gatewayClassName", () => {
2731
- const result = GkeGateway({ ...minProps, gatewayClassName: "gke-l7-rilb" });
2732
- const spec = p(result.gateway).spec as any;
2733
- expect(spec.gatewayClassName).toBe("gke-l7-rilb");
2734
- });
2735
-
2736
- test("HTTP listener when no certificate", () => {
2737
- const result = GkeGateway(minProps);
2738
- const spec = p(result.gateway).spec as any;
2739
- expect(spec.listeners[0].protocol).toBe("HTTP");
2740
- expect(spec.listeners[0].port).toBe(80);
2741
- });
2742
-
2743
- test("HTTPS listener with certificate", () => {
2744
- const result = GkeGateway({ ...minProps, certificateName: "api-cert" });
2745
- const spec = p(result.gateway).spec as any;
2746
- expect(spec.listeners[0].protocol).toBe("HTTPS");
2747
- expect(spec.listeners[0].port).toBe(443);
2748
- expect(spec.listeners[0].tls.certificateRefs[0].name).toBe("api-cert");
2749
- });
2750
-
2751
- test("httpRoute references parent gateway", () => {
2752
- const result = GkeGateway(minProps);
2753
- const spec = p(result.httpRoute).spec as any;
2754
- expect(spec.parentRefs[0].name).toBe("api-gateway");
2755
- });
2756
-
2757
- test("httpRoute has hostnames", () => {
2758
- const result = GkeGateway(minProps);
2759
- const spec = p(result.httpRoute).spec as any;
2760
- expect(spec.hostnames).toEqual(["api.example.com"]);
2761
- });
2762
-
2763
- test("httpRoute rules map to backend services", () => {
2764
- const result = GkeGateway(minProps);
2765
- const spec = p(result.httpRoute).spec as any;
2766
- expect(spec.rules[0].backendRefs[0].name).toBe("api");
2767
- expect(spec.rules[0].backendRefs[0].port).toBe(80);
2768
- });
2769
-
2770
- test("namespace propagated to both resources", () => {
2771
- const result = GkeGateway({ ...minProps, namespace: "prod" });
2772
- expect((p(result.gateway).metadata as any).namespace).toBe("prod");
2773
- expect((p(result.httpRoute).metadata as any).namespace).toBe("prod");
2774
- });
2775
- });
2776
-
2777
- // ── ConfigConnectorContext ───────────────────────────────────────────
2778
-
2779
- describe("ConfigConnectorContext", () => {
2780
- const minProps = { googleServiceAccountEmail: "cnrm@my-project.iam.gserviceaccount.com" };
2781
-
2782
- test("returns context with apiVersion and kind", () => {
2783
- const result = ConfigConnectorContext(minProps);
2784
- expect(result.context).toBeDefined();
2785
- expect((p(result.context) as any).apiVersion).toBe("core.cnrm.cloud.google.com/v1beta1");
2786
- expect((p(result.context) as any).kind).toBe("ConfigConnectorContext");
2787
- });
2788
-
2789
- test("googleServiceAccount in spec", () => {
2790
- const result = ConfigConnectorContext(minProps);
2791
- const spec = (p(result.context) as any).spec;
2792
- expect(spec.googleServiceAccount).toBe("cnrm@my-project.iam.gserviceaccount.com");
2793
- });
2794
-
2795
- test("default stateIntoSpec is Absent", () => {
2796
- const result = ConfigConnectorContext(minProps);
2797
- expect((p(result.context) as any).spec.stateIntoSpec).toBe("Absent");
2798
- });
2799
-
2800
- test("custom stateIntoSpec", () => {
2801
- const result = ConfigConnectorContext({ ...minProps, stateIntoSpec: "Merge" });
2802
- expect((p(result.context) as any).spec.stateIntoSpec).toBe("Merge");
2803
- });
2804
-
2805
- test("default namespace is default", () => {
2806
- const result = ConfigConnectorContext(minProps);
2807
- expect((p(result.context) as any).metadata.namespace).toBe("default");
2808
- });
2809
-
2810
- test("custom namespace", () => {
2811
- const result = ConfigConnectorContext({ ...minProps, namespace: "config-connector" });
2812
- expect((p(result.context) as any).metadata.namespace).toBe("config-connector");
2813
- });
2814
- });
2815
-
2816
- // ── GkeFluentBitAgent ────────────────────────────────────────────────
2817
-
2818
- describe("GkeFluentBitAgent", () => {
2819
- const { GkeFluentBitAgent } = require("./gke-fluent-bit-agent");
2820
-
2821
- const minProps = {
2822
- clusterName: "test-cluster",
2823
- projectId: "test-project",
2824
- gcpServiceAccountEmail: "fluent-bit@test-project.iam.gserviceaccount.com",
2825
- };
2826
-
2827
- test("returns all expected resources", () => {
2828
- const result = GkeFluentBitAgent(minProps);
2829
- expect(result.daemonSet).toBeDefined();
2830
- expect(result.serviceAccount).toBeDefined();
2831
- expect(result.clusterRole).toBeDefined();
2832
- expect(result.clusterRoleBinding).toBeDefined();
2833
- expect(result.configMap).toBeDefined();
2834
- });
2835
-
2836
- test("SA has GKE Workload Identity annotation", () => {
2837
- const result = GkeFluentBitAgent(minProps);
2838
- const meta = p(result.serviceAccount).metadata as any;
2839
- expect(meta.annotations["iam.gke.io/gcp-service-account"]).toBe(
2840
- "fluent-bit@test-project.iam.gserviceaccount.com",
2841
- );
2842
- });
2843
-
2844
- test("SA has no annotation when gcpServiceAccountEmail omitted", () => {
2845
- const result = GkeFluentBitAgent({
2846
- clusterName: "test-cluster",
2847
- projectId: "test-project",
2848
- });
2849
- const meta = p(result.serviceAccount).metadata as any;
2850
- expect(meta.annotations).toBeUndefined();
2851
- });
2852
-
2853
- test("configMap uses stackdriver output", () => {
2854
- const result = GkeFluentBitAgent(minProps);
2855
- const data = p(result.configMap).data as any;
2856
- expect(data["fluent-bit.conf"]).toContain("stackdriver");
2857
- expect(data["fluent-bit.conf"]).toContain("test-cluster");
2858
- });
2859
-
2860
- test("default namespace is gke-logging", () => {
2861
- const result = GkeFluentBitAgent(minProps);
2862
- expect((p(result.daemonSet).metadata as any).namespace).toBe("gke-logging");
2863
- expect((p(result.serviceAccount).metadata as any).namespace).toBe("gke-logging");
2864
- });
2865
-
2866
- test("common labels on all resources", () => {
2867
- const result = GkeFluentBitAgent(minProps);
2868
- for (const resource of [result.daemonSet, result.serviceAccount, result.clusterRole, result.clusterRoleBinding, result.configMap]) {
2869
- expect((p(resource).metadata as any).labels["app.kubernetes.io/managed-by"]).toBe("chant");
2870
- }
2871
- });
2872
-
2873
- test("DaemonSet mounts host log directory", () => {
2874
- const result = GkeFluentBitAgent(minProps);
2875
- const spec = (p(result.daemonSet) as any).spec.template.spec;
2876
- const varlog = spec.volumes.find((v: any) => v.name === "varlog");
2877
- expect(varlog.hostPath.path).toBe("/var/log");
2878
- });
2879
-
2880
- test("container runs as root for log access", () => {
2881
- const result = GkeFluentBitAgent(minProps);
2882
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
2883
- expect(container.securityContext.runAsUser).toBe(0);
2884
- expect(container.securityContext.readOnlyRootFilesystem).toBe(true);
2885
- });
2886
- });
2887
-
2888
- // ── GkeOtelCollector ─────────────────────────────────────────────────
2889
-
2890
- describe("GkeOtelCollector", () => {
2891
- const { GkeOtelCollector } = require("./gke-otel-collector");
2892
-
2893
- const minProps = {
2894
- clusterName: "test-cluster",
2895
- projectId: "test-project",
2896
- gcpServiceAccountEmail: "otel@test-project.iam.gserviceaccount.com",
2897
- };
2898
-
2899
- test("returns all expected resources", () => {
2900
- const result = GkeOtelCollector(minProps);
2901
- expect(result.daemonSet).toBeDefined();
2902
- expect(result.serviceAccount).toBeDefined();
2903
- expect(result.clusterRole).toBeDefined();
2904
- expect(result.clusterRoleBinding).toBeDefined();
2905
- expect(result.configMap).toBeDefined();
2906
- });
2907
-
2908
- test("SA has GKE Workload Identity annotation", () => {
2909
- const result = GkeOtelCollector(minProps);
2910
- const meta = p(result.serviceAccount).metadata as any;
2911
- expect(meta.annotations["iam.gke.io/gcp-service-account"]).toBe(
2912
- "otel@test-project.iam.gserviceaccount.com",
2913
- );
2914
- });
2915
-
2916
- test("SA has no annotation when gcpServiceAccountEmail omitted", () => {
2917
- const result = GkeOtelCollector({
2918
- clusterName: "test-cluster",
2919
- projectId: "test-project",
2920
- });
2921
- const meta = p(result.serviceAccount).metadata as any;
2922
- expect(meta.annotations).toBeUndefined();
2923
- });
2924
-
2925
- test("configMap uses googlecloud exporter", () => {
2926
- const result = GkeOtelCollector(minProps);
2927
- const data = p(result.configMap).data as any;
2928
- expect(data["config.yaml"]).toContain("googlecloud");
2929
- expect(data["config.yaml"]).toContain("test-project");
2930
- });
2931
-
2932
- test("default namespace is gke-monitoring", () => {
2933
- const result = GkeOtelCollector(minProps);
2934
- expect((p(result.daemonSet).metadata as any).namespace).toBe("gke-monitoring");
2935
- });
2936
-
2937
- test("container exposes OTLP ports", () => {
2938
- const result = GkeOtelCollector(minProps);
2939
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
2940
- const ports = container.ports.map((p: any) => p.containerPort);
2941
- expect(ports).toContain(4317);
2942
- expect(ports).toContain(4318);
2943
- });
2944
-
2945
- test("container runs as non-root", () => {
2946
- const result = GkeOtelCollector(minProps);
2947
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
2948
- expect(container.securityContext.runAsNonRoot).toBe(true);
2949
- expect(container.securityContext.runAsUser).toBe(10001);
2950
- });
2951
-
2952
- test("common labels on all resources", () => {
2953
- const result = GkeOtelCollector(minProps);
2954
- for (const resource of [result.daemonSet, result.serviceAccount, result.clusterRole, result.clusterRoleBinding, result.configMap]) {
2955
- expect((p(resource).metadata as any).labels["app.kubernetes.io/managed-by"]).toBe("chant");
2956
- }
2957
- });
2958
-
2959
- // #2559 moved the collector config onto the otel lexicon. This is the
2960
- // hand-written template the composite carried before, verbatim; the
2961
- // lexicon-rendered config must match it byte for byte.
2962
- const handWrittenConfig = (projectId: string, clusterName: string) => `receivers:
2963
- otlp:
2964
- protocols:
2965
- grpc:
2966
- endpoint: 0.0.0.0:4317
2967
- http:
2968
- endpoint: 0.0.0.0:4318
2969
-
2970
- processors:
2971
- batch:
2972
- timeout: 30s
2973
- send_batch_size: 8192
2974
- resourcedetection:
2975
- detectors: [gcp]
2976
- timeout: 10s
2977
-
2978
- exporters:
2979
- googlecloud:
2980
- project: ${projectId}
2981
- metric:
2982
- prefix: custom.googleapis.com/${clusterName}
2983
- trace:
2984
- attribute_mappings:
2985
- - key: service.name
2986
- replacement: g.co/r/service/name
2987
-
2988
- service:
2989
- pipelines:
2990
- metrics:
2991
- receivers: [otlp]
2992
- processors: [batch, resourcedetection]
2993
- exporters: [googlecloud]
2994
- traces:
2995
- receivers: [otlp]
2996
- processors: [batch, resourcedetection]
2997
- exporters: [googlecloud]
2998
- `;
2999
-
3000
- test.each([
3001
- ["test-project", "test-cluster"],
3002
- ["my-project", "gke-microservice"],
3003
- ["p-123456", "c1"],
3004
- ])("config.yaml is byte-identical to the pre-lexicon template (%s, %s)", (projectId, clusterName) => {
3005
- const result = GkeOtelCollector({ clusterName, projectId });
3006
- expect((p(result.configMap).data as any)["config.yaml"]).toBe(handWrittenConfig(projectId, clusterName));
3007
- });
3008
-
3009
- test("the rendered config passes the otel lexicon's checks", async () => {
3010
- const { validateCollectorConfig } = await import("@intentius/chant-lexicon-otel");
3011
- const { load } = await import("js-yaml");
3012
- const result = GkeOtelCollector(minProps);
3013
- const config = load((p(result.configMap).data as any)["config.yaml"]) as any;
3014
- expect(validateCollectorConfig(config)).toEqual([]);
3015
- });
3016
- });
3017
-
3018
- // ── OtelCollector ────────────────────────────────────────────────────
3019
-
3020
- describe("OtelCollector", () => {
3021
- const { OtelCollector } = require("./otel-collector");
3022
-
3023
- async function renderedConfig(result: any): Promise<any> {
3024
- const { load } = await import("js-yaml");
3025
- return load((p(result.configMap).data as any)["config.yaml"]);
3026
- }
3027
-
3028
- test("returns the agent resources and a Service", () => {
3029
- const result = OtelCollector({});
3030
- for (const key of ["daemonSet", "service", "serviceAccount", "clusterRole", "clusterRoleBinding", "configMap"]) {
3031
- expect(result[key], key).toBeDefined();
3032
- }
3033
- });
3034
-
3035
- test("defaults to otel-collector in observability, on the pinned contrib image", async () => {
3036
- const { COLLECTOR_IMAGE } = await import("@intentius/chant-lexicon-otel");
3037
- const result = OtelCollector({});
3038
- const meta = p(result.daemonSet).metadata as any;
3039
- expect(meta.name).toBe("otel-collector");
3040
- expect(meta.namespace).toBe("observability");
3041
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
3042
- expect(container.image).toBe(COLLECTOR_IMAGE);
3043
- expect(container.image).toMatch(/^otel\/opentelemetry-collector-contrib:\d+\.\d+\.\d+$/);
3044
- });
3045
-
3046
- test("the default config is OTLP in, debug out, and passes the otel lexicon's checks", async () => {
3047
- const { validateCollectorConfig } = await import("@intentius/chant-lexicon-otel");
3048
- const config = await renderedConfig(OtelCollector({}));
3049
- expect(validateCollectorConfig(config)).toEqual([]);
3050
- expect(Object.keys(config.exporters)).toEqual(["debug"]);
3051
- expect(Object.keys(config.service.pipelines).sort()).toEqual(["logs", "metrics", "traces"]);
3052
- expect(config.service.extensions).toEqual(["health_check"]);
3053
- });
3054
-
3055
- test("container and Service ports follow the config's receivers", () => {
3056
- const result = OtelCollector({});
3057
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
3058
- expect(container.ports).toEqual([
3059
- { containerPort: 4317, name: "otlp-grpc" },
3060
- { containerPort: 4318, name: "otlp-http" },
3061
- { containerPort: 13133, name: "health" },
3062
- ]);
3063
- const spec = p(result.service).spec as any;
3064
- expect(spec.internalTrafficPolicy).toBe("Local");
3065
- expect(spec.ports).toEqual([
3066
- { name: "otlp-grpc", port: 4317, targetPort: "otlp-grpc", protocol: "TCP" },
3067
- { name: "otlp-http", port: 4318, targetPort: "otlp-http", protocol: "TCP" },
3068
- ]);
3069
- });
3070
-
3071
- test("probes hit the health_check extension", () => {
3072
- const container = (p(OtelCollector({}).daemonSet) as any).spec.template.spec.containers[0];
3073
- expect(container.livenessProbe).toEqual({ httpGet: { path: "/", port: "health" } });
3074
- expect(container.readinessProbe).toEqual(container.livenessProbe);
3075
- });
3076
-
3077
- test("the config file is mounted at the path the command reads", async () => {
3078
- const { COLLECTOR_CONFIG_PATH } = await import("@intentius/chant-lexicon-otel");
3079
- const pod = (p(OtelCollector({}).daemonSet) as any).spec.template.spec;
3080
- const container = pod.containers[0];
3081
- expect(container.args ?? container.command).toContain(`--config=${COLLECTOR_CONFIG_PATH}`);
3082
- const dir = COLLECTOR_CONFIG_PATH.slice(0, COLLECTOR_CONFIG_PATH.lastIndexOf("/"));
3083
- expect(container.volumeMounts.map((m: any) => m.mountPath)).toContain(dir);
3084
- });
3085
-
3086
- test("exporters and signals shape the default config", async () => {
3087
- const { OtlpExporter } = await import("@intentius/chant-lexicon-otel");
3088
- const tempo = new OtlpExporter({ name: "tempo", endpoint: "tempo:4317", tls: { insecure: true } });
3089
- const config = await renderedConfig(OtelCollector({ exporters: [tempo], signals: ["traces"] }));
3090
- expect(config.exporters).toEqual({ "otlp/tempo": { endpoint: "tempo:4317", tls: { insecure: true } } });
3091
- expect(Object.keys(config.service.pipelines)).toEqual(["traces"]);
3092
- expect(config.service.pipelines.traces.exporters).toEqual(["otlp/tempo"]);
3093
- });
3094
-
3095
- test("a full config replaces the default, and ports and probes follow it", async () => {
3096
- const { OtlpReceiver, DebugExporter, Pipeline } = await import("@intentius/chant-lexicon-otel");
3097
- const otlp = new OtlpReceiver({ protocols: { grpc: { endpoint: "0.0.0.0:14317" } } });
3098
- const result = OtelCollector({
3099
- config: [new Pipeline({ signal: "logs", receivers: [otlp], exporters: [new DebugExporter({})] })],
3100
- });
3101
- const config = await renderedConfig(result);
3102
- expect(Object.keys(config.receivers)).toEqual(["otlp"]);
3103
- expect(config.service.extensions).toBeUndefined();
3104
- const container = (p(result.daemonSet) as any).spec.template.spec.containers[0];
3105
- expect(container.ports).toEqual([{ containerPort: 14317, name: "otlp-grpc" }]);
3106
- expect(container.livenessProbe).toBeUndefined();
3107
- expect((p(result.service).spec as any).ports.map((x: any) => x.port)).toEqual([14317]);
3108
- });
3109
-
3110
- test("name, namespace and labels reach every resource", () => {
3111
- const result = OtelCollector({ name: "agent", namespace: "telemetry", labels: { team: "obs" } });
3112
- for (const key of ["daemonSet", "service", "serviceAccount", "configMap"]) {
3113
- const meta = p(result[key]).metadata as any;
3114
- expect(meta.name, key).toMatch(/^agent(-|$)/);
3115
- expect(meta.namespace, key).toBe("telemetry");
3116
- expect(meta.labels.team, key).toBe("obs");
3117
- expect(meta.labels["app.kubernetes.io/managed-by"], key).toBe("chant");
3118
- }
3119
- expect((p(result.service).spec as any).selector).toEqual({ "app.kubernetes.io/name": "agent" });
3120
- });
3121
-
3122
- test("defaults override a member", () => {
3123
- const result = OtelCollector({ defaults: { service: { spec: { internalTrafficPolicy: "Cluster" } } } });
3124
- expect((p(result.service).spec as any).internalTrafficPolicy).toBe("Cluster");
3125
- });
3126
-
3127
- test("container runs as non-root with a read-only root filesystem", () => {
3128
- const container = (p(OtelCollector({}).daemonSet) as any).spec.template.spec.containers[0];
3129
- expect(container.securityContext.runAsNonRoot).toBe(true);
3130
- expect(container.securityContext.readOnlyRootFilesystem).toBe(true);
3131
- expect(container.securityContext.capabilities).toEqual({ drop: ["ALL"] });
3132
- });
3133
- });
3134
-
3135
- // ── GkeExternalDnsAgent ──────────────────────────────────────────────
3136
-
3137
- describe("GkeExternalDnsAgent", () => {
3138
- const { GkeExternalDnsAgent } = require("./gke-external-dns-agent");
3139
-
3140
- const minProps = {
3141
- gcpServiceAccountEmail: "external-dns@test-project.iam.gserviceaccount.com",
3142
- gcpProjectId: "test-project",
3143
- domainFilters: ["example.com"],
3144
- };
3145
-
3146
- test("returns all expected resources", () => {
3147
- const result = GkeExternalDnsAgent(minProps);
3148
- expect(result.deployment).toBeDefined();
3149
- expect(result.serviceAccount).toBeDefined();
3150
- expect(result.clusterRole).toBeDefined();
3151
- expect(result.clusterRoleBinding).toBeDefined();
3152
- });
3153
-
3154
- test("SA has GKE Workload Identity annotation", () => {
3155
- const result = GkeExternalDnsAgent(minProps);
3156
- const meta = p(result.serviceAccount).metadata as any;
3157
- expect(meta.annotations["iam.gke.io/gcp-service-account"]).toBe(
3158
- "external-dns@test-project.iam.gserviceaccount.com",
3159
- );
3160
- });
3161
-
3162
- test("uses google provider", () => {
3163
- const result = GkeExternalDnsAgent(minProps);
3164
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3165
- expect(container.args).toContain("--provider=google");
3166
- });
3167
-
3168
- test("passes google-project arg", () => {
3169
- const result = GkeExternalDnsAgent(minProps);
3170
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3171
- expect(container.args).toContain("--google-project=test-project");
3172
- });
3173
-
3174
- test("domain filters are applied", () => {
3175
- const result = GkeExternalDnsAgent(minProps);
3176
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3177
- expect(container.args).toContain("--domain-filter=example.com");
3178
- });
3179
-
3180
- test("txtOwnerId is applied when set", () => {
3181
- const result = GkeExternalDnsAgent({ ...minProps, txtOwnerId: "my-cluster" });
3182
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3183
- expect(container.args).toContain("--txt-owner-id=my-cluster");
3184
- });
3185
-
3186
- test("default namespace is kube-system", () => {
3187
- const result = GkeExternalDnsAgent(minProps);
3188
- expect((p(result.deployment).metadata as any).namespace).toBe("kube-system");
3189
- });
3190
-
3191
- test("container runs as non-root", () => {
3192
- const result = GkeExternalDnsAgent(minProps);
3193
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3194
- expect(container.securityContext.runAsNonRoot).toBe(true);
3195
- expect(container.securityContext.runAsUser).toBe(65534);
3196
- });
3197
- });
3198
-
3199
- // ── AksExternalDnsAgent ──────────────────────────────────────────────
3200
-
3201
- describe("AksExternalDnsAgent", () => {
3202
- const { AksExternalDnsAgent } = require("./aks-external-dns-agent");
3203
-
3204
- const minProps = {
3205
- clientId: "00000000-0000-0000-0000-000000000000",
3206
- resourceGroup: "test-rg",
3207
- subscriptionId: "11111111-1111-1111-1111-111111111111",
3208
- tenantId: "22222222-2222-2222-2222-222222222222",
3209
- domainFilters: ["example.com"],
3210
- };
3211
-
3212
- test("returns all expected resources", () => {
3213
- const result = AksExternalDnsAgent(minProps);
3214
- expect(result.deployment).toBeDefined();
3215
- expect(result.serviceAccount).toBeDefined();
3216
- expect(result.clusterRole).toBeDefined();
3217
- expect(result.clusterRoleBinding).toBeDefined();
3218
- });
3219
-
3220
- test("SA has AKS Workload Identity annotation and label", () => {
3221
- const result = AksExternalDnsAgent(minProps);
3222
- const meta = p(result.serviceAccount).metadata as any;
3223
- expect(meta.annotations["azure.workload.identity/client-id"]).toBe(
3224
- "00000000-0000-0000-0000-000000000000",
3225
- );
3226
- expect(meta.labels["azure.workload.identity/use"]).toBe("true");
3227
- });
3228
-
3229
- test("uses azure provider", () => {
3230
- const result = AksExternalDnsAgent(minProps);
3231
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3232
- expect(container.args).toContain("--provider=azure");
3233
- });
3234
-
3235
- test("passes azure resource group and subscription", () => {
3236
- const result = AksExternalDnsAgent(minProps);
3237
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3238
- expect(container.args).toContain("--azure-resource-group=test-rg");
3239
- expect(container.args).toContain("--azure-subscription-id=11111111-1111-1111-1111-111111111111");
3240
- });
3241
-
3242
- test("container has Azure env vars", () => {
3243
- const result = AksExternalDnsAgent(minProps);
3244
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3245
- const envMap = Object.fromEntries(container.env.map((e: any) => [e.name, e.value]));
3246
- expect(envMap.AZURE_TENANT_ID).toBe("22222222-2222-2222-2222-222222222222");
3247
- expect(envMap.AZURE_SUBSCRIPTION_ID).toBe("11111111-1111-1111-1111-111111111111");
3248
- expect(envMap.AZURE_RESOURCE_GROUP).toBe("test-rg");
3249
- });
3250
-
3251
- test("pod labels include workload identity use label", () => {
3252
- const result = AksExternalDnsAgent(minProps);
3253
- const podLabels = (p(result.deployment) as any).spec.template.metadata.labels;
3254
- expect(podLabels["azure.workload.identity/use"]).toBe("true");
3255
- });
3256
-
3257
- test("domain filters are applied", () => {
3258
- const result = AksExternalDnsAgent(minProps);
3259
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3260
- expect(container.args).toContain("--domain-filter=example.com");
3261
- });
3262
-
3263
- test("default namespace is kube-system", () => {
3264
- const result = AksExternalDnsAgent(minProps);
3265
- expect((p(result.deployment).metadata as any).namespace).toBe("kube-system");
3266
- });
3267
-
3268
- test("container runs as non-root", () => {
3269
- const result = AksExternalDnsAgent(minProps);
3270
- const container = (p(result.deployment) as any).spec.template.spec.containers[0];
3271
- expect(container.securityContext.runAsNonRoot).toBe(true);
3272
- expect(container.securityContext.runAsUser).toBe(65534);
3273
- });
3274
- });
3275
-
3276
- // ── CockroachDbCluster ──────────────────────────────────────────────
3277
-
3278
- describe("CockroachDbCluster", () => {
3279
- const { CockroachDbCluster } = require("./cockroachdb-cluster");
3280
-
3281
- const minProps = { name: "cockroachdb" };
3282
-
3283
- test("returns all expected resources", () => {
3284
- const result = CockroachDbCluster(minProps);
3285
- expect(result.serviceAccount).toBeDefined();
3286
- expect(result.role).toBeDefined();
3287
- expect(result.roleBinding).toBeDefined();
3288
- expect(result.clusterRole).toBeDefined();
3289
- expect(result.clusterRoleBinding).toBeDefined();
3290
- expect(result.publicService).toBeDefined();
3291
- expect(result.headlessService).toBeDefined();
3292
- expect(result.pdb).toBeDefined();
3293
- expect(result.statefulSet).toBeDefined();
3294
- expect(result.initJob).toBeDefined();
3295
- expect(result.certGenJob).toBeDefined();
3296
- });
3297
-
3298
- test("default replicas is 3", () => {
3299
- const result = CockroachDbCluster(minProps);
3300
- const spec = p(result.statefulSet).spec as any;
3301
- expect(spec.replicas).toBe(3);
3302
- });
3303
-
3304
- test("default image is cockroachdb/cockroach:v24.3.0", () => {
3305
- const result = CockroachDbCluster(minProps);
3306
- const container = (p(result.statefulSet).spec as any).template.spec.containers[0];
3307
- expect(container.image).toBe("cockroachdb/cockroach:v24.3.0");
3308
- });
3309
-
3310
- test("StatefulSet has correct ports (26257+8080)", () => {
3311
- const result = CockroachDbCluster(minProps);
3312
- const container = (p(result.statefulSet).spec as any).template.spec.containers[0];
3313
- const ports = container.ports.map((p: any) => p.containerPort);
3314
- expect(ports).toContain(26257);
3315
- expect(ports).toContain(8080);
3316
- });
3317
-
3318
- test("StatefulSet has PVC with default 100Gi storage", () => {
3319
- const result = CockroachDbCluster(minProps);
3320
- const vct = (p(result.statefulSet).spec as any).volumeClaimTemplates[0];
3321
- expect(vct.spec.resources.requests.storage).toBe("100Gi");
3322
- expect(vct.spec.accessModes).toEqual(["ReadWriteOnce"]);
3323
- });
3324
-
3325
- test("headless service has clusterIP None and publishNotReadyAddresses", () => {
3326
- const result = CockroachDbCluster(minProps);
3327
- const spec = p(result.headlessService).spec as any;
3328
- expect(spec.clusterIP).toBe("None");
3329
- expect(spec.publishNotReadyAddresses).toBe(true);
3330
- });
3331
-
3332
- test("public service has ClusterIP type with both ports", () => {
3333
- const result = CockroachDbCluster(minProps);
3334
- const spec = p(result.publicService).spec as any;
3335
- expect(spec.type).toBe("ClusterIP");
3336
- const ports = spec.ports.map((pt: any) => pt.port);
3337
- expect(ports).toContain(26257);
3338
- expect(ports).toContain(8080);
3339
- });
3340
-
3341
- test("PDB has maxUnavailable 1", () => {
3342
- const result = CockroachDbCluster(minProps);
3343
- const spec = p(result.pdb).spec as any;
3344
- expect(spec.maxUnavailable).toBe(1);
3345
- });
3346
-
3347
- test("StatefulSet has pod anti-affinity", () => {
3348
- const result = CockroachDbCluster(minProps);
3349
- const affinity = (p(result.statefulSet).spec as any).template.spec.affinity;
3350
- expect(affinity.podAntiAffinity).toBeDefined();
3351
- });
3352
-
3353
- test("props flow through (replicas, image, storage)", () => {
3354
- const result = CockroachDbCluster({
3355
- name: "crdb",
3356
- replicas: 5,
3357
- image: "cockroachdb/cockroach:v23.2.0",
3358
- storageSize: "200Gi",
3359
- });
3360
- const spec = p(result.statefulSet).spec as any;
3361
- expect(spec.replicas).toBe(5);
3362
- expect(spec.template.spec.containers[0].image).toBe("cockroachdb/cockroach:v23.2.0");
3363
- expect(spec.volumeClaimTemplates[0].spec.resources.requests.storage).toBe("200Gi");
3364
- });
3365
-
3366
- test("joinAddresses appear in container args", () => {
3367
- const joins = ["crdb-0.crdb.ns.svc.cluster.local", "crdb-1.crdb.ns.svc.cluster.local"];
3368
- const result = CockroachDbCluster({ name: "crdb", joinAddresses: joins });
3369
- const cmd = (p(result.statefulSet).spec as any).template.spec.containers[0].args[0] as string;
3370
- expect(cmd).toContain("--join=");
3371
- expect(cmd).toContain("crdb-0.crdb.ns.svc.cluster.local");
3372
- expect(cmd).toContain("crdb-1.crdb.ns.svc.cluster.local");
3373
- });
3374
-
3375
- test("locality appears in container args when set", () => {
3376
- const result = CockroachDbCluster({ name: "crdb", locality: "cloud=aws,region=us-east-1" });
3377
- const cmd = (p(result.statefulSet).spec as any).template.spec.containers[0].args[0] as string;
3378
- expect(cmd).toContain("--locality=cloud=aws,region=us-east-1");
3379
- });
3380
-
3381
- test("namespace is set on all namespaced resources", () => {
3382
- const result = CockroachDbCluster({ name: "crdb", namespace: "crdb-eks" });
3383
- for (const key of ["serviceAccount", "role", "roleBinding", "publicService", "headlessService", "pdb", "statefulSet", "initJob", "certGenJob"] as const) {
3384
- expect((p(result[key]).metadata as any).namespace).toBe("crdb-eks");
3385
- }
3386
- });
3387
-
3388
- test("cluster-scoped resources do not have namespace", () => {
3389
- const result = CockroachDbCluster({ name: "crdb", namespace: "crdb-eks" });
3390
- expect((p(result.clusterRole).metadata as any).namespace).toBeUndefined();
3391
- expect((p(result.clusterRoleBinding).metadata as any).namespace).toBeUndefined();
3392
- });
3393
-
3394
- test("includes common labels", () => {
3395
- const result = CockroachDbCluster(minProps);
3396
- const meta = p(result.statefulSet).metadata as any;
3397
- expect(meta.labels["app.kubernetes.io/name"]).toBe("cockroachdb");
3398
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
3399
- });
3400
-
3401
- test("secure mode mounts certs volume", () => {
3402
- const result = CockroachDbCluster({ name: "crdb", secure: true });
3403
- const spec = (p(result.statefulSet).spec as any).template.spec;
3404
- expect(spec.volumes).toBeDefined();
3405
- const certsVol = spec.volumes.find((v: any) => v.name === "certs");
3406
- expect(certsVol).toBeDefined();
3407
- expect(certsVol.secret.secretName).toBe("crdb-node-certs");
3408
- });
3409
-
3410
- test("insecure mode omits certs volume", () => {
3411
- const result = CockroachDbCluster({ name: "crdb", secure: false });
3412
- const spec = (p(result.statefulSet).spec as any).template.spec;
3413
- expect(spec.volumes).toBeUndefined();
3414
- const cmd = spec.containers[0].args[0] as string;
3415
- expect(cmd).toContain("--insecure");
3416
- });
3417
-
3418
- test("storageClassName is set when provided", () => {
3419
- const result = CockroachDbCluster({ name: "crdb", storageClassName: "gp3-encrypted" });
3420
- const vct = (p(result.statefulSet).spec as any).volumeClaimTemplates[0];
3421
- expect(vct.spec.storageClassName).toBe("gp3-encrypted");
3422
- });
3423
-
3424
- test("init job references correct host", () => {
3425
- const result = CockroachDbCluster({ name: "crdb" });
3426
- const container = (p(result.initJob).spec as any).template.spec.containers[0];
3427
- expect(container.args).toContain("--host=crdb-0.crdb");
3428
- });
3429
-
3430
- test("StatefulSet uses Parallel podManagementPolicy", () => {
3431
- const result = CockroachDbCluster(minProps);
3432
- expect((p(result.statefulSet).spec as any).podManagementPolicy).toBe("Parallel");
3433
- });
3434
-
3435
- test("cert-gen job uses same image as StatefulSet", () => {
3436
- const result = CockroachDbCluster({ name: "crdb", image: "cockroachdb/cockroach:v23.2.0" });
3437
- const container = (p(result.certGenJob).spec as any).template.spec.containers[0];
3438
- expect(container.image).toBe("cockroachdb/cockroach:v23.2.0");
3439
- });
3440
- });
3441
-
3442
- describe("ArgoAppFor", () => {
3443
- test("returns a single Application", () => {
3444
- const result = ArgoAppFor("api", { repo: "https://github.com/acme/infra", path: "dist/api" });
3445
- expect(result.application).toBeDefined();
3446
- expect((result.application as any).entityType).toBe("K8s::Argo::Application");
3447
- });
3448
-
3449
- test("maps repo/path/revision onto spec.source", () => {
3450
- const result = ArgoAppFor("api", {
3451
- repo: "https://github.com/acme/infra",
3452
- path: "dist/api",
3453
- targetRevision: "v1.2.3",
3454
- });
3455
- const spec = p(result.application).spec as any;
3456
- expect(spec.source.repoURL).toBe("https://github.com/acme/infra");
3457
- expect(spec.source.path).toBe("dist/api");
3458
- expect(spec.source.targetRevision).toBe("v1.2.3");
3459
- });
3460
-
3461
- test("defaults to the in-cluster destination and default project", () => {
3462
- const spec = p(ArgoAppFor("api", { repo: "r", path: "p" }).application).spec as any;
3463
- expect(spec.destination.server).toBe("https://kubernetes.default.svc");
3464
- expect(spec.destination.namespace).toBe("api");
3465
- expect(spec.project).toBe("default");
3466
- });
3467
-
3468
- test("default sync policy is automated, non-pruning, self-healing", () => {
3469
- const spec = p(ArgoAppFor("api", { repo: "r", path: "p" }).application).spec as any;
3470
- expect(spec.syncPolicy.automated.prune).toBe(false);
3471
- expect(spec.syncPolicy.automated.selfHeal).toBe(true);
3472
- expect(spec.syncPolicy.syncOptions).toContain("CreateNamespace=true");
3473
- });
3474
-
3475
- test("explicit empty sync policy yields manual sync (no automated block)", () => {
3476
- const spec = p(ArgoAppFor("api", { repo: "r", path: "p", syncPolicy: {} }).application).spec as any;
3477
- expect(spec.syncPolicy).toBeUndefined();
3478
- });
3479
-
3480
- test("honors an explicit destination", () => {
3481
- const spec = p(
3482
- ArgoAppFor("api", {
3483
- repo: "r",
3484
- path: "p",
3485
- destination: { server: "https://east.example.com", namespace: "prod" },
3486
- }).application,
3487
- ).spec as any;
3488
- expect(spec.destination.server).toBe("https://east.example.com");
3489
- expect(spec.destination.namespace).toBe("prod");
3490
- });
3491
- });
3492
-
3493
- describe("ArgoAppSetForRegions", () => {
3494
- const opts = { name: "crdb", repo: "https://github.com/acme/infra", project: "crdb" };
3495
- const mapper = (region: string) => ({
3496
- server: `https://${region}.example.com`,
3497
- namespace: `crdb-${region}`,
3498
- path: `dist/${region}`,
3499
- });
3500
-
3501
- test("produces one ApplicationSet fanned out to 3 Applications", () => {
3502
- const result = ArgoAppSetForRegions(["east", "central", "west"], mapper, opts);
3503
- expect((result.applicationSet as any).entityType).toBe("K8s::Argo::ApplicationSet");
3504
- const spec = p(result.applicationSet).spec as any;
3505
- const elements = spec.generators[0].list.elements;
3506
- expect(elements).toHaveLength(3);
3507
- expect(elements.map((e: any) => e.region)).toEqual(["east", "central", "west"]);
3508
- expect(elements[0].server).toBe("https://east.example.com");
3509
- expect(elements[0].path).toBe("dist/east");
3510
- });
3511
-
3512
- test("template scopes to a single static AppProject (ARGO004)", () => {
3513
- const spec = p(ArgoAppSetForRegions(["east"], mapper, opts).applicationSet).spec as any;
3514
- expect(spec.template.spec.project).toBe("crdb");
3515
- expect(spec.template.spec.project).not.toContain("{{");
3516
- });
3517
-
3518
- test("template destination interpolates the per-region server", () => {
3519
- const spec = p(ArgoAppSetForRegions(["east"], mapper, opts).applicationSet).spec as any;
3520
- expect(spec.template.spec.destination.server).toBe("{{server}}");
3521
- expect(spec.template.spec.destination.namespace).toBe("{{namespace}}");
3522
- });
3523
-
3524
- test("falls back to the set-level path when the mapper omits one", () => {
3525
- const spec = p(
3526
- ArgoAppSetForRegions(
3527
- ["east"],
3528
- (r) => ({ server: `https://${r}.example.com`, namespace: `ns-${r}` }),
3529
- { ...opts, path: "dist/shared" },
3530
- ).applicationSet,
3531
- ).spec as any;
3532
- expect(spec.generators[0].list.elements[0].path).toBe("dist/shared");
3533
- });
3534
-
3535
- test("throws when no path is resolvable for a region", () => {
3536
- expect(() =>
3537
- ArgoAppSetForRegions(
3538
- ["east"],
3539
- (r) => ({ server: `https://${r}.example.com`, namespace: `ns-${r}` }),
3540
- opts,
3541
- ),
3542
- ).toThrow(/no path/);
3543
- });
3544
- });
3545
-
3546
- describe("registerArgoCluster", () => {
3547
- test("emits a Secret labelled as an Argo cluster registration", () => {
3548
- const result = registerArgoCluster({ name: "east", server: "https://east.example.com" });
3549
- expect((result.secret as any).entityType).toBe("K8s::Core::Secret");
3550
- const meta = (p(result.secret).metadata as any);
3551
- expect(meta.labels["argocd.argoproj.io/secret-type"]).toBe("cluster");
3552
- const stringData = p(result.secret).stringData as any;
3553
- expect(stringData.name).toBe("east");
3554
- expect(stringData.server).toBe("https://east.example.com");
3555
- });
3556
-
3557
- test("serializes an object config to JSON", () => {
3558
- const result = registerArgoCluster({
3559
- name: "east",
3560
- server: "https://east.example.com",
3561
- config: { tlsClientConfig: { insecure: false } },
3562
- });
3563
- const stringData = p(result.secret).stringData as any;
3564
- expect(JSON.parse(stringData.config)).toEqual({ tlsClientConfig: { insecure: false } });
3565
- });
3566
- });
3567
-
3568
- describe("FluxGitSource", () => {
3569
- test("returns a single GitRepository", () => {
3570
- const result = FluxGitSource("home-chant", { url: "https://github.com/jhgaylor/home-chant" });
3571
- expect(result.gitRepository).toBeDefined();
3572
- expect((result.gitRepository as any).entityType).toBe("K8s::Flux::GitRepository");
3573
- });
3574
-
3575
- test("defaults: 5m interval, main branch, flux-system namespace", () => {
3576
- const result = FluxGitSource("home-chant", { url: "https://github.com/jhgaylor/home-chant" });
3577
- const meta = p(result.gitRepository).metadata as any;
3578
- const spec = p(result.gitRepository).spec as any;
3579
- expect(meta.namespace).toBe("flux-system");
3580
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
3581
- expect(spec.interval).toBe("5m");
3582
- expect(spec.url).toBe("https://github.com/jhgaylor/home-chant");
3583
- expect(spec.ref).toEqual({ branch: "main" });
3584
- });
3585
-
3586
- test("a tag pin wins over the branch default", () => {
3587
- const spec = p(FluxGitSource("app", { url: "u", tag: "v1.2.3" }).gitRepository).spec as any;
3588
- expect(spec.ref).toEqual({ tag: "v1.2.3" });
3589
- });
3590
-
3591
- test("secretRef renders as a name reference", () => {
3592
- const spec = p(FluxGitSource("app", { url: "u", secretRef: "git-creds" }).gitRepository).spec as any;
3593
- expect(spec.secretRef).toEqual({ name: "git-creds" });
3594
- });
3595
- });
3596
-
3597
- describe("FluxAppFor", () => {
3598
- const source = () => FluxGitSource("home-chant", { url: "https://github.com/jhgaylor/home-chant" });
3599
-
3600
- test("returns a single Kustomization (the source is not duplicated)", () => {
3601
- const result = FluxAppFor("hello-chant", { source: source(), path: "./apps/hello-chant/k8s" });
3602
- expect(result.kustomization).toBeDefined();
3603
- expect((result.kustomization as any).entityType).toBe("K8s::Flux::Kustomization");
3604
- expect((result as any).gitRepository).toBeUndefined();
3605
- });
3606
-
3607
- test("defaults: 10m interval, prune, wait, flux-system namespace", () => {
3608
- const result = FluxAppFor("hello-chant", { source: source(), path: "./apps/hello-chant/k8s" });
3609
- const meta = p(result.kustomization).metadata as any;
3610
- const spec = p(result.kustomization).spec as any;
3611
- expect(meta.name).toBe("hello-chant");
3612
- expect(meta.namespace).toBe("flux-system");
3613
- expect(spec.interval).toBe("10m");
3614
- expect(spec.prune).toBe(true);
3615
- expect(spec.wait).toBe(true);
3616
- expect(spec.path).toBe("./apps/hello-chant/k8s");
3617
- });
3618
-
3619
- test("derives sourceRef from a FluxGitSource result", () => {
3620
- const spec = p(FluxAppFor("hello", { source: source(), path: "./k8s" }).kustomization).spec as any;
3621
- expect(spec.sourceRef).toEqual({ kind: "GitRepository", name: "home-chant", namespace: "flux-system" });
3622
- });
3623
-
3624
- test("many apps share one source", () => {
3625
- const shared = source();
3626
- const a = FluxAppFor("mealie", { source: shared, path: "./apps/mealie/k8s" });
3627
- const b = FluxAppFor("ntfy", { source: shared, path: "./apps/ntfy/k8s" });
3628
- expect((p(a.kustomization).spec as any).sourceRef.name).toBe("home-chant");
3629
- expect((p(b.kustomization).spec as any).sourceRef.name).toBe("home-chant");
3630
- });
3631
-
3632
- test("a string source names an existing GitRepository (flux-system)", () => {
3633
- const spec = p(FluxAppFor("mealie", { source: "flux-system", path: "./apps/mealie/generated" }).kustomization)
3634
- .spec as any;
3635
- expect(spec.sourceRef).toEqual({ kind: "GitRepository", name: "flux-system" });
3636
- });
3637
-
3638
- test("an explicit ref carries a non-git source kind", () => {
3639
- const spec = p(
3640
- FluxAppFor("fountain", { source: { kind: "OCIRepository", name: "fountain" }, path: "./k8s" }).kustomization,
3641
- ).spec as any;
3642
- expect(spec.sourceRef).toEqual({ kind: "OCIRepository", name: "fountain" });
3643
- });
3644
-
3645
- test("dependsOn is a plain name list rendered to name objects", () => {
3646
- const spec = p(
3647
- FluxAppFor("hello", {
3648
- source: "flux-system",
3649
- path: "./k8s",
3650
- dependsOn: ["cert-manager", "traefik"],
3651
- }).kustomization,
3652
- ).spec as any;
3653
- expect(spec.dependsOn).toEqual([{ name: "cert-manager" }, { name: "traefik" }]);
3654
- });
3655
-
3656
- test("omits dependsOn when the list is empty", () => {
3657
- const spec = p(FluxAppFor("hello", { source: "flux-system", path: "./k8s" }).kustomization).spec as any;
3658
- expect(spec.dependsOn).toBeUndefined();
3659
- });
3660
-
3661
- test("maps targetNamespace and opt-outs onto the spec", () => {
3662
- const spec = p(
3663
- FluxAppFor("cloudflared", {
3664
- source: "flux-system",
3665
- path: "./apps/cloudflared/generated",
3666
- targetNamespace: "cloudflared",
3667
- wait: false,
3668
- prune: false,
3669
- suspend: true,
3670
- timeout: "3m",
3671
- serviceAccountName: "flux-applier",
3672
- }).kustomization,
3673
- ).spec as any;
3674
- expect(spec.targetNamespace).toBe("cloudflared");
3675
- expect(spec.wait).toBe(false);
3676
- expect(spec.prune).toBe(false);
3677
- expect(spec.suspend).toBe(true);
3678
- expect(spec.timeout).toBe("3m");
3679
- expect(spec.serviceAccountName).toBe("flux-applier");
3680
- });
3681
-
3682
- test("omits decryption when the option is not set", () => {
3683
- const spec = p(FluxAppFor("hello", { source: "flux-system", path: "./k8s" }).kustomization).spec as any;
3684
- expect(spec.decryption).toBeUndefined();
3685
- });
3686
-
3687
- test('decryption: "sops" defaults the secretRef to sops-age', () => {
3688
- const spec = p(
3689
- FluxAppFor("hello", { source: "flux-system", path: "./k8s", decryption: "sops" }).kustomization,
3690
- ).spec as any;
3691
- expect(spec.decryption).toEqual({ provider: "sops", secretRef: { name: "sops-age" } });
3692
- });
3693
-
3694
- test("decryption object form names a custom secretRef", () => {
3695
- const spec = p(
3696
- FluxAppFor("hello", {
3697
- source: "flux-system",
3698
- path: "./k8s",
3699
- decryption: { provider: "sops", secretRef: "my-age-identity" },
3700
- }).kustomization,
3701
- ).spec as any;
3702
- expect(spec.decryption).toEqual({ provider: "sops", secretRef: { name: "my-age-identity" } });
3703
- });
3704
-
3705
- test("decryption object form with no secretRef still defaults to sops-age", () => {
3706
- const spec = p(
3707
- FluxAppFor("hello", { source: "flux-system", path: "./k8s", decryption: { provider: "sops" } }).kustomization,
3708
- ).spec as any;
3709
- expect(spec.decryption).toEqual({ provider: "sops", secretRef: { name: "sops-age" } });
3710
- });
3711
- });
3712
-
3713
- // ── InferenceService ─────────────────────────────────────────────────
3714
-
3715
- describe("InferenceService", () => {
3716
- test("emits a valid InferenceService referencing the runtime and storageUri", () => {
3717
- const result = InferenceService({
3718
- name: "llama-3-8b",
3719
- namespace: "serving",
3720
- model: "gs://my-models/llama-3-8b/v1",
3721
- runtime: "vllm-runtime",
3722
- });
3723
- expect(result.inferenceService).toBeDefined();
3724
- const spec = p(result.inferenceService).spec as any;
3725
- expect(spec.predictor.model.runtime).toBe("vllm-runtime");
3726
- expect(spec.predictor.model.storageUri).toBe("gs://my-models/llama-3-8b/v1");
3727
- });
3728
-
3729
- test("accepts a resolved model ref ({ storageUri }) in place of a raw string", () => {
3730
- const result = InferenceService({
3731
- name: "svc",
3732
- namespace: "ns",
3733
- model: { storageUri: "s3://bucket/model/v2" },
3734
- runtime: "vllm-runtime",
3735
- });
3736
- const spec = p(result.inferenceService).spec as any;
3737
- expect(spec.predictor.model.storageUri).toBe("s3://bucket/model/v2");
3738
- });
3739
-
3740
- test("modelFormat is omitted unless explicitly set", () => {
3741
- const result = InferenceService({
3742
- name: "svc",
3743
- namespace: "ns",
3744
- model: "gs://bucket/model",
3745
- runtime: "vllm-runtime",
3746
- });
3747
- const spec = p(result.inferenceService).spec as any;
3748
- expect(spec.predictor.model.modelFormat).toBeUndefined();
3749
- });
3750
-
3751
- test("modelFormat.name flows through when set", () => {
3752
- const result = InferenceService({
3753
- name: "svc",
3754
- namespace: "ns",
3755
- model: "gs://bucket/model",
3756
- runtime: "vllm-runtime",
3757
- modelFormat: "vLLM",
3758
- });
3759
- const spec = p(result.inferenceService).spec as any;
3760
- expect(spec.predictor.model.modelFormat).toEqual({ name: "vLLM" });
3761
- });
3762
-
3763
- test("autoscaling bounds (minReplicas/maxReplicas/scaleTarget/scaleMetric) are expressible and present", () => {
3764
- const result = InferenceService({
3765
- name: "svc",
3766
- namespace: "ns",
3767
- model: "gs://bucket/model",
3768
- runtime: "vllm-runtime",
3769
- minReplicas: 1,
3770
- maxReplicas: 4,
3771
- scaleTarget: 8,
3772
- scaleMetric: "concurrency",
3773
- });
3774
- const spec = p(result.inferenceService).spec as any;
3775
- expect(spec.predictor.minReplicas).toBe(1);
3776
- expect(spec.predictor.maxReplicas).toBe(4);
3777
- expect(spec.predictor.scaleTarget).toBe(8);
3778
- expect(spec.predictor.scaleMetric).toBe("concurrency");
3779
- });
3780
-
3781
- test("raw-HPA scaleMetric values (cpu/memory/rps) pass through", () => {
3782
- const result = InferenceService({
3783
- name: "svc",
3784
- namespace: "ns",
3785
- model: "gs://bucket/model",
3786
- runtime: "vllm-runtime",
3787
- scaleMetric: "cpu",
3788
- });
3789
- const spec = p(result.inferenceService).spec as any;
3790
- expect(spec.predictor.scaleMetric).toBe("cpu");
3791
- });
3792
-
3793
- test("autoscaling fields are absent when not set", () => {
3794
- const result = InferenceService({
3795
- name: "svc",
3796
- namespace: "ns",
3797
- model: "gs://bucket/model",
3798
- runtime: "vllm-runtime",
3799
- });
3800
- const spec = p(result.inferenceService).spec as any;
3801
- expect(spec.predictor.minReplicas).toBeUndefined();
3802
- expect(spec.predictor.maxReplicas).toBeUndefined();
3803
- expect(spec.predictor.scaleTarget).toBeUndefined();
3804
- expect(spec.predictor.scaleMetric).toBeUndefined();
3805
- });
3806
-
3807
- test("canary traffic split is expressible and present", () => {
3808
- const result = InferenceService({
3809
- name: "svc",
3810
- namespace: "ns",
3811
- model: "gs://bucket/model",
3812
- runtime: "vllm-runtime",
3813
- canaryTrafficPercent: 10,
3814
- });
3815
- const spec = p(result.inferenceService).spec as any;
3816
- expect(spec.predictor.canaryTrafficPercent).toBe(10);
3817
- });
3818
-
3819
- test("canary traffic split is absent when not set", () => {
3820
- const result = InferenceService({
3821
- name: "svc",
3822
- namespace: "ns",
3823
- model: "gs://bucket/model",
3824
- runtime: "vllm-runtime",
3825
- });
3826
- const spec = p(result.inferenceService).spec as any;
3827
- expect(spec.predictor.canaryTrafficPercent).toBeUndefined();
3828
- });
3829
-
3830
- test("includes common labels and metadata", () => {
3831
- const result = InferenceService({
3832
- name: "svc",
3833
- namespace: "ns",
3834
- model: "gs://bucket/model",
3835
- runtime: "vllm-runtime",
3836
- labels: { team: "ml-platform" },
3837
- });
3838
- const meta = p(result.inferenceService).metadata as any;
3839
- expect(meta.name).toBe("svc");
3840
- expect(meta.namespace).toBe("ns");
3841
- expect(meta.labels["app.kubernetes.io/name"]).toBe("svc");
3842
- expect(meta.labels["app.kubernetes.io/managed-by"]).toBe("chant");
3843
- expect(meta.labels.team).toBe("ml-platform");
3844
- });
3845
-
3846
- test("golden: full spec shape with predictor, model, autoscaling, and canary", () => {
3847
- const result = InferenceService({
3848
- name: "llama-3-8b",
3849
- namespace: "serving",
3850
- model: "gs://my-models/llama-3-8b/v1",
3851
- runtime: "vllm-runtime",
3852
- modelFormat: "vLLM",
3853
- minReplicas: 1,
3854
- maxReplicas: 4,
3855
- scaleTarget: 8,
3856
- scaleMetric: "concurrency",
3857
- canaryTrafficPercent: 10,
3858
- });
3859
- const spec = p(result.inferenceService).spec as any;
3860
- expect(spec).toEqual({
3861
- predictor: {
3862
- model: {
3863
- runtime: "vllm-runtime",
3864
- storageUri: "gs://my-models/llama-3-8b/v1",
3865
- modelFormat: { name: "vLLM" },
3866
- },
3867
- minReplicas: 1,
3868
- maxReplicas: 4,
3869
- scaleTarget: 8,
3870
- scaleMetric: "concurrency",
3871
- canaryTrafficPercent: 10,
3872
- },
3873
- });
3874
- });
3875
-
3876
- test("defaults passthrough merges into the InferenceService", () => {
3877
- const result = InferenceService({
3878
- name: "svc",
3879
- namespace: "ns",
3880
- model: "gs://bucket/model",
3881
- runtime: "vllm-runtime",
3882
- defaults: {
3883
- inferenceService: { spec: { predictor: { model: { protocolVersion: "v2" } } } },
3884
- },
3885
- });
3886
- const spec = p(result.inferenceService).spec as any;
3887
- expect(spec.predictor.model.protocolVersion).toBe("v2");
3888
- expect(spec.predictor.model.runtime).toBe("vllm-runtime");
3889
- });
3890
- });
3891
-
3892
- // ── Model ─────────────────────────────────────────────────────────
3893
-
3894
- describe("Model", () => {
3895
- test("resolves a gcs source to a gs:// storageUri pinned to version", () => {
3896
- const result = Model({ id: "llama-3-8b", version: "2024-07-01", source: "gcs" });
3897
- expect(result.storageUri).toBe("gs://llama-3-8b/2024-07-01");
3898
- });
3899
-
3900
- test("resolves an s3 source to an s3:// storageUri pinned to version", () => {
3901
- const result = Model({ id: "llama-3-8b", version: "2024-07-01", source: "s3" });
3902
- expect(result.storageUri).toBe("s3://llama-3-8b/2024-07-01");
3903
- });
3904
-
3905
- test("resolves a pvc source to a pvc:// storageUri pinned to version", () => {
3906
- const result = Model({ id: "llama-3-8b", version: "2024-07-01", source: "pvc" });
3907
- expect(result.storageUri).toBe("pvc://llama-3-8b/2024-07-01");
3908
- });
3909
-
3910
- test("resolves an hf source to an hf:// storageUri pinned to version", () => {
3911
- const result = Model({ id: "llama-3-8b", version: "2024-07-01", source: "hf" });
3912
- expect(result.storageUri).toBe("hf://llama-3-8b/2024-07-01");
3913
- });
3914
-
3915
- test("an explicit uri overrides the id-derived path but version is still appended", () => {
3916
- const result = Model({
3917
- id: "llama-3-8b",
3918
- version: "2024-07-01",
3919
- source: "gcs",
3920
- uri: "my-models-bucket/llama-3-8b-instruct",
3921
- });
3922
- expect(result.storageUri).toBe("gs://my-models-bucket/llama-3-8b-instruct/2024-07-01");
3923
- });
3924
-
3925
- test("no cache PVC by default", () => {
3926
- const result = Model({ id: "llama-3-8b", version: "2024-07-01", source: "gcs" });
3927
- expect(result.cache).toBeUndefined();
3928
- });
3929
-
3930
- test("emits a cache PVC named `${id}-${version}` when cache is set", () => {
3931
- const result = Model({
3932
- id: "llama-3-8b",
3933
- version: "2024-07-01",
3934
- source: "gcs",
3935
- cache: { storageClass: "premium-rwo", size: "200Gi" },
3936
- });
3937
- expect(result.cache).toBeDefined();
3938
- expect((p(result.cache) as any).metadata.name).toBe("llama-3-8b-2024-07-01");
3939
- expect((p(result.cache) as any).spec.storageClassName).toBe("premium-rwo");
3940
- expect((p(result.cache) as any).spec.resources.requests.storage).toBe("200Gi");
3941
- });
3942
-
3943
- test("resolveModelStorageUri is the same resolution the composite uses", () => {
3944
- expect(resolveModelStorageUri({ id: "m", version: "v1", source: "s3" })).toBe("s3://m/v1");
3945
- });
3946
- });
3947
-
3948
- // ── OperatorStack ────────────────────────────────────────────────────────
3949
-
3950
- const READ_ONLY_OP: Pick<OpConfig, "phases" | "onFailure"> = {
3951
- phases: [{ name: "check", steps: [{ kind: "activity", fn: "lifecycleDiff" }] }],
3952
- };
3953
- const MUTATING_OP: Pick<OpConfig, "phases" | "onFailure"> = {
3954
- phases: [{ name: "apply", steps: [{ kind: "activity", fn: "kubectlApply" }] }],
3955
- };
3956
- const DESTRUCTIVE_OP: Pick<OpConfig, "phases" | "onFailure"> = {
3957
- phases: [{ name: "teardown", steps: [{ kind: "activity", fn: "envTeardown" }] }],
3958
- };
3959
-
3960
- describe("OperatorStack", () => {
3961
- test("returns a namespace and one CronJob/ServiceAccount/Role/RoleBinding per hosted ConvergeOp", () => {
3962
- const result: any = OperatorStack({
3963
- name: "chant-operator",
3964
- image: "chant:latest",
3965
- converge: [
3966
- { name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" },
3967
- { name: "fountain-apply", schedule: "*/10 * * * *", env: "staging", dial: "apply", dispatchTargets: [MUTATING_OP] },
3968
- ],
3969
- });
3970
- expect(result.namespace).toBeDefined();
3971
- expect(result["cronJob_fountain-observe"]).toBeDefined();
3972
- expect(result["cronJob_fountain-apply"]).toBeDefined();
3973
- expect(result["serviceAccount_fountain-observe"]).toBeDefined();
3974
- expect(result["serviceAccount_fountain-apply"]).toBeDefined();
3975
- expect(result["role_fountain-observe"]).toBeDefined();
3976
- expect(result["role_fountain-apply"]).toBeDefined();
3977
- expect(result["roleBinding_fountain-observe"]).toBeDefined();
3978
- expect(result["roleBinding_fountain-apply"]).toBeDefined();
3979
- });
3980
-
3981
- test("namespace name defaults to the stack name", () => {
3982
- const result: any = OperatorStack({
3983
- name: "chant-operator",
3984
- image: "chant:latest",
3985
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
3986
- });
3987
- expect((p(result.namespace).metadata as any).name).toBe("chant-operator");
3988
- });
3989
-
3990
- test("namespace name is overridable", () => {
3991
- const result: any = OperatorStack({
3992
- name: "chant-operator",
3993
- namespace: "chant-ops",
3994
- image: "chant:latest",
3995
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
3996
- });
3997
- expect((p(result.namespace).metadata as any).name).toBe("chant-ops");
3998
- expect((p(result["cronJob_fountain-observe"]).metadata as any).namespace).toBe("chant-ops");
3999
- });
4000
-
4001
- test("CronJob schedule passes through from the hosted ConvergeOp", () => {
4002
- const result: any = OperatorStack({
4003
- name: "chant-operator",
4004
- image: "chant:latest",
4005
- converge: [{ name: "fountain-observe", schedule: "17 * * * *", env: "staging" }],
4006
- });
4007
- expect((p(result["cronJob_fountain-observe"]).spec as any).schedule).toBe("17 * * * *");
4008
- });
4009
-
4010
- test("CronJob uses concurrencyPolicy Forbid — never queue a tick behind one in flight", () => {
4011
- const result: any = OperatorStack({
4012
- name: "chant-operator",
4013
- image: "chant:latest",
4014
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4015
- });
4016
- expect((p(result["cronJob_fountain-observe"]).spec as any).concurrencyPolicy).toBe("Forbid");
4017
- });
4018
-
4019
- test("CronJob container command defaults to `chant run <name>`", () => {
4020
- const result: any = OperatorStack({
4021
- name: "chant-operator",
4022
- image: "chant:latest",
4023
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4024
- });
4025
- const container = (p(result["cronJob_fountain-observe"]).spec as any).jobTemplate.spec.template.spec.containers[0];
4026
- expect(container.image).toBe("chant:latest");
4027
- expect(container.command).toEqual(["chant", "run", "fountain-observe"]);
4028
- expect(container.env).toEqual([
4029
- { name: "CHANT_CONVERGE_ENV", value: "staging" },
4030
- { name: "CHANT_CONVERGE_DIAL", value: "observe" },
4031
- ]);
4032
- });
4033
-
4034
- test("CronJob container command is overridable per host", () => {
4035
- const result: any = OperatorStack({
4036
- name: "chant-operator",
4037
- image: "chant:latest",
4038
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging", command: ["chant", "operator", "tick", "fountain-observe"] }],
4039
- });
4040
- const container = (p(result["cronJob_fountain-observe"]).spec as any).jobTemplate.spec.template.spec.containers[0];
4041
- expect(container.command).toEqual(["chant", "operator", "tick", "fountain-observe"]);
4042
- });
4043
-
4044
- test("ServiceAccount is bound to the CronJob's pod spec", () => {
4045
- const result: any = OperatorStack({
4046
- name: "chant-operator",
4047
- image: "chant:latest",
4048
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4049
- });
4050
- const podSpec = (p(result["cronJob_fountain-observe"]).spec as any).jobTemplate.spec.template.spec;
4051
- expect(podSpec.serviceAccountName).toBe("fountain-observe-sa");
4052
- expect((p(result["serviceAccount_fountain-observe"]).metadata as any).name).toBe("fountain-observe-sa");
4053
- const binding = p(result["roleBinding_fountain-observe"]) as any;
4054
- expect(binding.subjects[0]).toEqual({ kind: "ServiceAccount", name: "fountain-observe-sa", namespace: "chant-operator" });
4055
- expect(binding.roleRef).toEqual({ apiGroup: "rbac.authorization.k8s.io", kind: "Role", name: "fountain-observe-role" });
4056
- });
4057
-
4058
- // ── RBAC derivation ──────────────────────────────────────────────────
4059
-
4060
- test("a ConvergeOp with no dispatch targets gets read-only RBAC", () => {
4061
- const result: any = OperatorStack({
4062
- name: "chant-operator",
4063
- image: "chant:latest",
4064
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4065
- });
4066
- const role = p(result["role_fountain-observe"]) as any;
4067
- for (const rule of role.rules) {
4068
- expect(rule.verbs).toEqual(["get", "list", "watch"]);
4069
- }
4070
- });
4071
-
4072
- test("observe-dial ConvergeOp with a mutating dispatch target still gets read-only RBAC — observe never dispatches, per OPS014/convergeTick", () => {
4073
- const result: any = OperatorStack({
4074
- name: "chant-operator",
4075
- image: "chant:latest",
4076
- converge: [{ name: "fountain-watch", schedule: "*/10 * * * *", env: "staging", dial: "observe", dispatchTargets: [MUTATING_OP] }],
4077
- });
4078
- const role = p(result["role_fountain-watch"]) as any;
4079
- for (const rule of role.rules) {
4080
- expect(rule.verbs).toEqual(["get", "list", "watch"]);
4081
- }
4082
- });
4083
-
4084
- test("reconcile-dial ConvergeOp with a mutating dispatch target still gets read-only RBAC — OPS014 only lets apply free-run a mutating dispatch", () => {
4085
- const result: any = OperatorStack({
4086
- name: "chant-operator",
4087
- image: "chant:latest",
4088
- converge: [{ name: "fountain-reconcile", schedule: "*/10 * * * *", env: "staging", dial: "reconcile", dispatchTargets: [MUTATING_OP] }],
4089
- });
4090
- const role = p(result["role_fountain-reconcile"]) as any;
4091
- for (const rule of role.rules) {
4092
- expect(rule.verbs).toEqual(["get", "list", "watch"]);
4093
- }
4094
- });
4095
-
4096
- test("apply-dial ConvergeOp with a mutating dispatch target gets create/update/patch, never delete or wildcard", () => {
4097
- const result: any = OperatorStack({
4098
- name: "chant-operator",
4099
- image: "chant:latest",
4100
- converge: [{ name: "fountain-apply", schedule: "*/10 * * * *", env: "staging", dial: "apply", dispatchTargets: [MUTATING_OP] }],
4101
- });
4102
- const role = p(result["role_fountain-apply"]) as any;
4103
- expect(role.rules.length).toBeGreaterThan(0);
4104
- for (const rule of role.rules) {
4105
- expect(rule.verbs).toEqual(["get", "list", "watch", "create", "update", "patch"]);
4106
- expect(rule.verbs).not.toContain("delete");
4107
- expect(rule.verbs).not.toContain("deletecollection");
4108
- expect(rule.verbs).not.toContain("*");
4109
- expect(rule.resources).not.toContain("*");
4110
- expect(rule.apiGroups).not.toContain("*");
4111
- }
4112
- });
4113
-
4114
- test("apply-dial ConvergeOp with only a read-only dispatch target stays read-only — least privilege, not dial-implied ceiling", () => {
4115
- const result: any = OperatorStack({
4116
- name: "chant-operator",
4117
- image: "chant:latest",
4118
- converge: [{ name: "fountain-verify", schedule: "*/10 * * * *", env: "staging", dial: "apply", dispatchTargets: [READ_ONLY_OP] }],
4119
- });
4120
- const role = p(result["role_fountain-verify"]) as any;
4121
- for (const rule of role.rules) {
4122
- expect(rule.verbs).toEqual(["get", "list", "watch"]);
4123
- }
4124
- });
4125
-
4126
- test("a destructive dispatch target is refused at construction, even under dial apply", () => {
4127
- expect(() =>
4128
- OperatorStack({
4129
- name: "chant-operator",
4130
- image: "chant:latest",
4131
- converge: [{ name: "fountain-teardown", schedule: "*/10 * * * *", env: "staging", dial: "apply", dispatchTargets: [DESTRUCTIVE_OP] }],
4132
- }),
4133
- ).toThrow(/destructive/);
4134
- });
4135
-
4136
- test("two hosts in the same stack get independently scoped RBAC — never the union", () => {
4137
- const result: any = OperatorStack({
4138
- name: "chant-operator",
4139
- image: "chant:latest",
4140
- converge: [
4141
- { name: "fountain-observe", schedule: "*/10 * * * *", env: "staging", dial: "observe" },
4142
- { name: "fountain-apply", schedule: "*/10 * * * *", env: "staging", dial: "apply", dispatchTargets: [MUTATING_OP] },
4143
- ],
4144
- });
4145
- expect((p(result["role_fountain-observe"]) as any).rules[0].verbs).toEqual(["get", "list", "watch"]);
4146
- expect((p(result["role_fountain-apply"]) as any).rules[0].verbs).toEqual(["get", "list", "watch", "create", "update", "patch"]);
4147
- });
4148
-
4149
- test("custom resource rules are used instead of the default set", () => {
4150
- const result: any = OperatorStack({
4151
- name: "chant-operator",
4152
- image: "chant:latest",
4153
- converge: [{
4154
- name: "fountain-secrets",
4155
- schedule: "*/10 * * * *",
4156
- env: "staging",
4157
- resources: [{ apiGroups: [""], resources: ["secrets"] }],
4158
- }],
4159
- });
4160
- const role = p(result["role_fountain-secrets"]) as any;
4161
- expect(role.rules).toEqual([{ apiGroups: [""], resources: ["secrets"], verbs: ["get", "list", "watch"] }]);
4162
- });
4163
-
4164
- // ── deriveHostVerbClass (unit) ───────────────────────────────────────
4165
-
4166
- test("deriveHostVerbClass: reconcile dial with a mutating target stays read-only", () => {
4167
- expect(deriveHostVerbClass("x", "reconcile", [MUTATING_OP])).toBe("read-only");
4168
- });
4169
-
4170
- test("deriveHostVerbClass: apply dial with a mutating target elevates to mutating", () => {
4171
- expect(deriveHostVerbClass("x", "apply", [MUTATING_OP])).toBe("mutating");
4172
- });
4173
-
4174
- test("deriveHostVerbClass: apply dial with only read-only targets stays read-only", () => {
4175
- expect(deriveHostVerbClass("x", "apply", [READ_ONLY_OP])).toBe("read-only");
4176
- });
4177
-
4178
- test("deriveHostVerbClass: a destructive target throws under any dial", () => {
4179
- expect(() => deriveHostVerbClass("x", "apply", [DESTRUCTIVE_OP])).toThrow(/destructive/);
4180
- expect(() => deriveHostVerbClass("x", "observe", [DESTRUCTIVE_OP])).toThrow(/destructive/);
4181
- });
4182
-
4183
- // #2192 — the refusal cites the rule that actually owns it (OPS014), and
4184
- // gives OPS014's own reason. The old message argued from the local
4185
- // executor's inability to honour a gate, which #2119 retired: a gated op
4186
- // now ends the run `gated` rather than being refused, so the refusal stands
4187
- // on the unattended-approval ground instead.
4188
- test("deriveHostVerbClass: the destructive refusal names OPS014 and the unattended-approval reason", () => {
4189
- expect(() => deriveHostVerbClass("x", "apply", [DESTRUCTIVE_OP])).toThrow(/OPS014/);
4190
- expect(() => deriveHostVerbClass("x", "apply", [DESTRUCTIVE_OP])).toThrow(/unattended/);
4191
- expect(() => deriveHostVerbClass("x", "apply", [DESTRUCTIVE_OP])).not.toThrow(/TMP014/);
4192
- });
4193
-
4194
- // ── Build-time refusals ──────────────────────────────────────────────
4195
-
4196
- test("refuses an empty converge array", () => {
4197
- expect(() => OperatorStack({ name: "chant-operator", image: "chant:latest", converge: [] })).toThrow(/at least one/);
4198
- });
4199
-
4200
- test("refuses duplicate hosted ConvergeOp names", () => {
4201
- expect(() =>
4202
- OperatorStack({
4203
- name: "chant-operator",
4204
- image: "chant:latest",
4205
- converge: [
4206
- { name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" },
4207
- { name: "fountain-observe", schedule: "*/5 * * * *", env: "staging" },
4208
- ],
4209
- }),
4210
- ).toThrow(/duplicate/);
4211
- });
4212
-
4213
- test("refuses a host with a blank schedule", () => {
4214
- expect(() =>
4215
- OperatorStack({
4216
- name: "chant-operator",
4217
- image: "chant:latest",
4218
- converge: [{ name: "fountain-observe", schedule: "", env: "staging" }],
4219
- }),
4220
- ).toThrow(/schedule is required/);
4221
- });
4222
-
4223
- // ── schedule validation (#2071 item 4) ────────────────────────────
4224
-
4225
- test("accepts a valid five-field schedule", () => {
4226
- expect(() =>
4227
- OperatorStack({
4228
- name: "chant-operator",
4229
- image: "chant:latest",
4230
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4231
- }),
4232
- ).not.toThrow();
4233
- });
4234
-
4235
- test("refuses a host with a 6-field (seconds) schedule, naming the field, the value, and the CronJob limit", () => {
4236
- expect(() =>
4237
- OperatorStack({
4238
- name: "chant-operator",
4239
- image: "chant:latest",
4240
- converge: [{ name: "fountain-observe", schedule: "0 */10 * * * *", env: "staging" }],
4241
- }),
4242
- ).toThrow(/schedule "0 \*\/10 \* \* \* \*" is 6-field cron.*five fields/s);
4243
- });
4244
-
4245
- test("refuses a host with a malformed schedule", () => {
4246
- expect(() =>
4247
- OperatorStack({
4248
- name: "chant-operator",
4249
- image: "chant:latest",
4250
- converge: [{ name: "fountain-observe", schedule: "not a cron", env: "staging" }],
4251
- }),
4252
- ).toThrow(/schedule "not a cron" is not valid cron syntax/);
4253
- });
4254
-
4255
- test("refuses a blank image", () => {
4256
- expect(() =>
4257
- OperatorStack({
4258
- name: "chant-operator",
4259
- image: "",
4260
- converge: [{ name: "fountain-observe", schedule: "*/10 * * * *", env: "staging" }],
4261
- }),
4262
- ).toThrow(/image/);
4263
- });
4264
- });
4265
-
4266
- describe("package index re-exports (regression guard)", () => {
4267
- test("Argo composites are reachable from the package entry", async () => {
4268
- const pkg: any = await import("../index");
4269
- expect(typeof pkg.ArgoAppFor).toBe("function");
4270
- expect(typeof pkg.ArgoAppSetForRegions).toBe("function");
4271
- expect(typeof pkg.registerArgoCluster).toBe("function");
4272
- });
4273
-
4274
- test("Flux composites are reachable from the package entry", async () => {
4275
- const pkg: any = await import("../index");
4276
- expect(typeof pkg.FluxGitSource).toBe("function");
4277
- expect(typeof pkg.FluxAppFor).toBe("function");
4278
- });
4279
-
4280
- test("Model is reachable from the package entry", async () => {
4281
- const pkg: any = await import("../index");
4282
- expect(typeof pkg.Model).toBe("function");
4283
- expect(typeof pkg.resolveModelStorageUri).toBe("function");
4284
- });
4285
-
4286
- test("OperatorStack is reachable from the package entry", async () => {
4287
- const pkg: any = await import("../index");
4288
- expect(typeof pkg.OperatorStack).toBe("function");
4289
- expect(typeof pkg.deriveHostVerbClass).toBe("function");
4290
- });
4291
- });