@intentius/chant-lexicon-k8s 0.124.45 → 0.124.46
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/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/package.json +5 -5
- package/src/kustomize/search.test.ts +101 -0
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "a72c8c81dcfc3cab30716d1e25cda352d7ccd1b66b8b10f554a9f14af5810698",
|
|
5
5
|
"meta.json": "c1831ac15083f5e0e45b29698d7b77f1c01646240fe6de5d6320753188594f69",
|
|
6
6
|
"types/index.d.ts": "5c5340046d090ae9db5553039d923cf92a8b2eb57aa4dc941273ed5bcfb5bc9d",
|
|
7
7
|
"rules/argo-appset-single-project.ts": "afa9f310753aa2d475f35012b13135b2dfaebed2a35d44edbe185ebc07673674",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"skills/chant-k8s-argo.md": "24c9a85b78a2fc5c6657424baac9cc6d6caff6f47605b8146b2c0082133181cf",
|
|
79
79
|
"skills/chant-k8s-flux.md": "9670efc2e9854bd14686b5adeb707396b9030a4dcaee6529b30abf56efe2c50c"
|
|
80
80
|
},
|
|
81
|
-
"composite": "
|
|
81
|
+
"composite": "eaab5d2323505e8c2a37753efebf0387b92ee2d887073dca6b73f0e3b992cdfd"
|
|
82
82
|
}
|
package/dist/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-k8s",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.46",
|
|
4
4
|
"description": "Kubernetes lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
"build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json && cp src/generated/index.d.ts dist/generated/index.d.d.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@intentius/chant-lexicon-otel": "^0.124.
|
|
76
|
-
"@intentius/chant-lexicon-prometheus": "^0.124.
|
|
75
|
+
"@intentius/chant-lexicon-otel": "^0.124.46",
|
|
76
|
+
"@intentius/chant-lexicon-prometheus": "^0.124.46",
|
|
77
77
|
"js-yaml": "^4.3.1",
|
|
78
78
|
"@types/js-yaml": "^4.0.9"
|
|
79
79
|
},
|
|
80
80
|
"optionalDependencies": {
|
|
81
|
-
"@intentius/chant-k8s-client": "^0.124.
|
|
81
|
+
"@intentius/chant-k8s-client": "^0.124.46"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@intentius/chant": "*",
|
|
@@ -86,6 +86,6 @@
|
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"zod": "^4.3.6",
|
|
89
|
-
"@intentius/chant": "^0.124.
|
|
89
|
+
"@intentius/chant": "^0.124.46"
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant search` over a `k8s.kustomize.roots` project (chant #4365): the
|
|
3
|
+
* rendered objects are build-root entities, so search must merge them the way
|
|
4
|
+
* `chant graph` does, and give them the ids `chant graph --format ir` prints.
|
|
5
|
+
*
|
|
6
|
+
* The render goes through the real hook's helper with a canned runner, the
|
|
7
|
+
* same output `root.test.ts` pins, so the test needs neither kustomize nor
|
|
8
|
+
* kubectl.
|
|
9
|
+
*/
|
|
10
|
+
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { cp, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import type { GraphIR } from "@intentius/chant/graph-ir";
|
|
16
|
+
import type { LexiconPlugin } from "@intentius/chant/lexicon";
|
|
17
|
+
import { runGraph } from "@intentius/chant/cli/handlers/graph";
|
|
18
|
+
import { runSearch, type SearchJson } from "@intentius/chant/cli/handlers/search";
|
|
19
|
+
import { renderKustomizeRoots } from "./root";
|
|
20
|
+
import { k8sPlugin } from "../plugin";
|
|
21
|
+
|
|
22
|
+
const fixtureRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "testdata", "kustomize-root");
|
|
23
|
+
|
|
24
|
+
const RENDERED = `apiVersion: v1
|
|
25
|
+
kind: Service
|
|
26
|
+
metadata:
|
|
27
|
+
name: prod-web
|
|
28
|
+
spec:
|
|
29
|
+
ports:
|
|
30
|
+
- port: 80
|
|
31
|
+
selector:
|
|
32
|
+
app: web
|
|
33
|
+
---
|
|
34
|
+
apiVersion: apps/v1
|
|
35
|
+
kind: Deployment
|
|
36
|
+
metadata:
|
|
37
|
+
name: prod-web
|
|
38
|
+
spec:
|
|
39
|
+
replicas: 3
|
|
40
|
+
selector:
|
|
41
|
+
matchLabels:
|
|
42
|
+
app: web
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
/** The k8s plugin, with its kustomize render swapped for the canned output. */
|
|
46
|
+
const plugin: LexiconPlugin = {
|
|
47
|
+
...k8sPlugin,
|
|
48
|
+
buildRoots: async (ctx) => {
|
|
49
|
+
const roots = (ctx.config as { k8s?: { kustomize?: { roots?: string[] } } }).k8s?.kustomize?.roots ?? [];
|
|
50
|
+
return renderKustomizeRoots({ projectRoot: ctx.projectRoot, roots, run: async () => ({ stdout: RENDERED }) });
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let project: string;
|
|
55
|
+
|
|
56
|
+
async function inProject(run: () => Promise<number>): Promise<{ exit: number; out: string[]; err: string[] }> {
|
|
57
|
+
const out: string[] = [];
|
|
58
|
+
const err: string[] = [];
|
|
59
|
+
vi.spyOn(console, "log").mockImplementation((line: unknown) => void out.push(String(line)));
|
|
60
|
+
vi.spyOn(console, "error").mockImplementation((line: unknown) => void err.push(String(line)));
|
|
61
|
+
const cwd = process.cwd();
|
|
62
|
+
process.chdir(project);
|
|
63
|
+
try {
|
|
64
|
+
return { exit: await run(), out, err };
|
|
65
|
+
} finally {
|
|
66
|
+
process.chdir(cwd);
|
|
67
|
+
vi.restoreAllMocks();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
beforeAll(async () => {
|
|
72
|
+
project = await mkdtemp(join(tmpdir(), "chant-kustomize-search-"));
|
|
73
|
+
await cp(fixtureRoot, project, { recursive: true });
|
|
74
|
+
await writeFile(
|
|
75
|
+
join(project, "chant.config.json"),
|
|
76
|
+
JSON.stringify({ lexicons: ["k8s"], k8s: { kustomize: { roots: ["overlays/prod"] } } }),
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
afterAll(async () => {
|
|
81
|
+
await rm(project, { recursive: true, force: true });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("search over a k8s.kustomize.roots project (#4365)", () => {
|
|
85
|
+
test("a kind query returns the rendered objects under graph --format ir's ids", async () => {
|
|
86
|
+
const graphRun = await inProject(() =>
|
|
87
|
+
runGraph({ args: { command: "graph", path: ".", format: "ir" } as never, plugins: [plugin], serializers: [] }),
|
|
88
|
+
);
|
|
89
|
+
expect(graphRun.exit, graphRun.err.join("\n")).toBe(0);
|
|
90
|
+
const graph = JSON.parse(graphRun.out.join("\n")) as GraphIR;
|
|
91
|
+
const drawn = graph.nodes.filter((n) => n.kind?.startsWith("K8s::")).map((n) => n.id).sort();
|
|
92
|
+
expect(drawn).toEqual(["overlays/prod/deploymentProdWeb", "overlays/prod/serviceProdWeb"]);
|
|
93
|
+
|
|
94
|
+
const searchRun = await inProject(() =>
|
|
95
|
+
runSearch({ args: { path: "kind:K8s::", json: true } as never, plugins: [plugin], serializers: [] }),
|
|
96
|
+
);
|
|
97
|
+
expect(searchRun.exit, searchRun.err.join("\n")).toBe(0);
|
|
98
|
+
const json = JSON.parse(searchRun.out.join("\n")) as SearchJson;
|
|
99
|
+
expect(json.matches.map((m) => m.id).sort()).toEqual(drawn);
|
|
100
|
+
});
|
|
101
|
+
});
|