@intentius/chant-lexicon-terraform 0.124.32 → 0.124.34
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.
- package/dist/composites/terraform-adopt-op.d.ts +2 -0
- package/dist/composites/terraform-adopt-op.d.ts.map +1 -1
- package/dist/composites/terraform-adopt-op.js +2 -1
- package/dist/composites/terraform-apply-op.d.ts +2 -0
- package/dist/composites/terraform-apply-op.d.ts.map +1 -1
- package/dist/composites/terraform-apply-op.js +2 -1
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/package.json +2 -2
- package/src/composites/terraform-adopt-op.test.ts +6 -0
- package/src/composites/terraform-adopt-op.ts +7 -2
- package/src/composites/terraform-apply-op.test.ts +6 -0
- package/src/composites/terraform-apply-op.ts +7 -2
|
@@ -137,6 +137,8 @@ export interface TerraformAdoptOpConfig {
|
|
|
137
137
|
*/
|
|
138
138
|
compensate?: boolean | {
|
|
139
139
|
command?: string;
|
|
140
|
+
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
|
|
141
|
+
image?: string;
|
|
140
142
|
};
|
|
141
143
|
}
|
|
142
144
|
export interface TerraformAdoptOpResources {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terraform-adopt-op.d.ts","sourceRoot":"","sources":["../../src/composites/terraform-adopt-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,OAAO,EAA6B,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQ5E,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"terraform-adopt-op.d.ts","sourceRoot":"","sources":["../../src/composites/terraform-adopt-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,OAAO,EAA6B,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQ5E,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,wGAAwG;IACxG,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,qGAAqG;QACrG,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,wEAAwE;IACxE,EAAE,EAAE,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;CACrC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,yBAAyB,CAmE1F"}
|
|
@@ -94,6 +94,7 @@ import { Op, phase, gate, activity } from "@intentius/chant/op";
|
|
|
94
94
|
import { terraformInit as initStep, choudoufuLiveCheck as checkStep, choudoufuLivePlan as ledgerStep, choudoufuAdopt as adoptStep, } from "../op/builders.js";
|
|
95
95
|
export function TerraformAdoptOp(config) {
|
|
96
96
|
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
|
|
97
|
+
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
|
|
97
98
|
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
|
|
98
99
|
throw new Error(`TerraformAdoptOp "${config.name}": compensate is enabled, but there is no automatic undo for an ` +
|
|
99
100
|
`adoption — un-adopting is untag, removing this estate's ownership marker from a live resource, ` +
|
|
@@ -145,7 +146,7 @@ export function TerraformAdoptOp(config) {
|
|
|
145
146
|
phase("Adopt", [adopt]),
|
|
146
147
|
],
|
|
147
148
|
...(compensateCommand
|
|
148
|
-
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
|
|
149
|
+
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
|
|
149
150
|
: {}),
|
|
150
151
|
});
|
|
151
152
|
return { op };
|
|
@@ -148,6 +148,8 @@ export interface TerraformApplyOpConfig {
|
|
|
148
148
|
*/
|
|
149
149
|
compensate?: boolean | {
|
|
150
150
|
command?: string;
|
|
151
|
+
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
|
|
152
|
+
image?: string;
|
|
151
153
|
};
|
|
152
154
|
}
|
|
153
155
|
export interface TerraformApplyOpResources {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terraform-apply-op.d.ts","sourceRoot":"","sources":["../../src/composites/terraform-apply-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AAEH,OAAO,EAA6B,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW/F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,IAAI,EAAE,MAAM,CAAC;IACb,0GAA0G;IAC1G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"terraform-apply-op.d.ts","sourceRoot":"","sources":["../../src/composites/terraform-apply-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AAEH,OAAO,EAA6B,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW/F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,IAAI,EAAE,MAAM,CAAC;IACb,0GAA0G;IAC1G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qGAAqG;IACrG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,qGAAqG;QACrG,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,mEAAmE;IACnE,EAAE,EAAE,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;CACrC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,yBAAyB,CAkH1F"}
|
|
@@ -91,6 +91,7 @@ export function TerraformApplyOp(config) {
|
|
|
91
91
|
// fails here, at build time, with the Op named — not as a warning when the
|
|
92
92
|
// apply has already half-run. Same shape as ApplyOp's refusal (#1449).
|
|
93
93
|
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
|
|
94
|
+
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
|
|
94
95
|
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
|
|
95
96
|
throw new Error(`TerraformApplyOp "${config.name}": compensate is enabled, but terraform has no automatic ` +
|
|
96
97
|
`rollback — undoing a partial apply means planning and applying the inverse, which is a ` +
|
|
@@ -176,7 +177,7 @@ export function TerraformApplyOp(config) {
|
|
|
176
177
|
},
|
|
177
178
|
phases,
|
|
178
179
|
...(compensateCommand
|
|
179
|
-
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
|
|
180
|
+
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
|
|
180
181
|
: {}),
|
|
181
182
|
});
|
|
182
183
|
return { op };
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "34bbd70366edbbcb42fbd0b972fed5e2a35443748fa87a56e7cb20db430a61c9",
|
|
5
5
|
"meta.json": "ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356",
|
|
6
6
|
"types/index.d.ts": "022927e6a7b351cc4cf52d5f973f60ccd140e5810e17b32fb8868965aa1db161",
|
|
7
7
|
"rules/plan-before-apply.ts": "7c10245b2c3335253b48ee7d8b075d89f43116bde20313a5d1031b343fef1282",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"rules/tf045.ts": "760b1f4f385fbe7a86897efe3078fdeac11bcc9bfb806285d63db50488174b7b",
|
|
57
57
|
"skills/chant-terraform.md": "d9ca7b7c28aed0038ce775a3491150298492eed2858fd3651ed9bfca0e577ae8"
|
|
58
58
|
},
|
|
59
|
-
"composite": "
|
|
59
|
+
"composite": "d87af237b7025781d6cb8708dea56d182c24638fb1770ee189b17fad14e42eec"
|
|
60
60
|
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-terraform",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"access": "public"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@intentius/chant": "^0.124.
|
|
70
|
+
"@intentius/chant": "^0.124.34",
|
|
71
71
|
"zod": "^4.3.6"
|
|
72
72
|
},
|
|
73
73
|
"description": "terraform lexicon for chant, existing Terraform root modules as declarable entities",
|
|
@@ -176,6 +176,12 @@ describe("TerraformAdoptOp compensation (#2105)", () => {
|
|
|
176
176
|
expect((op.onFailure![0].steps[0] as ActivityStep).args?.cmd).toBe("./untag.sh");
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
+
test("a supplied image runs the rollback in that container (#4015)", () => {
|
|
180
|
+
const image = `alpine:3.20@sha256:${"b".repeat(64)}`;
|
|
181
|
+
const op = props({ ...base, compensate: { command: "./untag.sh", image } });
|
|
182
|
+
expect((op.onFailure![0].steps[0] as ActivityStep).args).toEqual({ cmd: "./untag.sh", image });
|
|
183
|
+
});
|
|
184
|
+
|
|
179
185
|
test("compensate: false and omitting it both leave no onFailure", () => {
|
|
180
186
|
expect(props(base).onFailure).toBeUndefined();
|
|
181
187
|
expect(props({ ...base, compensate: false }).onFailure).toBeUndefined();
|
|
@@ -143,7 +143,11 @@ export interface TerraformAdoptOpConfig {
|
|
|
143
143
|
* object with no `command`, throws when the Op is built, naming the Op,
|
|
144
144
|
* rather than warning at the moment a rollback is already wanted.
|
|
145
145
|
*/
|
|
146
|
-
compensate?: boolean | {
|
|
146
|
+
compensate?: boolean | {
|
|
147
|
+
command?: string;
|
|
148
|
+
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
|
|
149
|
+
image?: string;
|
|
150
|
+
};
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
export interface TerraformAdoptOpResources {
|
|
@@ -153,6 +157,7 @@ export interface TerraformAdoptOpResources {
|
|
|
153
157
|
|
|
154
158
|
export function TerraformAdoptOp(config: TerraformAdoptOpConfig): TerraformAdoptOpResources {
|
|
155
159
|
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
|
|
160
|
+
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
|
|
156
161
|
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
|
|
157
162
|
throw new Error(
|
|
158
163
|
`TerraformAdoptOp "${config.name}": compensate is enabled, but there is no automatic undo for an ` +
|
|
@@ -212,7 +217,7 @@ export function TerraformAdoptOp(config: TerraformAdoptOpConfig): TerraformAdopt
|
|
|
212
217
|
phase("Adopt", [adopt]),
|
|
213
218
|
],
|
|
214
219
|
...(compensateCommand
|
|
215
|
-
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
|
|
220
|
+
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
|
|
216
221
|
: {}),
|
|
217
222
|
});
|
|
218
223
|
|
|
@@ -179,6 +179,12 @@ describe("TerraformApplyOp compensation — total or refused (#2086)", () => {
|
|
|
179
179
|
args: { cmd: "terraform apply -input=false rollback.tfplan" },
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
|
+
|
|
183
|
+
test("compensate: { command, image } runs the rollback in that image (#4015)", () => {
|
|
184
|
+
const image = `hashicorp/terraform:1.9@sha256:${"a".repeat(64)}`;
|
|
185
|
+
const op = props({ name: "a", root: "app", compensate: { command: "terraform apply rollback.tfplan", image } });
|
|
186
|
+
expect(op.onFailure![0].steps[0]).toMatchObject({ fn: "shellCmd", args: { cmd: "terraform apply rollback.tfplan", image } });
|
|
187
|
+
});
|
|
182
188
|
});
|
|
183
189
|
|
|
184
190
|
describe("TerraformApplyOp on the local executor (#2086, gate-as-fact #2119)", () => {
|
|
@@ -158,7 +158,11 @@ export interface TerraformApplyOpConfig {
|
|
|
158
158
|
* rollback is already needed. Supply `compensate: { command: "..." }` with a
|
|
159
159
|
* rollback of your own, or leave it unset.
|
|
160
160
|
*/
|
|
161
|
-
compensate?: boolean | {
|
|
161
|
+
compensate?: boolean | {
|
|
162
|
+
command?: string;
|
|
163
|
+
/** Run the rollback command in a container pinned by digest (#4015), as `shell()`'s `image` does. */
|
|
164
|
+
image?: string;
|
|
165
|
+
};
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
export interface TerraformApplyOpResources {
|
|
@@ -174,6 +178,7 @@ export function TerraformApplyOp(config: TerraformApplyOpConfig): TerraformApply
|
|
|
174
178
|
// fails here, at build time, with the Op named — not as a warning when the
|
|
175
179
|
// apply has already half-run. Same shape as ApplyOp's refusal (#1449).
|
|
176
180
|
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
|
|
181
|
+
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
|
|
177
182
|
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
|
|
178
183
|
throw new Error(
|
|
179
184
|
`TerraformApplyOp "${config.name}": compensate is enabled, but terraform has no automatic ` +
|
|
@@ -274,7 +279,7 @@ export function TerraformApplyOp(config: TerraformApplyOpConfig): TerraformApply
|
|
|
274
279
|
},
|
|
275
280
|
phases,
|
|
276
281
|
...(compensateCommand
|
|
277
|
-
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand })])] }
|
|
282
|
+
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
|
|
278
283
|
: {}),
|
|
279
284
|
});
|
|
280
285
|
|