@intentius/chant 0.41.3 → 0.41.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/lifecycle.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqDlD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAwH/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C3E;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA2J3E;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/lifecycle.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqDlD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAwH/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C3E;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA2J3E;AAgjBD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA0J3E;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB1E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAM9E;AAkBD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C/E"}
|
package/package.json
CHANGED
|
@@ -359,6 +359,45 @@ describe("runLifecycleDiff --live", () => {
|
|
|
359
359
|
expect(output).toContain("release/default/web");
|
|
360
360
|
});
|
|
361
361
|
|
|
362
|
+
test("--live --json carries the observed artifact metadata, not just the key deltas (behold#146)", async () => {
|
|
363
|
+
buildMock.mockResolvedValue(makeBuildResult({ helm: [] }));
|
|
364
|
+
fetchLifecycleMock.mockResolvedValue(undefined);
|
|
365
|
+
// No previous snapshot at all — the first-run case where the diff is pure
|
|
366
|
+
// `added` keys and, before this, a JSON consumer had no status to read.
|
|
367
|
+
readSnapshotMock.mockResolvedValue(null);
|
|
368
|
+
|
|
369
|
+
const plugins: LexiconPlugin[] = [
|
|
370
|
+
createMockPlugin({
|
|
371
|
+
name: "helm",
|
|
372
|
+
listArtifacts: staticListArtifacts({
|
|
373
|
+
"release/default/web": {
|
|
374
|
+
type: "Helm::Release",
|
|
375
|
+
physicalId: "default/web",
|
|
376
|
+
status: "deployed",
|
|
377
|
+
attributes: { chart: "web-1.2.3", revision: "3" },
|
|
378
|
+
},
|
|
379
|
+
}),
|
|
380
|
+
}),
|
|
381
|
+
];
|
|
382
|
+
|
|
383
|
+
const ctx = {
|
|
384
|
+
args: makeArgs({ command: "state", path: "diff", extraPositional: "prod", live: true, json: true }),
|
|
385
|
+
plugins,
|
|
386
|
+
serializers: plugins.map((p) => p.serializer),
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
const exit = await runLifecycleDiff(ctx);
|
|
390
|
+
|
|
391
|
+
expect(exit).toBe(0);
|
|
392
|
+
const payload = JSON.parse(stdoutBuf.join("\n")) as {
|
|
393
|
+
lexicons: Record<string, { artifacts?: { added: string[] }; observedArtifacts?: Record<string, { status?: string; attributes?: Record<string, unknown> }> }>;
|
|
394
|
+
};
|
|
395
|
+
expect(payload.lexicons.helm.artifacts?.added).toContain("release/default/web");
|
|
396
|
+
const seen = payload.lexicons.helm.observedArtifacts?.["release/default/web"];
|
|
397
|
+
expect(seen?.status).toBe("deployed");
|
|
398
|
+
expect(seen?.attributes?.chart).toBe("web-1.2.3");
|
|
399
|
+
});
|
|
400
|
+
|
|
362
401
|
test("legacy digest mode still works without --live", async () => {
|
|
363
402
|
buildMock.mockResolvedValue(makeBuildResult({ aws: ["bucket"] }));
|
|
364
403
|
fetchLifecycleMock.mockResolvedValue(undefined);
|
|
@@ -652,6 +652,12 @@ interface LiveDiffOutcome {
|
|
|
652
652
|
/** Property-level drift (#1014), present only for lexicons with a deep reader. */
|
|
653
653
|
deep?: DeepDiffResult;
|
|
654
654
|
artifacts?: LiveArtifactDiffResult;
|
|
655
|
+
/** What `listArtifacts` actually saw, keyed like `artifacts`' entries
|
|
656
|
+
* (behold#146). The diff alone is snapshot-relative key lists — on a
|
|
657
|
+
* first run everything is `added` with no metadata, so a consumer
|
|
658
|
+
* painting artifact presence (a Helm release's status) had nothing to
|
|
659
|
+
* read. Mirrors `observed` on the resources path. */
|
|
660
|
+
observedArtifacts?: Record<string, ArtifactMetadata>;
|
|
655
661
|
}
|
|
656
662
|
>;
|
|
657
663
|
totalDrift: number;
|
|
@@ -831,8 +837,14 @@ async function runLifecycleDiffLive(args: LiveDiffArgs): Promise<LiveDiffOutcome
|
|
|
831
837
|
const observedThen = prevSnapshot?.artifacts;
|
|
832
838
|
const adiff = diffLiveArtifacts({ observedNow, observedThen });
|
|
833
839
|
totalDrift += adiff.added.length + adiff.removed.length + adiff.changed.length;
|
|
834
|
-
if (args.json)
|
|
835
|
-
|
|
840
|
+
if (args.json) {
|
|
841
|
+
const lex = (byLexicon[lexiconName] ??= {});
|
|
842
|
+
lex.artifacts = adiff;
|
|
843
|
+
// What was actually seen, not just how it moved (behold#146): the
|
|
844
|
+
// metadata was in hand and dropped, leaving JSON consumers unable to
|
|
845
|
+
// read an artifact's own status (a Helm release's "deployed").
|
|
846
|
+
lex.observedArtifacts = observedNow;
|
|
847
|
+
} else renderLiveArtifactDiff(lexiconName, args.environment, adiff);
|
|
836
848
|
lexiconChecked = true;
|
|
837
849
|
}
|
|
838
850
|
|