@intentius/chant-lexicon-k8s 0.49.0 → 0.50.0

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 (120) hide show
  1. package/dist/composites/index.d.ts +2 -0
  2. package/dist/composites/index.d.ts.map +1 -1
  3. package/dist/composites/operator-stack.d.ts +183 -0
  4. package/dist/composites/operator-stack.d.ts.map +1 -0
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/integrity.json +35 -35
  8. package/dist/lint/post-synth/argo-helpers.d.ts.map +1 -1
  9. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
  10. package/dist/lint/post-synth/k8s-helpers.d.ts +28 -5
  11. package/dist/lint/post-synth/k8s-helpers.d.ts.map +1 -1
  12. package/dist/lint/post-synth/wk8005.d.ts.map +1 -1
  13. package/dist/lint/post-synth/wk8006.d.ts.map +1 -1
  14. package/dist/lint/post-synth/wk8041.d.ts.map +1 -1
  15. package/dist/lint/post-synth/wk8042.d.ts.map +1 -1
  16. package/dist/lint/post-synth/wk8101.d.ts.map +1 -1
  17. package/dist/lint/post-synth/wk8102.d.ts.map +1 -1
  18. package/dist/lint/post-synth/wk8103.d.ts.map +1 -1
  19. package/dist/lint/post-synth/wk8104.d.ts.map +1 -1
  20. package/dist/lint/post-synth/wk8105.d.ts.map +1 -1
  21. package/dist/lint/post-synth/wk8201.d.ts.map +1 -1
  22. package/dist/lint/post-synth/wk8202.d.ts.map +1 -1
  23. package/dist/lint/post-synth/wk8203.d.ts.map +1 -1
  24. package/dist/lint/post-synth/wk8204.d.ts.map +1 -1
  25. package/dist/lint/post-synth/wk8205.d.ts.map +1 -1
  26. package/dist/lint/post-synth/wk8207.d.ts.map +1 -1
  27. package/dist/lint/post-synth/wk8208.d.ts.map +1 -1
  28. package/dist/lint/post-synth/wk8209.d.ts.map +1 -1
  29. package/dist/lint/post-synth/wk8301.d.ts.map +1 -1
  30. package/dist/lint/post-synth/wk8302.d.ts.map +1 -1
  31. package/dist/lint/post-synth/wk8303.d.ts.map +1 -1
  32. package/dist/lint/post-synth/wk8304.d.ts.map +1 -1
  33. package/dist/lint/post-synth/wk8305.d.ts.map +1 -1
  34. package/dist/lint/post-synth/wk8306.d.ts.map +1 -1
  35. package/dist/lint/post-synth/wk8401.d.ts.map +1 -1
  36. package/dist/lint/post-synth/wk8402.d.ts.map +1 -1
  37. package/dist/lint/post-synth/wk8403.d.ts.map +1 -1
  38. package/dist/lint/post-synth/wk8404.d.ts.map +1 -1
  39. package/dist/lint/post-synth/wk8405.d.ts.map +1 -1
  40. package/dist/lint/post-synth/wk8406.d.ts.map +1 -1
  41. package/dist/lint/post-synth/wk8407.d.ts.map +1 -1
  42. package/dist/manifest.json +1 -1
  43. package/dist/op/builders.d.ts +69 -0
  44. package/dist/op/builders.d.ts.map +1 -0
  45. package/dist/rules/argo-helpers.ts +2 -6
  46. package/dist/rules/crd-schema-helpers.ts +4 -6
  47. package/dist/rules/k8s-helpers.ts +32 -23
  48. package/dist/rules/wk8005.ts +27 -32
  49. package/dist/rules/wk8006.ts +33 -38
  50. package/dist/rules/wk8041.ts +19 -24
  51. package/dist/rules/wk8042.ts +17 -22
  52. package/dist/rules/wk8101.ts +29 -34
  53. package/dist/rules/wk8102.ts +13 -18
  54. package/dist/rules/wk8103.ts +17 -22
  55. package/dist/rules/wk8104.ts +30 -35
  56. package/dist/rules/wk8105.ts +16 -21
  57. package/dist/rules/wk8201.ts +26 -31
  58. package/dist/rules/wk8202.ts +17 -22
  59. package/dist/rules/wk8203.ts +17 -22
  60. package/dist/rules/wk8204.ts +46 -51
  61. package/dist/rules/wk8205.ts +27 -32
  62. package/dist/rules/wk8207.ts +14 -19
  63. package/dist/rules/wk8208.ts +14 -19
  64. package/dist/rules/wk8209.ts +14 -19
  65. package/dist/rules/wk8301.ts +25 -30
  66. package/dist/rules/wk8302.ts +19 -24
  67. package/dist/rules/wk8303.ts +23 -26
  68. package/dist/rules/wk8304.ts +35 -40
  69. package/dist/rules/wk8305.ts +39 -42
  70. package/dist/rules/wk8306.ts +20 -25
  71. package/dist/rules/wk8401.ts +59 -64
  72. package/dist/rules/wk8402.ts +13 -18
  73. package/dist/rules/wk8403.ts +32 -37
  74. package/dist/rules/wk8404.ts +15 -21
  75. package/dist/rules/wk8405.ts +15 -18
  76. package/dist/rules/wk8406.ts +29 -34
  77. package/dist/rules/wk8407.ts +17 -22
  78. package/dist/serializer.d.ts.map +1 -1
  79. package/package.json +3 -3
  80. package/src/composites/composites.test.ts +283 -0
  81. package/src/composites/index.ts +4 -0
  82. package/src/composites/operator-stack.ts +385 -0
  83. package/src/index.ts +11 -0
  84. package/src/lint/post-synth/argo-helpers.ts +2 -6
  85. package/src/lint/post-synth/crd-schema-helpers.ts +4 -6
  86. package/src/lint/post-synth/k8s-helpers.test.ts +26 -9
  87. package/src/lint/post-synth/k8s-helpers.ts +32 -23
  88. package/src/lint/post-synth/wk8005.ts +27 -32
  89. package/src/lint/post-synth/wk8006.ts +33 -38
  90. package/src/lint/post-synth/wk8041.ts +19 -24
  91. package/src/lint/post-synth/wk8042.ts +17 -22
  92. package/src/lint/post-synth/wk8101.ts +29 -34
  93. package/src/lint/post-synth/wk8102.ts +13 -18
  94. package/src/lint/post-synth/wk8103.ts +17 -22
  95. package/src/lint/post-synth/wk8104.ts +30 -35
  96. package/src/lint/post-synth/wk8105.ts +16 -21
  97. package/src/lint/post-synth/wk8201.ts +26 -31
  98. package/src/lint/post-synth/wk8202.ts +17 -22
  99. package/src/lint/post-synth/wk8203.ts +17 -22
  100. package/src/lint/post-synth/wk8204.ts +46 -51
  101. package/src/lint/post-synth/wk8205.ts +27 -32
  102. package/src/lint/post-synth/wk8207.ts +14 -19
  103. package/src/lint/post-synth/wk8208.ts +14 -19
  104. package/src/lint/post-synth/wk8209.ts +14 -19
  105. package/src/lint/post-synth/wk8301.ts +25 -30
  106. package/src/lint/post-synth/wk8302.ts +19 -24
  107. package/src/lint/post-synth/wk8303.ts +23 -26
  108. package/src/lint/post-synth/wk8304.ts +35 -40
  109. package/src/lint/post-synth/wk8305.ts +39 -42
  110. package/src/lint/post-synth/wk8306.ts +20 -25
  111. package/src/lint/post-synth/wk8401.ts +59 -64
  112. package/src/lint/post-synth/wk8402.ts +13 -18
  113. package/src/lint/post-synth/wk8403.ts +32 -37
  114. package/src/lint/post-synth/wk8404.ts +15 -21
  115. package/src/lint/post-synth/wk8405.ts +15 -18
  116. package/src/lint/post-synth/wk8406.ts +29 -34
  117. package/src/lint/post-synth/wk8407.ts +17 -22
  118. package/src/op/builders.test.ts +82 -0
  119. package/src/op/builders.ts +95 -0
  120. package/src/serializer.ts +9 -1
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { getPrimaryOutput, parseK8sManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
11
11
 
12
12
  export const wk8207: PostSynthCheck = {
13
13
  id: "WK8207",
@@ -16,27 +16,22 @@ export const wk8207: PostSynthCheck = {
16
16
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
- for (const [, output] of ctx.outputs) {
20
- const yaml = getPrimaryOutput(output);
21
- const manifests = parseK8sManifests(yaml);
19
+ for (const manifest of docsToManifests(ctx)) {
20
+ if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
21
 
23
- for (const manifest of manifests) {
24
- if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
+ const podSpec = extractPodSpec(manifest);
23
+ if (!podSpec) continue;
25
24
 
26
- const podSpec = extractPodSpec(manifest);
27
- if (!podSpec) continue;
25
+ const resourceName = manifest.metadata?.name ?? manifest.kind;
28
26
 
29
- const resourceName = manifest.metadata?.name ?? manifest.kind;
30
-
31
- if (podSpec.hostNetwork === true) {
32
- diagnostics.push({
33
- checkId: "WK8207",
34
- severity: "warning",
35
- message: `${manifest.kind} "${resourceName}" uses hostNetwork: true — this bypasses network isolation and should be avoided`,
36
- entity: resourceName,
37
- lexicon: "k8s",
38
- });
39
- }
27
+ if (podSpec.hostNetwork === true) {
28
+ diagnostics.push({
29
+ checkId: "WK8207",
30
+ severity: "warning",
31
+ message: `${manifest.kind} "${resourceName}" uses hostNetwork: true — this bypasses network isolation and should be avoided`,
32
+ entity: resourceName,
33
+ lexicon: "k8s",
34
+ });
40
35
  }
41
36
  }
42
37
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { getPrimaryOutput, parseK8sManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
11
11
 
12
12
  export const wk8208: PostSynthCheck = {
13
13
  id: "WK8208",
@@ -16,27 +16,22 @@ export const wk8208: PostSynthCheck = {
16
16
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
- for (const [, output] of ctx.outputs) {
20
- const yaml = getPrimaryOutput(output);
21
- const manifests = parseK8sManifests(yaml);
19
+ for (const manifest of docsToManifests(ctx)) {
20
+ if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
21
 
23
- for (const manifest of manifests) {
24
- if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
+ const podSpec = extractPodSpec(manifest);
23
+ if (!podSpec) continue;
25
24
 
26
- const podSpec = extractPodSpec(manifest);
27
- if (!podSpec) continue;
25
+ const resourceName = manifest.metadata?.name ?? manifest.kind;
28
26
 
29
- const resourceName = manifest.metadata?.name ?? manifest.kind;
30
-
31
- if (podSpec.hostPID === true) {
32
- diagnostics.push({
33
- checkId: "WK8208",
34
- severity: "warning",
35
- message: `${manifest.kind} "${resourceName}" uses hostPID: true — this allows visibility into all host processes and should be avoided`,
36
- entity: resourceName,
37
- lexicon: "k8s",
38
- });
39
- }
27
+ if (podSpec.hostPID === true) {
28
+ diagnostics.push({
29
+ checkId: "WK8208",
30
+ severity: "warning",
31
+ message: `${manifest.kind} "${resourceName}" uses hostPID: true — this allows visibility into all host processes and should be avoided`,
32
+ entity: resourceName,
33
+ lexicon: "k8s",
34
+ });
40
35
  }
41
36
  }
42
37
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { getPrimaryOutput, parseK8sManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
10
+ import { docsToManifests, extractPodSpec, WORKLOAD_KINDS } from "./k8s-helpers";
11
11
 
12
12
  export const wk8209: PostSynthCheck = {
13
13
  id: "WK8209",
@@ -16,27 +16,22 @@ export const wk8209: PostSynthCheck = {
16
16
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
- for (const [, output] of ctx.outputs) {
20
- const yaml = getPrimaryOutput(output);
21
- const manifests = parseK8sManifests(yaml);
19
+ for (const manifest of docsToManifests(ctx)) {
20
+ if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
21
 
23
- for (const manifest of manifests) {
24
- if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
+ const podSpec = extractPodSpec(manifest);
23
+ if (!podSpec) continue;
25
24
 
26
- const podSpec = extractPodSpec(manifest);
27
- if (!podSpec) continue;
25
+ const resourceName = manifest.metadata?.name ?? manifest.kind;
28
26
 
29
- const resourceName = manifest.metadata?.name ?? manifest.kind;
30
-
31
- if (podSpec.hostIPC === true) {
32
- diagnostics.push({
33
- checkId: "WK8209",
34
- severity: "warning",
35
- message: `${manifest.kind} "${resourceName}" uses hostIPC: true — this exposes host shared memory segments and should be avoided`,
36
- entity: resourceName,
37
- lexicon: "k8s",
38
- });
39
- }
27
+ if (podSpec.hostIPC === true) {
28
+ diagnostics.push({
29
+ checkId: "WK8209",
30
+ severity: "warning",
31
+ message: `${manifest.kind} "${resourceName}" uses hostIPC: true — this exposes host shared memory segments and should be avoided`,
32
+ entity: resourceName,
33
+ lexicon: "k8s",
34
+ });
40
35
  }
41
36
  }
42
37
 
@@ -12,7 +12,7 @@
12
12
  */
13
13
 
14
14
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
15
- import { getPrimaryOutput, parseK8sManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
15
+ import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
16
16
 
17
17
  export const wk8301: PostSynthCheck = {
18
18
  id: "WK8301",
@@ -21,35 +21,30 @@ export const wk8301: PostSynthCheck = {
21
21
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
22
22
  const diagnostics: PostSynthDiagnostic[] = [];
23
23
 
24
- for (const [, output] of ctx.outputs) {
25
- const yaml = getPrimaryOutput(output);
26
- const manifests = parseK8sManifests(yaml);
27
-
28
- for (const manifest of manifests) {
29
- if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
30
- // CronJobs and Jobs are short-lived — probes are less relevant
31
- if (manifest.kind === "Job" || manifest.kind === "CronJob") continue;
32
-
33
- const containers = extractContainers(manifest);
34
- const resourceName = manifest.metadata?.name ?? manifest.kind;
35
-
36
- for (const container of containers) {
37
- // No declared port → no inbound traffic → nothing to HTTP-probe.
38
- if (!container.ports || container.ports.length === 0) continue;
39
-
40
- const missing: string[] = [];
41
- if (!container.livenessProbe) missing.push("livenessProbe");
42
- if (!container.readinessProbe) missing.push("readinessProbe");
43
-
44
- if (missing.length > 0) {
45
- diagnostics.push({
46
- checkId: "WK8301",
47
- severity: "warning",
48
- message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing ${missing.join(" and ")}`,
49
- entity: resourceName,
50
- lexicon: "k8s",
51
- });
52
- }
24
+ for (const manifest of docsToManifests(ctx)) {
25
+ if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
26
+ // CronJobs and Jobs are short-lived — probes are less relevant
27
+ if (manifest.kind === "Job" || manifest.kind === "CronJob") continue;
28
+
29
+ const containers = extractContainers(manifest);
30
+ const resourceName = manifest.metadata?.name ?? manifest.kind;
31
+
32
+ for (const container of containers) {
33
+ // No declared port → no inbound traffic → nothing to HTTP-probe.
34
+ if (!container.ports || container.ports.length === 0) continue;
35
+
36
+ const missing: string[] = [];
37
+ if (!container.livenessProbe) missing.push("livenessProbe");
38
+ if (!container.readinessProbe) missing.push("readinessProbe");
39
+
40
+ if (missing.length > 0) {
41
+ diagnostics.push({
42
+ checkId: "WK8301",
43
+ severity: "warning",
44
+ message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing ${missing.join(" and ")}`,
45
+ entity: resourceName,
46
+ lexicon: "k8s",
47
+ });
53
48
  }
54
49
  }
55
50
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
- import { getPrimaryOutput, parseK8sManifests } from "./k8s-helpers";
9
+ import { docsToManifests } from "./k8s-helpers";
10
10
 
11
11
  export const wk8302: PostSynthCheck = {
12
12
  id: "WK8302",
@@ -15,29 +15,24 @@ export const wk8302: PostSynthCheck = {
15
15
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
16
  const diagnostics: PostSynthDiagnostic[] = [];
17
17
 
18
- for (const [, output] of ctx.outputs) {
19
- const yaml = getPrimaryOutput(output);
20
- const manifests = parseK8sManifests(yaml);
21
-
22
- for (const manifest of manifests) {
23
- if (manifest.kind !== "Deployment") continue;
24
-
25
- const resourceName = manifest.metadata?.name ?? "Deployment";
26
- const spec = manifest.spec;
27
- if (!spec) continue;
28
-
29
- const replicas = spec.replicas;
30
-
31
- // If replicas is omitted, Kubernetes defaults to 1
32
- if (replicas === undefined || replicas === null || replicas === 1) {
33
- diagnostics.push({
34
- checkId: "WK8302",
35
- severity: "info",
36
- message: `Deployment "${resourceName}" has ${replicas ?? 1} replica(s) — consider at least 2 for high availability`,
37
- entity: resourceName,
38
- lexicon: "k8s",
39
- });
40
- }
18
+ for (const manifest of docsToManifests(ctx)) {
19
+ if (manifest.kind !== "Deployment") continue;
20
+
21
+ const resourceName = manifest.metadata?.name ?? "Deployment";
22
+ const spec = manifest.spec;
23
+ if (!spec) continue;
24
+
25
+ const replicas = spec.replicas;
26
+
27
+ // If replicas is omitted, Kubernetes defaults to 1
28
+ if (replicas === undefined || replicas === null || replicas === 1) {
29
+ diagnostics.push({
30
+ checkId: "WK8302",
31
+ severity: "info",
32
+ message: `Deployment "${resourceName}" has ${replicas ?? 1} replica(s) consider at least 2 for high availability`,
33
+ entity: resourceName,
34
+ lexicon: "k8s",
35
+ });
41
36
  }
42
37
  }
43
38
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { getPrimaryOutput, parseK8sManifests } from "./k8s-helpers";
10
+ import { docsToManifests } from "./k8s-helpers";
11
11
  import type { K8sManifest } from "./k8s-helpers";
12
12
 
13
13
  export const wk8303: PostSynthCheck = {
@@ -17,38 +17,35 @@ export const wk8303: PostSynthCheck = {
17
17
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
18
18
  const diagnostics: PostSynthDiagnostic[] = [];
19
19
 
20
- for (const [, output] of ctx.outputs) {
21
- const yaml = getPrimaryOutput(output);
22
- const manifests = parseK8sManifests(yaml);
20
+ const manifests = docsToManifests(ctx);
23
21
 
24
- // Collect all PDB selectors to match against Deployments
25
- const pdbSelectors = collectPdbSelectors(manifests);
22
+ // Collect all PDB selectors to match against Deployments
23
+ const pdbSelectors = collectPdbSelectors(manifests);
26
24
 
27
- for (const manifest of manifests) {
28
- if (manifest.kind !== "Deployment") continue;
25
+ for (const manifest of manifests) {
26
+ if (manifest.kind !== "Deployment") continue;
29
27
 
30
- const spec = manifest.spec;
31
- if (!spec) continue;
28
+ const spec = manifest.spec;
29
+ if (!spec) continue;
32
30
 
33
- const replicas = spec.replicas;
34
- // Only check HA deployments (replicas >= 2)
35
- if (typeof replicas !== "number" || replicas < 2) continue;
31
+ const replicas = spec.replicas;
32
+ // Only check HA deployments (replicas >= 2)
33
+ if (typeof replicas !== "number" || replicas < 2) continue;
36
34
 
37
- const resourceName = manifest.metadata?.name ?? "Deployment";
35
+ const resourceName = manifest.metadata?.name ?? "Deployment";
38
36
 
39
- // Check if any PDB targets this Deployment's labels
40
- const selector = spec.selector as Record<string, unknown> | undefined;
41
- const matchLabels = selector?.matchLabels as Record<string, string> | undefined;
37
+ // Check if any PDB targets this Deployment's labels
38
+ const selector = spec.selector as Record<string, unknown> | undefined;
39
+ const matchLabels = selector?.matchLabels as Record<string, string> | undefined;
42
40
 
43
- if (!matchLabels || !hasCoveringPdb(matchLabels, pdbSelectors)) {
44
- diagnostics.push({
45
- checkId: "WK8303",
46
- severity: "info",
47
- message: `Deployment "${resourceName}" has ${replicas} replicas but no PodDisruptionBudget — add a PDB to ensure availability during voluntary disruptions`,
48
- entity: resourceName,
49
- lexicon: "k8s",
50
- });
51
- }
41
+ if (!matchLabels || !hasCoveringPdb(matchLabels, pdbSelectors)) {
42
+ diagnostics.push({
43
+ checkId: "WK8303",
44
+ severity: "info",
45
+ message: `Deployment "${resourceName}" has ${replicas} replicas but no PodDisruptionBudget — add a PDB to ensure availability during voluntary disruptions`,
46
+ entity: resourceName,
47
+ lexicon: "k8s",
48
+ });
52
49
  }
53
50
  }
54
51
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
- import { getPrimaryOutput, parseK8sManifests } from "./k8s-helpers";
10
+ import { docsToManifests } from "./k8s-helpers";
11
11
 
12
12
  export const wk8304: PostSynthCheck = {
13
13
  id: "WK8304",
@@ -16,51 +16,46 @@ export const wk8304: PostSynthCheck = {
16
16
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
- for (const [, output] of ctx.outputs) {
20
- const yaml = getPrimaryOutput(output);
21
- const manifests = parseK8sManifests(yaml);
19
+ for (const manifest of docsToManifests(ctx)) {
20
+ if (manifest.kind !== "Ingress") continue;
22
21
 
23
- for (const manifest of manifests) {
24
- if (manifest.kind !== "Ingress") continue;
22
+ const annotations = manifest.metadata?.annotations as Record<string, string> | undefined;
23
+ if (!annotations) continue;
25
24
 
26
- const annotations = manifest.metadata?.annotations as Record<string, string> | undefined;
27
- if (!annotations) continue;
25
+ const sslRedirect = annotations["alb.ingress.kubernetes.io/ssl-redirect"];
26
+ if (!sslRedirect) continue;
28
27
 
29
- const sslRedirect = annotations["alb.ingress.kubernetes.io/ssl-redirect"];
30
- if (!sslRedirect) continue;
28
+ const resourceName = manifest.metadata?.name ?? "Ingress";
29
+ const certArn = annotations["alb.ingress.kubernetes.io/certificate-arn"];
31
30
 
32
- const resourceName = manifest.metadata?.name ?? "Ingress";
33
- const certArn = annotations["alb.ingress.kubernetes.io/certificate-arn"];
34
-
35
- if (!certArn) {
36
- diagnostics.push({
37
- checkId: "WK8304",
38
- severity: "warning",
39
- message: `Ingress "${resourceName}" has ssl-redirect annotation but no certificate-arn — HTTPS redirect will fail without a TLS certificate`,
40
- entity: resourceName,
41
- lexicon: "k8s",
42
- });
43
- continue;
44
- }
31
+ if (!certArn) {
32
+ diagnostics.push({
33
+ checkId: "WK8304",
34
+ severity: "warning",
35
+ message: `Ingress "${resourceName}" has ssl-redirect annotation but no certificate-arn — HTTPS redirect will fail without a TLS certificate`,
36
+ entity: resourceName,
37
+ lexicon: "k8s",
38
+ });
39
+ continue;
40
+ }
45
41
 
46
- // Check listen-ports includes HTTPS
47
- const listenPorts = annotations["alb.ingress.kubernetes.io/listen-ports"];
48
- if (listenPorts) {
49
- try {
50
- const ports = JSON.parse(listenPorts) as Array<Record<string, number>>;
51
- const hasHttps = ports.some((p) => "HTTPS" in p);
52
- if (!hasHttps) {
53
- diagnostics.push({
54
- checkId: "WK8304",
55
- severity: "warning",
56
- message: `Ingress "${resourceName}" has ssl-redirect but listen-ports does not include HTTPS`,
57
- entity: resourceName,
58
- lexicon: "k8s",
59
- });
60
- }
61
- } catch {
62
- // Can't parse listen-ports — skip this check
42
+ // Check listen-ports includes HTTPS
43
+ const listenPorts = annotations["alb.ingress.kubernetes.io/listen-ports"];
44
+ if (listenPorts) {
45
+ try {
46
+ const ports = JSON.parse(listenPorts) as Array<Record<string, number>>;
47
+ const hasHttps = ports.some((p) => "HTTPS" in p);
48
+ if (!hasHttps) {
49
+ diagnostics.push({
50
+ checkId: "WK8304",
51
+ severity: "warning",
52
+ message: `Ingress "${resourceName}" has ssl-redirect but listen-ports does not include HTTPS`,
53
+ entity: resourceName,
54
+ lexicon: "k8s",
55
+ });
63
56
  }
57
+ } catch {
58
+ // Can't parse listen-ports — skip this check
64
59
  }
65
60
  }
66
61
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
- import { getPrimaryOutput, parseK8sManifests } from "./k8s-helpers";
9
+ import { docsToManifests } from "./k8s-helpers";
10
10
  import type { K8sManifest } from "./k8s-helpers";
11
11
 
12
12
  export const wk8305: PostSynthCheck = {
@@ -16,60 +16,57 @@ export const wk8305: PostSynthCheck = {
16
16
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
17
  const diagnostics: PostSynthDiagnostic[] = [];
18
18
 
19
- for (const [, output] of ctx.outputs) {
20
- const yaml = getPrimaryOutput(output);
21
- const manifests = parseK8sManifests(yaml);
19
+ const manifests = docsToManifests(ctx);
22
20
 
23
- // Build a map of Service name+namespace → set of port numbers
24
- const servicePorts = collectServicePorts(manifests);
21
+ // Build a map of Service name+namespace → set of port numbers
22
+ const servicePorts = collectServicePorts(manifests);
25
23
 
26
- for (const manifest of manifests) {
27
- if (manifest.kind !== "Ingress") continue;
24
+ for (const manifest of manifests) {
25
+ if (manifest.kind !== "Ingress") continue;
28
26
 
29
- const ingressName = manifest.metadata?.name ?? "Ingress";
30
- const ingressNamespace = manifest.metadata?.namespace ?? "default";
31
- const spec = manifest.spec;
32
- if (!spec) continue;
27
+ const ingressName = manifest.metadata?.name ?? "Ingress";
28
+ const ingressNamespace = manifest.metadata?.namespace ?? "default";
29
+ const spec = manifest.spec;
30
+ if (!spec) continue;
33
31
 
34
- const rules = spec.rules as Array<Record<string, unknown>> | undefined;
35
- if (!rules) continue;
32
+ const rules = spec.rules as Array<Record<string, unknown>> | undefined;
33
+ if (!rules) continue;
36
34
 
37
- for (const rule of rules) {
38
- const http = rule.http as Record<string, unknown> | undefined;
39
- if (!http) continue;
35
+ for (const rule of rules) {
36
+ const http = rule.http as Record<string, unknown> | undefined;
37
+ if (!http) continue;
40
38
 
41
- const paths = http.paths as Array<Record<string, unknown>> | undefined;
42
- if (!paths) continue;
39
+ const paths = http.paths as Array<Record<string, unknown>> | undefined;
40
+ if (!paths) continue;
43
41
 
44
- for (const pathEntry of paths) {
45
- const backend = pathEntry.backend as Record<string, unknown> | undefined;
46
- if (!backend) continue;
42
+ for (const pathEntry of paths) {
43
+ const backend = pathEntry.backend as Record<string, unknown> | undefined;
44
+ if (!backend) continue;
47
45
 
48
- const service = backend.service as Record<string, unknown> | undefined;
49
- if (!service) continue;
46
+ const service = backend.service as Record<string, unknown> | undefined;
47
+ if (!service) continue;
50
48
 
51
- const svcName = service.name as string | undefined;
52
- const port = service.port as Record<string, unknown> | undefined;
53
- const portNumber = port?.number as number | undefined;
49
+ const svcName = service.name as string | undefined;
50
+ const port = service.port as Record<string, unknown> | undefined;
51
+ const portNumber = port?.number as number | undefined;
54
52
 
55
- if (!svcName || portNumber === undefined) continue;
53
+ if (!svcName || portNumber === undefined) continue;
56
54
 
57
- // Look up the Service in the manifest set
58
- const key = `${ingressNamespace}/${svcName}`;
59
- const knownPorts = servicePorts.get(key);
55
+ // Look up the Service in the manifest set
56
+ const key = `${ingressNamespace}/${svcName}`;
57
+ const knownPorts = servicePorts.get(key);
60
58
 
61
- // Skip if the Service is not in the manifest set (external service)
62
- if (!knownPorts) continue;
59
+ // Skip if the Service is not in the manifest set (external service)
60
+ if (!knownPorts) continue;
63
61
 
64
- if (!knownPorts.has(portNumber)) {
65
- diagnostics.push({
66
- checkId: "WK8305",
67
- severity: "warning",
68
- message: `Ingress "${ingressName}" references Service "${svcName}" port ${portNumber}, but the Service only declares ports [${[...knownPorts].join(", ")}]`,
69
- entity: ingressName,
70
- lexicon: "k8s",
71
- });
72
- }
62
+ if (!knownPorts.has(portNumber)) {
63
+ diagnostics.push({
64
+ checkId: "WK8305",
65
+ severity: "warning",
66
+ message: `Ingress "${ingressName}" references Service "${svcName}" port ${portNumber}, but the Service only declares ports [${[...knownPorts].join(", ")}]`,
67
+ entity: ingressName,
68
+ lexicon: "k8s",
69
+ });
73
70
  }
74
71
  }
75
72
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
11
- import { getPrimaryOutput, parseK8sManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
11
+ import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers";
12
12
 
13
13
  export const wk8306: PostSynthCheck = {
14
14
  id: "WK8306",
@@ -17,30 +17,25 @@ export const wk8306: PostSynthCheck = {
17
17
  check(ctx: PostSynthContext): PostSynthDiagnostic[] {
18
18
  const diagnostics: PostSynthDiagnostic[] = [];
19
19
 
20
- for (const [, output] of ctx.outputs) {
21
- const yaml = getPrimaryOutput(output);
22
- const manifests = parseK8sManifests(yaml);
23
-
24
- for (const manifest of manifests) {
25
- if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
26
-
27
- const resourceName = manifest.metadata?.name ?? manifest.kind;
28
- const containers = extractContainers(manifest);
29
-
30
- for (const container of containers) {
31
- const command = (container as Record<string, unknown>).command as unknown[] | undefined;
32
- if (!Array.isArray(command) || command.length === 0) continue;
33
-
34
- const firstArg = String(command[0]);
35
- if (firstArg.startsWith("-")) {
36
- diagnostics.push({
37
- checkId: "WK8306",
38
- severity: "error",
39
- message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has command[0]="${firstArg}" which starts with a flag — the first element should be the binary, flags belong in args`,
40
- entity: resourceName,
41
- lexicon: "k8s",
42
- });
43
- }
20
+ for (const manifest of docsToManifests(ctx)) {
21
+ if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind)) continue;
22
+
23
+ const resourceName = manifest.metadata?.name ?? manifest.kind;
24
+ const containers = extractContainers(manifest);
25
+
26
+ for (const container of containers) {
27
+ const command = (container as Record<string, unknown>).command as unknown[] | undefined;
28
+ if (!Array.isArray(command) || command.length === 0) continue;
29
+
30
+ const firstArg = String(command[0]);
31
+ if (firstArg.startsWith("-")) {
32
+ diagnostics.push({
33
+ checkId: "WK8306",
34
+ severity: "error",
35
+ message: `Container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" has command[0]="${firstArg}" which starts with a flag — the first element should be the binary, flags belong in args`,
36
+ entity: resourceName,
37
+ lexicon: "k8s",
38
+ });
44
39
  }
45
40
  }
46
41
  }