@intentius/chant-lexicon-pulumi 0.124.98 → 0.124.99

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 (316) hide show
  1. package/dist/adopt.d.ts +0 -1
  2. package/dist/capability-plugin.d.ts +0 -1
  3. package/dist/change-set.d.ts +0 -1
  4. package/dist/changed-units.d.ts +0 -1
  5. package/dist/check-step.d.ts +0 -1
  6. package/dist/ci-setup.d.ts +0 -1
  7. package/dist/codegen/docs-cli.d.ts +0 -1
  8. package/dist/codegen/docs.d.ts +0 -1
  9. package/dist/codegen/package.d.ts +0 -1
  10. package/dist/composites/pulumi-adopt-op.d.ts +0 -1
  11. package/dist/composites/pulumi-watch-op.d.ts +0 -1
  12. package/dist/config.d.ts +0 -1
  13. package/dist/describe-resources.d.ts +0 -1
  14. package/dist/drift-read.d.ts +0 -1
  15. package/dist/drift-record.d.ts +0 -1
  16. package/dist/engine-events.d.ts +0 -1
  17. package/dist/engine-graph.d.ts +0 -1
  18. package/dist/exit-codes.d.ts +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/init-templates.d.ts +0 -1
  21. package/dist/integrity.json +2 -2
  22. package/dist/lint/audit-catalog.d.ts +0 -1
  23. package/dist/lint/post-synth/index.d.ts +0 -1
  24. package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
  25. package/dist/lint/post-synth/pul001.d.ts +0 -1
  26. package/dist/lint/post-synth/pul002.d.ts +0 -1
  27. package/dist/lint/post-synth/pul003.d.ts +0 -1
  28. package/dist/lint/post-synth/pul004.d.ts +0 -1
  29. package/dist/lint/post-synth/pul005.d.ts +0 -1
  30. package/dist/lint/post-synth/pul006.d.ts +0 -1
  31. package/dist/lint/post-synth/pul007.d.ts +0 -1
  32. package/dist/lint/post-synth/pul008.d.ts +0 -1
  33. package/dist/lint/post-synth/pul009.d.ts +0 -1
  34. package/dist/lint/post-synth/pul010.d.ts +0 -1
  35. package/dist/lint/post-synth/pul011.d.ts +0 -1
  36. package/dist/lint/post-synth/pul012.d.ts +0 -1
  37. package/dist/lint/post-synth/pul013.d.ts +0 -1
  38. package/dist/lint/post-synth/pul014.d.ts +0 -1
  39. package/dist/lint/post-synth/pul015.d.ts +0 -1
  40. package/dist/lint/rules/index.d.ts +0 -1
  41. package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
  42. package/dist/lock-rows.d.ts +0 -1
  43. package/dist/lsp/completions.d.ts +0 -1
  44. package/dist/lsp/documents.d.ts +0 -1
  45. package/dist/lsp/hover.d.ts +0 -1
  46. package/dist/lsp/keys.d.ts +0 -1
  47. package/dist/lsp/object-path.d.ts +0 -1
  48. package/dist/lsp/yaml-cursor.d.ts +0 -1
  49. package/dist/manifest.json +1 -1
  50. package/dist/member-engine.d.ts +0 -1
  51. package/dist/member-outputs.d.ts +0 -1
  52. package/dist/op/activities/index.d.ts +0 -1
  53. package/dist/op/activities/pulumi-adopt.d.ts +0 -1
  54. package/dist/op/activities/pulumi.d.ts +0 -1
  55. package/dist/op/activity-contracts.d.ts +0 -1
  56. package/dist/op/builders.d.ts +0 -1
  57. package/dist/package-cli.d.ts +0 -1
  58. package/dist/plan-shape.d.ts +0 -1
  59. package/dist/planned-output-changes.d.ts +0 -1
  60. package/dist/plugin.d.ts +0 -1
  61. package/dist/plunge-timings.d.ts +0 -1
  62. package/dist/preview-tips.d.ts +0 -1
  63. package/dist/pulumi-up.d.ts +0 -1
  64. package/dist/release-copy.d.ts +0 -1
  65. package/dist/review-stack.d.ts +0 -1
  66. package/dist/run.d.ts +0 -1
  67. package/dist/serializer.d.ts +0 -1
  68. package/dist/stack-export-snapshot.d.ts +0 -1
  69. package/dist/stack-ops.d.ts +0 -1
  70. package/dist/stack-outputs.d.ts +0 -1
  71. package/dist/stack-references.d.ts +0 -1
  72. package/dist/trace-facts.d.ts +0 -1
  73. package/dist/values.d.ts +0 -1
  74. package/dist/workspace-member.d.ts +0 -1
  75. package/package.json +3 -4
  76. package/dist/adopt.d.ts.map +0 -1
  77. package/dist/capability-plugin.d.ts.map +0 -1
  78. package/dist/change-set.d.ts.map +0 -1
  79. package/dist/changed-units.d.ts.map +0 -1
  80. package/dist/check-step.d.ts.map +0 -1
  81. package/dist/ci-setup.d.ts.map +0 -1
  82. package/dist/codegen/docs-cli.d.ts.map +0 -1
  83. package/dist/codegen/docs.d.ts.map +0 -1
  84. package/dist/codegen/package.d.ts.map +0 -1
  85. package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
  86. package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
  87. package/dist/config.d.ts.map +0 -1
  88. package/dist/describe-resources.d.ts.map +0 -1
  89. package/dist/drift-read.d.ts.map +0 -1
  90. package/dist/drift-record.d.ts.map +0 -1
  91. package/dist/engine-events.d.ts.map +0 -1
  92. package/dist/engine-graph.d.ts.map +0 -1
  93. package/dist/exit-codes.d.ts.map +0 -1
  94. package/dist/index.d.ts.map +0 -1
  95. package/dist/init-templates.d.ts.map +0 -1
  96. package/dist/lint/audit-catalog.d.ts.map +0 -1
  97. package/dist/lint/post-synth/index.d.ts.map +0 -1
  98. package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
  99. package/dist/lint/post-synth/pul001.d.ts.map +0 -1
  100. package/dist/lint/post-synth/pul002.d.ts.map +0 -1
  101. package/dist/lint/post-synth/pul003.d.ts.map +0 -1
  102. package/dist/lint/post-synth/pul004.d.ts.map +0 -1
  103. package/dist/lint/post-synth/pul005.d.ts.map +0 -1
  104. package/dist/lint/post-synth/pul006.d.ts.map +0 -1
  105. package/dist/lint/post-synth/pul007.d.ts.map +0 -1
  106. package/dist/lint/post-synth/pul008.d.ts.map +0 -1
  107. package/dist/lint/post-synth/pul009.d.ts.map +0 -1
  108. package/dist/lint/post-synth/pul010.d.ts.map +0 -1
  109. package/dist/lint/post-synth/pul011.d.ts.map +0 -1
  110. package/dist/lint/post-synth/pul012.d.ts.map +0 -1
  111. package/dist/lint/post-synth/pul013.d.ts.map +0 -1
  112. package/dist/lint/post-synth/pul014.d.ts.map +0 -1
  113. package/dist/lint/post-synth/pul015.d.ts.map +0 -1
  114. package/dist/lint/rules/index.d.ts.map +0 -1
  115. package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
  116. package/dist/lock-rows.d.ts.map +0 -1
  117. package/dist/lsp/completions.d.ts.map +0 -1
  118. package/dist/lsp/documents.d.ts.map +0 -1
  119. package/dist/lsp/hover.d.ts.map +0 -1
  120. package/dist/lsp/keys.d.ts.map +0 -1
  121. package/dist/lsp/object-path.d.ts.map +0 -1
  122. package/dist/lsp/yaml-cursor.d.ts.map +0 -1
  123. package/dist/member-engine.d.ts.map +0 -1
  124. package/dist/member-outputs.d.ts.map +0 -1
  125. package/dist/op/activities/index.d.ts.map +0 -1
  126. package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
  127. package/dist/op/activities/pulumi.d.ts.map +0 -1
  128. package/dist/op/activity-contracts.d.ts.map +0 -1
  129. package/dist/op/builders.d.ts.map +0 -1
  130. package/dist/package-cli.d.ts.map +0 -1
  131. package/dist/plan-shape.d.ts.map +0 -1
  132. package/dist/planned-output-changes.d.ts.map +0 -1
  133. package/dist/plugin.d.ts.map +0 -1
  134. package/dist/plunge-timings.d.ts.map +0 -1
  135. package/dist/preview-tips.d.ts.map +0 -1
  136. package/dist/pulumi-up.d.ts.map +0 -1
  137. package/dist/release-copy.d.ts.map +0 -1
  138. package/dist/review-stack.d.ts.map +0 -1
  139. package/dist/run.d.ts.map +0 -1
  140. package/dist/serializer.d.ts.map +0 -1
  141. package/dist/stack-export-snapshot.d.ts.map +0 -1
  142. package/dist/stack-ops.d.ts.map +0 -1
  143. package/dist/stack-outputs.d.ts.map +0 -1
  144. package/dist/stack-references.d.ts.map +0 -1
  145. package/dist/trace-facts.d.ts.map +0 -1
  146. package/dist/values.d.ts.map +0 -1
  147. package/dist/workspace-member.d.ts.map +0 -1
  148. package/src/adopt.ts +0 -202
  149. package/src/capability-plugin.ts +0 -34
  150. package/src/change-set.test.ts +0 -245
  151. package/src/change-set.ts +0 -508
  152. package/src/changed-units.test.ts +0 -87
  153. package/src/changed-units.ts +0 -96
  154. package/src/check-step.test.ts +0 -191
  155. package/src/check-step.ts +0 -316
  156. package/src/ci-setup.test.ts +0 -234
  157. package/src/ci-setup.ts +0 -224
  158. package/src/codegen/docs-cli.ts +0 -4
  159. package/src/codegen/docs.ts +0 -58
  160. package/src/codegen/package.ts +0 -63
  161. package/src/composites/pulumi-adopt-op.test.ts +0 -258
  162. package/src/composites/pulumi-adopt-op.ts +0 -193
  163. package/src/composites/pulumi-watch-op.test.ts +0 -42
  164. package/src/composites/pulumi-watch-op.ts +0 -85
  165. package/src/config.ts +0 -43
  166. package/src/describe-resources.test.ts +0 -112
  167. package/src/describe-resources.ts +0 -118
  168. package/src/drift-read.test.ts +0 -178
  169. package/src/drift-read.ts +0 -94
  170. package/src/drift-record.test.ts +0 -197
  171. package/src/drift-record.ts +0 -326
  172. package/src/engine-events.test.ts +0 -160
  173. package/src/engine-events.ts +0 -395
  174. package/src/engine-graph.test.ts +0 -141
  175. package/src/engine-graph.ts +0 -149
  176. package/src/exit-codes.test.ts +0 -21
  177. package/src/exit-codes.ts +0 -71
  178. package/src/index.ts +0 -139
  179. package/src/init-templates.ts +0 -85
  180. package/src/lint/audit-catalog.test.ts +0 -33
  181. package/src/lint/audit-catalog.ts +0 -174
  182. package/src/lint/post-synth/index.ts +0 -35
  183. package/src/lint/post-synth/member-read-helpers.ts +0 -122
  184. package/src/lint/post-synth/post-synth.test.ts +0 -245
  185. package/src/lint/post-synth/pul001.ts +0 -38
  186. package/src/lint/post-synth/pul002.ts +0 -38
  187. package/src/lint/post-synth/pul003.ts +0 -43
  188. package/src/lint/post-synth/pul004.ts +0 -32
  189. package/src/lint/post-synth/pul005.ts +0 -31
  190. package/src/lint/post-synth/pul006.ts +0 -31
  191. package/src/lint/post-synth/pul007.ts +0 -35
  192. package/src/lint/post-synth/pul008.ts +0 -35
  193. package/src/lint/post-synth/pul009.ts +0 -32
  194. package/src/lint/post-synth/pul010.ts +0 -42
  195. package/src/lint/post-synth/pul011.ts +0 -38
  196. package/src/lint/post-synth/pul012.ts +0 -35
  197. package/src/lint/post-synth/pul013.ts +0 -35
  198. package/src/lint/post-synth/pul014.ts +0 -32
  199. package/src/lint/post-synth/pul015.ts +0 -39
  200. package/src/lint/rules/index.ts +0 -7
  201. package/src/lint/rules/member-dir-absolute.test.ts +0 -37
  202. package/src/lint/rules/member-dir-absolute.ts +0 -83
  203. package/src/lock-rows.test.ts +0 -60
  204. package/src/lock-rows.ts +0 -56
  205. package/src/lsp/completions.test.ts +0 -69
  206. package/src/lsp/completions.ts +0 -119
  207. package/src/lsp/documents.ts +0 -48
  208. package/src/lsp/hover.test.ts +0 -56
  209. package/src/lsp/hover.ts +0 -83
  210. package/src/lsp/keys.ts +0 -169
  211. package/src/lsp/object-path.ts +0 -71
  212. package/src/lsp/yaml-cursor.ts +0 -85
  213. package/src/member-engine.test.ts +0 -112
  214. package/src/member-engine.ts +0 -97
  215. package/src/member-outputs.test.ts +0 -339
  216. package/src/member-outputs.ts +0 -157
  217. package/src/op/activities/index.ts +0 -36
  218. package/src/op/activities/pulumi-adopt.ts +0 -345
  219. package/src/op/activities/pulumi.ts +0 -136
  220. package/src/op/activity-contracts.ts +0 -129
  221. package/src/op/builders.ts +0 -67
  222. package/src/package-cli.ts +0 -14
  223. package/src/plan-shape.test.ts +0 -91
  224. package/src/plan-shape.ts +0 -105
  225. package/src/planned-output-changes.test.ts +0 -85
  226. package/src/planned-output-changes.ts +0 -141
  227. package/src/plugin.test.ts +0 -96
  228. package/src/plugin.ts +0 -272
  229. package/src/plunge-timings.test.ts +0 -241
  230. package/src/plunge-timings.ts +0 -115
  231. package/src/plunge-up-failed.test.ts +0 -54
  232. package/src/pr-note.test.ts +0 -87
  233. package/src/preview-generated.test.ts +0 -124
  234. package/src/preview-tips.test.ts +0 -134
  235. package/src/preview-tips.ts +0 -128
  236. package/src/pulumi-up.test.ts +0 -581
  237. package/src/pulumi-up.ts +0 -1102
  238. package/src/pulumi-urn-node.test.ts +0 -94
  239. package/src/release-copy.test.ts +0 -162
  240. package/src/release-copy.ts +0 -223
  241. package/src/review-stack.test.ts +0 -254
  242. package/src/review-stack.ts +0 -266
  243. package/src/run-plan-flags.test.ts +0 -53
  244. package/src/run.test.ts +0 -540
  245. package/src/run.ts +0 -1129
  246. package/src/serializer.test.ts +0 -9
  247. package/src/serializer.ts +0 -15
  248. package/src/skills/chant-pulumi-plunge.md +0 -51
  249. package/src/skills/chant-pulumi-stack-export.md +0 -54
  250. package/src/skills/chant-pulumi.md +0 -83
  251. package/src/stack-export-snapshot.test.ts +0 -192
  252. package/src/stack-export-snapshot.ts +0 -312
  253. package/src/stack-ops.fake-binary.test.ts +0 -323
  254. package/src/stack-ops.test.ts +0 -511
  255. package/src/stack-ops.ts +0 -1082
  256. package/src/stack-outputs.ts +0 -66
  257. package/src/stack-references.test.ts +0 -96
  258. package/src/stack-references.ts +0 -110
  259. package/src/testdata/plunge-drift/README.md +0 -10
  260. package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
  261. package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
  262. package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
  263. package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
  264. package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
  265. package/src/testdata/plunge-graph/README.md +0 -12
  266. package/src/testdata/plunge-graph/engine-graph.json +0 -158
  267. package/src/testdata/plunge-graph/stack-export.json +0 -49
  268. package/src/testdata/plunge-member/Pulumi.yaml +0 -4
  269. package/src/testdata/plunge-member/README.md +0 -3
  270. package/src/testdata/plunge-member/stack-export.json +0 -480
  271. package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
  272. package/src/testdata/plunge-outputs/README.md +0 -7
  273. package/src/testdata/plunge-outputs/stack-export.json +0 -2003
  274. package/src/testdata/plunge-outputs/stack-output.json +0 -19
  275. package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
  276. package/src/testdata/pulumi-member/README.md +0 -50
  277. package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
  278. package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
  279. package/src/testdata/pulumi-member/recording/index.js +0 -47
  280. package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
  281. package/src/testdata/pulumi-member/recording/package.json +0 -9
  282. package/src/testdata/pulumi-member/stack-export.json +0 -746
  283. package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
  284. package/src/testdata/pulumi-outputs/README.md +0 -9
  285. package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
  286. package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
  287. package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
  288. package/src/testdata/pulumi-outputs/stack-output.json +0 -19
  289. package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
  290. package/src/testdata/pulumi-preview/README.md +0 -9
  291. package/src/testdata/pulumi-preview/preview-create.json +0 -992
  292. package/src/testdata/pulumi-preview/preview.json +0 -2894
  293. package/src/testdata/pulumi-preview/stack-export.json +0 -1919
  294. package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
  295. package/src/testdata/pulumi-refresh/README.md +0 -14
  296. package/src/testdata/pulumi-refresh/all.json +0 -3742
  297. package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
  298. package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
  299. package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
  300. package/src/testdata/pulumi-refresh/role-same.json +0 -242
  301. package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
  302. package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
  303. package/src/testdata/pulumi-stream/README.md +0 -16
  304. package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
  305. package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
  306. package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
  307. package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
  308. package/src/testdata/pulumi-urn-node/README.md +0 -9
  309. package/src/testdata/pulumi-urn-node/preview.json +0 -2894
  310. package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
  311. package/src/trace-facts.test.ts +0 -38
  312. package/src/trace-facts.ts +0 -83
  313. package/src/values.ts +0 -147
  314. package/src/workspace-kinds.test.ts +0 -47
  315. package/src/workspace-member.test.ts +0 -127
  316. package/src/workspace-member.ts +0 -304
@@ -1,258 +0,0 @@
1
- /**
2
- * PulumiAdoptOp (#4562) and its activities. The adopt documents are built
3
- * from plunge's `AdoptView` (`pkg/backend/plunge`, fields as its JSON tags
4
- * spell them), not recorded; a floci recording of `plunge stack adopt
5
- * --json` replaces them when the epic's runs are made. The runners and the
6
- * bucket check are fakes, so no binary runs and no bucket is read.
7
- */
8
- import { mkdtempSync, readFileSync, statSync, writeFileSync } from "node:fs";
9
- import { tmpdir } from "node:os";
10
- import { join } from "node:path";
11
- import { describe, expect, test } from "vitest";
12
- import { validateActivitySteps, type ActivityContract, type ActivityStep, type GateStep, type OpConfig } from "@intentius/chant/op";
13
- import type { BucketReport } from "@intentius/chant/bucket-check";
14
- import { adoptBucketTarget, parsePlungeAdoptView, pulumiAdoptDigest } from "../adopt";
15
- import { PulumiAdoptOp } from "./pulumi-adopt-op";
16
- import {
17
- pulumiAdoptCheckContract,
18
- pulumiAdoptContract,
19
- pulumiAdoptExportContract,
20
- pulumiAdoptPreviewContract,
21
- } from "../op/activity-contracts";
22
- import { adoptCheck, adoptExport, adoptPreview, adoptStack } from "../op/activities/pulumi-adopt";
23
- import type { PulumiRunner } from "../run";
24
-
25
- const exportText = readFileSync(join(import.meta.dirname, "..", "testdata", "pulumi-preview", "stack-export.json"), "utf-8");
26
-
27
- const urn = (type: string, name: string) => `urn:pulumi:dev::shop::${type}::${name}`;
28
- const view = (status: string, extra: Record<string, unknown> = {}) =>
29
- JSON.stringify({
30
- adopt: "v1",
31
- stack: "organization/shop/dev",
32
- status,
33
- checkpoint: { source: "the DIY checkpoint", digest: "sha256:abc" },
34
- resources: [
35
- { urn: urn("aws:s3/bucketV2:BucketV2", "assets"), type: "aws:s3/bucketV2:BucketV2", id: "assets-123", fate: "pending", marked: false, reason: "adoption loads no provider schema" },
36
- { urn: urn("aws:iam/role:Role", "app"), type: "aws:iam/role:Role", id: "app-role", fate: "pending", marked: false },
37
- ],
38
- refusals: [],
39
- ...extra,
40
- });
41
-
42
- function props(config: Parameters<typeof PulumiAdoptOp>[0]): OpConfig {
43
- return (PulumiAdoptOp(config).op as unknown as { props: OpConfig }).props;
44
- }
45
-
46
- const contracts = new Map<string, ActivityContract>([
47
- ["pulumiAdoptCheck", pulumiAdoptCheckContract],
48
- ["pulumiAdoptExport", pulumiAdoptExportContract],
49
- ["pulumiAdoptPreview", pulumiAdoptPreviewContract],
50
- ["pulumiAdopt", pulumiAdoptContract],
51
- ]);
52
-
53
- describe("PulumiAdoptOp", () => {
54
- test("one stack: Check, Export, Preview, a gate bound to the preview's digest, Adopt", () => {
55
- const op = props({ name: "adopt-infra", stacks: [{ member: "infra", dir: "./infra", stack: "dev" }] });
56
- expect(op.phases.map((p) => p.name)).toEqual(["Check", "Export", "Preview", "Gate", "Adopt"]);
57
- const gate = op.phases[3]!.steps[0] as GateStep;
58
- expect(gate.gate).toBe("approve-adopt-infra");
59
- expect(gate.plan).toMatchObject({ step: "preview-0", path: "planDigest" });
60
- const adopt = op.phases[4]!.steps[0] as ActivityStep;
61
- expect(adopt.fn).toBe("pulumiAdopt");
62
- expect(adopt.args?.file).toBeUndefined();
63
- expect(op.labels).toMatchObject({ Adopt: "true", Surface: "pulumi-adopt" });
64
- });
65
-
66
- test("several stacks: one wave each, a gate per stack", () => {
67
- const op = props({
68
- name: "adopt",
69
- stacks: [
70
- { member: "net", dir: "./net", stack: "prod" },
71
- { member: "app", dir: "./app", stack: "prod", from: { backend: "https://api.pulumi.com" } },
72
- ],
73
- });
74
- expect(op.phases.map((p) => p.name)).toEqual(["Check", "Export", "Preview net/prod", "Gate net/prod", "Adopt net/prod", "Preview app/prod", "Gate app/prod", "Adopt app/prod"]);
75
- expect(op.phases[0]!.steps).toHaveLength(2);
76
- expect((op.phases[3]!.steps[0] as GateStep).gate).toBe("approve-adopt-net-prod");
77
- // The route from Pulumi Cloud adopts the Export step's file.
78
- const preview = op.phases[5]!.steps[0] as ActivityStep;
79
- expect(preview.args?.file).toMatchObject({ step: "export-1", path: "file" });
80
- });
81
-
82
- test("the stack's backend reaches all four steps, Preview and Adopt included", () => {
83
- const backend = "plunge+s3://state?region=us-east-1";
84
- const op = props({
85
- name: "adopt",
86
- stacks: [
87
- { member: "infra", dir: "./infra", stack: "dev", backend },
88
- { member: "web", dir: "./web", stack: "dev" },
89
- ],
90
- });
91
- const steps = op.phases.flatMap((p) => p.steps as ActivityStep[]).filter((s) => s.fn?.startsWith("pulumiAdopt"));
92
- const infra = steps.filter((s) => s.args?.member === "infra");
93
- expect(infra.map((s) => s.fn)).toEqual(["pulumiAdoptCheck", "pulumiAdoptExport", "pulumiAdoptPreview", "pulumiAdopt"]);
94
- for (const s of infra) expect(s.args?.backend).toBe(backend);
95
- // A stack without one leaves each step to resolve it (plywood.yml, PULUMI_BACKEND_URL, Pulumi.yaml).
96
- for (const s of steps.filter((s) => s.args?.member === "web")) expect(s.args?.backend).toBeUndefined();
97
- });
98
-
99
- test("its steps validate against the activities' contracts", () => {
100
- const op = props({
101
- name: "adopt",
102
- stacks: [
103
- { member: "infra", dir: "./infra", stack: "dev", backend: "plunge+s3://state?region=us-east-1", allowInsecure: ["lifecycle"] },
104
- { member: "web", dir: "./web", stack: "dev", from: { file: "./web/dev.json" } },
105
- ],
106
- });
107
- expect(validateActivitySteps(op, contracts)).toEqual([]);
108
- });
109
-
110
- test("compensate without a command, an empty list and a stack listed twice are refused when built", () => {
111
- expect(() => props({ name: "a", stacks: [{ member: "m", dir: ".", stack: "s" }], compensate: true })).toThrow(/no automatic undo/);
112
- expect(() => props({ name: "a", stacks: [] })).toThrow(/stacks is empty/);
113
- expect(() => props({ name: "a", stacks: [{ member: "m", dir: ".", stack: "s" }, { member: "m", dir: "./x", stack: "s" }] })).toThrow(/listed twice/);
114
- });
115
- });
116
-
117
- describe("the adopt document and its digest", () => {
118
- test("the digest ignores status, so the approved preview and the --yes run agree", () => {
119
- const preview = parsePlungeAdoptView(view("would-adopt"))!;
120
- const adopted = parsePlungeAdoptView(view("adopted"))!;
121
- expect(pulumiAdoptDigest(preview)).toBe(pulumiAdoptDigest(adopted));
122
- });
123
-
124
- test("a changed checkpoint or resource moves it", () => {
125
- const base = pulumiAdoptDigest(parsePlungeAdoptView(view("would-adopt"))!);
126
- expect(pulumiAdoptDigest(parsePlungeAdoptView(view("would-adopt", { checkpoint: { digest: "sha256:def" } }))!)).not.toBe(base);
127
- expect(parsePlungeAdoptView("not json")).toBeUndefined();
128
- expect(parsePlungeAdoptView(JSON.stringify({ status: "maybe" }))).toBeUndefined();
129
- });
130
- });
131
-
132
- describe("the bucket target from the backend URL", () => {
133
- test("s3 gives bucket, region and the path as namespace; an endpoint needs static keys", () => {
134
- expect(adoptBucketTarget("plunge+s3://state/stacks?region=us-east-1&allow_insecure=lifecycle", {})).toEqual({
135
- target: { store: "s3", bucket: "state", region: "us-east-1" },
136
- namespaces: ["stacks/"],
137
- waived: ["lifecycle"],
138
- });
139
- expect(adoptBucketTarget("plunge+s3://state?region=us-east-1&endpoint=http://localhost:4566", {})).toMatchObject({ refuse: expect.stringMatching(/static keys/) });
140
- expect(
141
- adoptBucketTarget("plunge+s3://state?region=us-east-1&endpoint=http://localhost:4566", { AWS_ACCESS_KEY_ID: "test", AWS_SECRET_ACCESS_KEY: "test" }),
142
- ).toMatchObject({ target: { endpoint: "http://localhost:4566", credentials: { accessKeyId: "test" } } });
143
- expect(adoptBucketTarget("plunge+s3://state", {})).toMatchObject({ refuse: expect.stringMatching(/no region/) });
144
- });
145
-
146
- test("file is skipped, azblob is refused without a bucket, gs is read", () => {
147
- expect(adoptBucketTarget("plunge+file:///tmp/state", {})).toMatchObject({ skip: expect.stringMatching(/no bucket/) });
148
- expect(adoptBucketTarget("plunge+azblob://state", {})).toMatchObject({ refuse: expect.stringMatching(/subscription/) });
149
- expect(adoptBucketTarget("plunge+gs://state", { PLUNGE_ALLOW_INSECURE: "object_versioning" })).toMatchObject({ target: { store: "gcs", bucket: "state" }, waived: ["object_versioning"] });
150
- });
151
- });
152
-
153
- function report(verdicts: Record<string, "ok" | "fail">, unwaivable: string[] = []): BucketReport {
154
- return {
155
- store: "s3",
156
- bucket: "state",
157
- namespaces: [],
158
- correct: Object.values(verdicts).every((v) => v === "ok"),
159
- settings: Object.entries(verdicts).map(([setting, verdict]) => ({
160
- setting: setting as BucketReport["settings"][number]["setting"],
161
- verdict,
162
- found: `${setting} is ${verdict}`,
163
- unwaivable: unwaivable.includes(setting),
164
- ...(verdict === "fail" ? { fix: `fix ${setting}` } : {}),
165
- })),
166
- };
167
- }
168
-
169
- describe("the activities", () => {
170
- const stack = { member: "infra", dir: "/tmp", stack: "dev" };
171
-
172
- test("check refuses a failing setting by name with its fix, honours a waiver, never an unwaivable one", async () => {
173
- const failing = async () => report({ versioning: "ok", lifecycle: "fail", public_access_block: "ok" });
174
- const args = { ...stack, backend: "plunge+s3://state?region=us-east-1" };
175
- await expect(adoptCheck(args, { env: {}, checkBucket: failing })).rejects.toThrow(/refusing to adopt "infra\/dev".*lifecycle \(fail\).*fix lifecycle/);
176
- expect(await adoptCheck({ ...args, allowInsecure: ["lifecycle"] }, { env: {}, checkBucket: failing })).toMatchObject({ checked: true, waived: ["lifecycle"] });
177
- const current = async () => report({ versioning: "ok", lifecycle: "fail", public_access_block: "ok" }, ["lifecycle"]);
178
- await expect(adoptCheck({ ...args, allowInsecure: ["lifecycle"] }, { env: {}, checkBucket: current })).rejects.toThrow(/no waiver reaches it/);
179
- expect(await adoptCheck({ ...stack, backend: "plunge+file:///tmp/s" }, { env: {} })).toMatchObject({ checked: false });
180
- });
181
-
182
- test("export runs stock pulumi stack export against the stock root and keeps it mode 600", async () => {
183
- const calls: { args: string[]; env?: Record<string, string> }[] = [];
184
- const run: PulumiRunner = async (args, opts) => {
185
- calls.push({ args, ...(opts.env ? { env: opts.env } : {}) });
186
- return { stdout: exportText };
187
- };
188
- const tmp = mkdtempSync(join(tmpdir(), "adopt-test-"));
189
- const out = await adoptExport({ ...stack, backend: "plunge+s3://state?region=us-east-1" }, { run, env: {}, tmp });
190
- expect(calls).toEqual([{ args: ["stack", "export", "--stack", "dev"], env: { PULUMI_BACKEND_URL: "s3://state?region=us-east-1" } }]);
191
- expect(out).toMatchObject({ adoptFromFile: false, source: "s3://state?region=us-east-1" });
192
- expect(out.resources).toBeGreaterThan(0);
193
- expect(statSync(out.file).mode & 0o777).toBe(0o600);
194
- expect(readFileSync(out.file, "utf-8")).toBe(exportText);
195
- });
196
-
197
- test("export from Pulumi Cloud adopts from the file, and a given file runs nothing", async () => {
198
- const calls: { env?: Record<string, string> }[] = [];
199
- const run: PulumiRunner = async (_args, opts) => {
200
- calls.push(opts.env ? { env: opts.env } : {});
201
- return { stdout: exportText };
202
- };
203
- const tmp = mkdtempSync(join(tmpdir(), "adopt-test-"));
204
- expect(await adoptExport({ ...stack, from: { backend: "https://api.pulumi.com" } }, { run, env: {}, tmp })).toMatchObject({ adoptFromFile: true });
205
- expect(calls).toEqual([{ env: { PULUMI_BACKEND_URL: "https://api.pulumi.com" } }]);
206
- const given = join(tmp, "given.json");
207
- writeFileSync(given, exportText);
208
- expect(await adoptExport({ ...stack, from: { file: given } }, { run, env: {}, tmp })).toMatchObject({ file: given, source: "file", adoptFromFile: true });
209
- expect(calls).toHaveLength(1);
210
- });
211
-
212
- test("preview runs plunge stack adopt --json and fails on a refusal, naming it", async () => {
213
- const seen: string[][] = [];
214
- const ok: PulumiRunner = async (args) => {
215
- seen.push(args);
216
- return { stdout: view("would-adopt") };
217
- };
218
- const out = await adoptPreview({ ...stack, file: "/tmp/s.json" }, { plunge: ok });
219
- expect(seen).toEqual([["stack", "adopt", "--json", "--stack", "dev", "--file", "/tmp/s.json"]]);
220
- expect(out).toMatchObject({ status: "would-adopt", resources: 2, fates: { pending: 2 }, changed: true });
221
- const refused: PulumiRunner = async () => {
222
- throw Object.assign(new Error("exit 255"), { code: 255, stdout: view("refused", { refusals: [{ code: "pending-operations", reason: "the checkpoint has 1 pending operation" }] }) });
223
- };
224
- await expect(adoptPreview(stack, { plunge: refused })).rejects.toThrow(/pending-operations: the checkpoint has 1 pending operation\. Nothing was written/);
225
- });
226
-
227
- test("preview and adopt hand plunge the stack's backend, resolved as the Check step resolves it", async () => {
228
- const envs: (Record<string, string> | undefined)[] = [];
229
- const plunge: PulumiRunner = async (_args, opts) => {
230
- envs.push(opts.env);
231
- return { stdout: view("would-adopt") };
232
- };
233
- const backend = "plunge+s3://state?region=us-east-1";
234
- await adoptPreview({ ...stack, backend }, { plunge, env: { PULUMI_BACKEND_URL: "file:///tmp/elsewhere" } });
235
- await adoptStack({ ...stack, backend }, { plunge, env: { PULUMI_BACKEND_URL: "file:///tmp/elsewhere" } });
236
- expect(envs).toEqual([{ PULUMI_BACKEND_URL: backend }, { PULUMI_BACKEND_URL: backend }]);
237
- // With no step backend, the environment's is the one named.
238
- envs.length = 0;
239
- const dir = mkdtempSync(join(tmpdir(), "adopt-test-"));
240
- await adoptPreview({ ...stack, dir }, { plunge, env: { PULUMI_BACKEND_URL: "plunge+file:///tmp/s" } });
241
- await adoptPreview({ ...stack, dir }, { plunge, env: {} });
242
- expect(envs).toEqual([{ PULUMI_BACKEND_URL: "plunge+file:///tmp/s" }, undefined]);
243
- });
244
-
245
- test("adopt runs the --yes form and says whether it matched the approved digest", async () => {
246
- const seen: string[][] = [];
247
- const plunge: PulumiRunner = async (args) => {
248
- seen.push(args);
249
- return { stdout: view("adopted") };
250
- };
251
- const approved = pulumiAdoptDigest(parsePlungeAdoptView(view("would-adopt"))!);
252
- const out = await adoptStack({ ...stack, planDigest: approved }, { plunge });
253
- expect(seen).toEqual([["stack", "adopt", "--json", "--yes", "--stack", "dev"]]);
254
- expect(out).toMatchObject({ status: "adopted", matchesApproved: true });
255
- const again = await adoptStack({ ...stack, planDigest: "sha256:other" }, { plunge: async () => ({ stdout: view("already-adopted") }) });
256
- expect(again).toMatchObject({ changed: false, matchesApproved: false });
257
- });
258
- });
@@ -1,193 +0,0 @@
1
- /**
2
- * PulumiAdoptOp composite (#4562): adopt stock Pulumi stacks onto plunge's
3
- * per-resource records, behind a gate, the pulumi twin of the terraform
4
- * lexicon's `TerraformAdoptOp`. It is the step after `plywood init --engine
5
- * plunge` (INTENTIUS/plywood#3); plywood supplies the words.
6
- *
7
- * plunge refuses a stock checkpoint with no records (`AdoptionRequiredError`)
8
- * rather than recreate everything, so a stack moves to plunge by `plunge
9
- * stack adopt`. Adoption writes one record per resource with the
10
- * checkpoint's IDs and calls no cloud API; the next `plunge up` adds the
11
- * `plunge-stack` and `plunge-urn` tags in place.
12
- *
13
- * Phases:
14
- *
15
- * - **Check**: the shared bucket check (#4558) on each stack's backend
16
- * bucket. A setting that fails, not waived, refuses the run before
17
- * anything is exported, naming the fix. A `file://` backend is skipped.
18
- * - **Export**: each stack's stock checkpoint, `pulumi stack export
19
- * --stack <s>`, kept in a scratch file. It is the back-out copy (`pulumi
20
- * stack import --file` on a stock backend), and on the route from Pulumi
21
- * Cloud (`from: { backend }`) or from an export taken by hand (`from: {
22
- * file }`) it is what plunge adopts with `--file`.
23
- * - Then one wave per stack, in the order given: **Preview** runs `plunge
24
- * stack adopt --json` (writes nothing), the **gate** binds that preview's
25
- * `planDigest`, and **Adopt** runs `plunge stack adopt --json --yes`. A
26
- * stack whose checkpoint changed after approval previews a new digest,
27
- * and the old approval does not open the gate for it.
28
- *
29
- * Every gate is a fact on the workspace ledger: `chant run` records the
30
- * pending gate citing the preview's digest and exits gated, `chant approve
31
- * <op> <gate>` writes the resolution, and the next run walks to the Adopt
32
- * step. The run itself is a run record on the same ledger (#4551), as for
33
- * `TerraformAdoptOp`. There is no `gate: "never"`: adoption moves the stack's
34
- * state onto another backend's records, which nobody should skip reviewing.
35
- *
36
- * ## Compensation
37
- *
38
- * Refused without a command, as `TerraformAdoptOp` refuses it. Backing out
39
- * is `plunge stack export --file s.json` then `pulumi stack import --file
40
- * s.json` on a stock backend, a decision about the stack and its backend
41
- * rather than something chant should run on its own.
42
- *
43
- * @example
44
- * ```typescript
45
- * import { PulumiAdoptOp } from "@intentius/chant-lexicon-pulumi";
46
- *
47
- * export const { op } = PulumiAdoptOp({
48
- * name: "adopt-infra",
49
- * stacks: [{ member: "infra", dir: "./infra", stack: "dev" }],
50
- * });
51
- * ```
52
- */
53
- import { Op, phase, gate, activity, OpResource } from "@intentius/chant/op";
54
- import { pulumiAdopt, pulumiAdoptCheck, pulumiAdoptExport, pulumiAdoptPreview } from "../op/builders";
55
-
56
- /** One stack to adopt. */
57
- export interface PulumiAdoptStack {
58
- /** The member's name. */
59
- member: string;
60
- /** The stack's directory, where `Pulumi.yaml` is, relative to the project root. */
61
- dir: string;
62
- /** The stack to adopt. */
63
- stack: string;
64
- /** The plunge backend URL (`plunge+s3://...`). Default: `plywood.yml`'s, `PULUMI_BACKEND_URL`, `Pulumi.yaml`'s. */
65
- backend?: string;
66
- /**
67
- * Where the checkpoint comes from, when it is not the stock stack at the
68
- * same root: `backend`, another backend to export from (Pulumi Cloud), or
69
- * `file`, an export already taken. Either way plunge adopts it with
70
- * `--file`.
71
- */
72
- from?: { backend: string } | { file: string };
73
- /** The bucket to check, as `@intentius/chant/bucket-check` takes it, when the URL does not name it fully (azblob). */
74
- bucket?: Record<string, unknown>;
75
- /** Key prefixes a lifecycle rule must cover. Default: the backend URL's path. */
76
- namespaces?: string[];
77
- /** Bucket settings waived, as plunge's `allow_insecure`. An unwaivable one stays refused. */
78
- allowInsecure?: string[];
79
- }
80
-
81
- export interface PulumiAdoptOpConfig {
82
- /** Op name (kebab-case). */
83
- name: string;
84
- /** The stacks to adopt, one wave each, in this order. */
85
- stacks: PulumiAdoptStack[];
86
- /** Directory relative `dir`s resolve against. Default: the running process's cwd. */
87
- cwd?: string;
88
- /** The gate's name with one stack; with several, each gate is `<gateName>-<member>-<stack>`. Default: `approve-<name>`. */
89
- gateName?: string;
90
- /** How long a recorded pending gate stays valid, as a duration string. Default: core's own (48h). */
91
- gateTimeout?: string;
92
- /** Override the gate description shown to the approver. */
93
- gateDescription?: string;
94
- /** Rollback on a failed adoption, run as an `onFailure` phase. Refused without a command. */
95
- compensate?: boolean | { command?: string; image?: string };
96
- }
97
-
98
- export interface PulumiAdoptOpResources {
99
- /** Op resource: Check, Export, then Preview, gate and Adopt per stack. */
100
- op: InstanceType<typeof OpResource>;
101
- }
102
-
103
- const slug = (s: string): string => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
104
-
105
- export function PulumiAdoptOp(config: PulumiAdoptOpConfig): PulumiAdoptOpResources {
106
- const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
107
- const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
108
- if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
109
- throw new Error(
110
- `PulumiAdoptOp "${config.name}": compensate is enabled, but there is no automatic undo for an adoption. ` +
111
- `Backing out is plunge stack export --file, then pulumi stack import --file on a stock backend, a decision ` +
112
- `about the stack and its backend. Supply compensate: { command: "..." } with an undo of your own, or set ` +
113
- `compensate: false.`,
114
- );
115
- }
116
- if (!Array.isArray(config.stacks) || config.stacks.length === 0) {
117
- throw new Error(`PulumiAdoptOp "${config.name}": stacks is empty; name at least one { member, dir, stack } to adopt`);
118
- }
119
- const seen = new Set<string>();
120
- for (const s of config.stacks) {
121
- const key = `${s.member}/${s.stack}`;
122
- if (seen.has(key)) throw new Error(`PulumiAdoptOp "${config.name}": ${key} is listed twice`);
123
- seen.add(key);
124
- }
125
-
126
- const where = config.cwd ? { cwd: config.cwd } : {};
127
- const single = config.stacks.length === 1;
128
- const gateBase = config.gateName ?? `approve-${config.name}`;
129
-
130
- const checks = config.stacks.map((s, i) =>
131
- pulumiAdoptCheck(s.member, {
132
- dir: s.dir,
133
- stack: s.stack,
134
- ...where,
135
- ...(s.backend ? { backend: s.backend } : {}),
136
- ...(s.bucket ? { bucket: s.bucket } : {}),
137
- ...(s.namespaces ? { namespaces: s.namespaces } : {}),
138
- ...(s.allowInsecure ? { allowInsecure: s.allowInsecure } : {}),
139
- id: `check-${i}`,
140
- }),
141
- );
142
- const exports = config.stacks.map((s, i) =>
143
- pulumiAdoptExport(s.member, {
144
- dir: s.dir,
145
- stack: s.stack,
146
- ...where,
147
- ...(s.backend ? { backend: s.backend } : {}),
148
- ...(s.from ? { from: s.from } : {}),
149
- id: `export-${i}`,
150
- profile: "longInfra",
151
- }),
152
- );
153
-
154
- const waves = config.stacks.flatMap((s, i) => {
155
- const file = s.from ? { file: exports[i]!.out.file } : {};
156
- // Every step gets the stack's backend, so Preview and Adopt read the store Check and Export read.
157
- const backend = s.backend ? { backend: s.backend } : {};
158
- const preview = pulumiAdoptPreview(s.member, { dir: s.dir, stack: s.stack, ...where, ...file, ...backend, id: `preview-${i}` });
159
- preview.outcomeAttribute = { name: single ? "Adoptable" : `Adoptable-${slug(s.member)}-${slug(s.stack)}`, from: "resources" };
160
- const adopt = pulumiAdopt(s.member, { dir: s.dir, stack: s.stack, ...where, ...file, ...backend, planDigest: preview.out.planDigest, id: `adopt-${i}` });
161
- adopt.outcomeAttribute = { name: single ? "Adopted" : `Adopted-${slug(s.member)}-${slug(s.stack)}`, from: "resources" };
162
- const label = single ? "" : ` ${s.member}/${s.stack}`;
163
- return [
164
- phase(`Preview${label}`, [preview]),
165
- phase(`Gate${label}`, [
166
- gate(single ? gateBase : `${gateBase}-${slug(s.member)}-${slug(s.stack)}`, {
167
- plan: preview.out.planDigest,
168
- ...(config.gateTimeout ? { timeout: config.gateTimeout } : {}),
169
- description:
170
- config.gateDescription ??
171
- `Approve adopting the Pulumi stack ${s.member}/${s.stack} onto plunge's per-resource records. The ` +
172
- `preview's adopt document is what is approved: each resource gets a record with the checkpoint's ID, ` +
173
- `no cloud object changes now, and the next plunge up writes the plunge-stack and plunge-urn tags.`,
174
- }),
175
- ]),
176
- phase(`Adopt${label}`, [adopt]),
177
- ];
178
- });
179
-
180
- const op = Op({
181
- name: config.name,
182
- overview: `Adopt ${single ? `the Pulumi stack ${config.stacks[0]!.member}/${config.stacks[0]!.stack}` : `${config.stacks.length} Pulumi stacks`} onto plunge's per-resource records`,
183
- labels: {
184
- Adopt: "true",
185
- Surface: "pulumi-adopt",
186
- },
187
- phases: [phase("Check", checks), phase("Export", exports), ...waves],
188
- ...(compensateCommand
189
- ? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
190
- : {}),
191
- });
192
- return { op };
193
- }
@@ -1,42 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { validateActivitySteps, type ActivityContract, type ActivityStep, type OpConfig } from "@intentius/chant/op";
3
- import { PulumiWatchOp } from "./pulumi-watch-op";
4
- import { pulumiDriftContract, pulumiPreviewContract } from "../op/activity-contracts";
5
- import * as activities from "../op/activities";
6
-
7
- function props(config: Parameters<typeof PulumiWatchOp>[0]): OpConfig {
8
- return (PulumiWatchOp(config).op as unknown as { props: OpConfig }).props;
9
- }
10
-
11
- const BASE = { name: "infra-watch", member: "infra", dir: "./infra" };
12
- const contracts = new Map<string, ActivityContract>([
13
- ["pulumiPreview", pulumiPreviewContract],
14
- ["pulumiDrift", pulumiDriftContract],
15
- ]);
16
-
17
- describe("PulumiWatchOp (#4494)", () => {
18
- test("Preview then Drift, each publishing its outcome", () => {
19
- const op = props({ ...BASE, stack: "dev", schedule: "0 6 * * *" });
20
- expect(op.phases.map((p) => p.name)).toEqual(["Preview", "Drift"]);
21
- const [preview, drift] = op.phases.map((p) => p.steps[0] as ActivityStep);
22
- expect(preview!.fn).toBe("pulumiPreview");
23
- expect(preview!.args).toEqual({ member: "infra", dir: "./infra", stack: "dev" });
24
- expect(preview!.outcomeAttribute).toEqual({ name: "Changes", from: "changed" });
25
- expect(drift!.fn).toBe("pulumiDrift");
26
- expect(drift!.outcomeAttribute).toEqual({ name: "Drift", from: "drifted" });
27
- expect(op.schedule).toEqual({ cron: "0 6 * * *", overlap: "skip" });
28
- });
29
-
30
- test("drift: false leaves the Drift phase out", () => {
31
- expect(props({ ...BASE, drift: false }).phases.map((p) => p.name)).toEqual(["Preview"]);
32
- });
33
-
34
- test("its steps validate against the activities' contracts", () => {
35
- expect(validateActivitySteps(props({ ...BASE, engine: "plunge" }), contracts)).toEqual([]);
36
- });
37
-
38
- test("the activities module exports exactly the activities, the watch's two and the adopt op's four (#4562)", () => {
39
- const fns = Object.entries(activities).filter(([, v]) => typeof v === "function").map(([k]) => k).sort();
40
- expect(fns).toEqual(["pulumiAdopt", "pulumiAdoptCheck", "pulumiAdoptExport", "pulumiAdoptPreview", "pulumiDrift", "pulumiPreview"]);
41
- });
42
- });
@@ -1,85 +0,0 @@
1
- /**
2
- * PulumiWatchOp composite (#4494): watch one Pulumi member on a schedule, the
3
- * pulumi twin of the terraform lexicon's `TerraformWatchOp`.
4
- *
5
- * Two phases, both read-only:
6
- *
7
- * - Preview: `pulumiPreview`, `pulumi preview --json` in the member's
8
- * directory. Its `changed` is the run's `Changes` outcome: true when the
9
- * program plans anything the stack does not hold, a resource that may
10
- * appear on apply included.
11
- * - Drift: `pulumiDrift`, one `pulumi refresh --preview-only --json --target
12
- * <urn>` per resource in the checked-in `stack-export.json` (`plunge drift
13
- * --resource <urn> --stream` for a member on plunge). Its `drifted` count,
14
- * drifted plus missing, is the run's `Drift` outcome. Set `drift: false` to
15
- * leave the phase out.
16
- *
17
- * Nothing here applies. chant never runs `pulumi up`, so a watch reports and
18
- * the stack's owner acts.
19
- *
20
- * The cron lands on the Op as `schedule`, the field `TerraformWatchOp` sets:
21
- * `chant operator` reads it as the Op's tick cadence and `generateOpsPipeline`
22
- * renders it as a CI cron. A one-shot `chant run` ignores it.
23
- *
24
- * @example
25
- * ```typescript
26
- * import { PulumiWatchOp } from "@intentius/chant-lexicon-pulumi";
27
- *
28
- * export const { op } = PulumiWatchOp({
29
- * name: "infra-watch",
30
- * member: "infra",
31
- * dir: "./infra",
32
- * stack: "dev",
33
- * schedule: "0 6 * * *",
34
- * });
35
- * ```
36
- */
37
- import { Op, phase, OpResource } from "@intentius/chant/op";
38
- import { pulumiDrift, pulumiPreview } from "../op/builders";
39
- import type { PulumiMemberEngine } from "../run";
40
-
41
- export interface PulumiWatchOpConfig {
42
- /** Op name (kebab-case). */
43
- name: string;
44
- /** The member's name, as the change set and the drift records name it. */
45
- member: string;
46
- /** The member's directory, where `Pulumi.yaml` is, relative to the project root. */
47
- dir: string;
48
- /** The stack to read. Default: the stack the directory has selected. */
49
- stack?: string;
50
- /** `pulumi` or `plunge`. Default: what `Pulumi.yaml`'s backend URL says. */
51
- engine?: PulumiMemberEngine;
52
- /** Run the Drift phase. Default true. */
53
- drift?: boolean;
54
- /** Cron expression for the Op's `schedule`. */
55
- schedule?: string;
56
- }
57
-
58
- export interface PulumiWatchOpResources {
59
- /** Op resource. Preview, then Drift unless `drift: false`. */
60
- op: InstanceType<typeof OpResource>;
61
- }
62
-
63
- export function PulumiWatchOp(config: PulumiWatchOpConfig): PulumiWatchOpResources {
64
- const { name, member, dir, stack, engine, schedule } = config;
65
- const common = { dir, ...(stack ? { stack } : {}), ...(engine ? { engine } : {}) };
66
-
67
- const preview = pulumiPreview(member, { ...common, id: "preview" });
68
- preview.outcomeAttribute = { name: "Changes", from: "changed" };
69
- const phases = [phase("Preview", [preview])];
70
-
71
- if (config.drift !== false) {
72
- const drift = pulumiDrift(member, { ...common, id: "drift" });
73
- drift.outcomeAttribute = { name: "Drift", from: "drifted" };
74
- phases.push(phase("Drift", [drift]));
75
- }
76
-
77
- const op = Op({
78
- name,
79
- overview: `Preview the ${member} Pulumi member${config.drift === false ? "" : " and read its drift"}; changes nothing`,
80
- labels: { Surface: "pulumi-watch" },
81
- ...(schedule ? { schedule: { cron: schedule, overlap: "skip" as const } } : {}),
82
- phases,
83
- });
84
- return { op };
85
- }
package/src/config.ts DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * The `pulumi` namespace in `chant.config.ts` (#4453).
3
- *
4
- * Nobody writes it by hand today. `chant workspace graph` writes `member`
5
- * into the reader project it makes for a member of kind `pulumi` (see
6
- * `workspace-kinds.json`): `dir` is the member's directory, absolute, and
7
- * `label` names the entities. The graph is the checked-in
8
- * `stack-export.json` there; the graph read never runs `pulumi`.
9
- */
10
- import { z } from "zod";
11
- import type { ChantConfig } from "@intentius/chant/config";
12
-
13
- export const pulumiMemberConfigSchema = z.strictObject({
14
- dir: z.string().min(1),
15
- label: z.string().optional(),
16
- /**
17
- * What runs the member's stack (#4453): `pulumi`, or `plunge`, whose
18
- * `plunge drift` reads drift in its place. Omit to take it from the
19
- * backend URL in `Pulumi.yaml` (`./run.ts`, `pulumiMemberEngine`).
20
- */
21
- engine: z.enum(["pulumi", "plunge"]).optional(),
22
- /**
23
- * The stack the drift read passes as `--stack` (#4496). Omit to take the
24
- * stack the checked-in `stack-export.json` names in its URNs.
25
- */
26
- stack: z.string().min(1).optional(),
27
- });
28
-
29
- export const pulumiConfigSchema = z.strictObject({
30
- /** One pulumi workspace member read into the graph (#3179). */
31
- member: pulumiMemberConfigSchema.optional(),
32
- });
33
-
34
- export type PulumiConfig = z.infer<typeof pulumiConfigSchema>;
35
-
36
- declare module "@intentius/chant/config" {
37
- interface ChantConfig {
38
- pulumi?: PulumiConfig;
39
- }
40
- }
41
-
42
- /** Compile-time proof that the augmentation reaches `ChantConfig`. */
43
- export type PulumiConfigNamespace = NonNullable<ChantConfig["pulumi"]>;