@intentius/chant-lexicon-k8s 0.124.97 → 0.124.98

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 (228) hide show
  1. package/dist/application-paths.d.ts +4 -0
  2. package/dist/application-paths.d.ts.map +1 -0
  3. package/dist/application-paths.js +95 -0
  4. package/dist/application-set.d.ts +46 -0
  5. package/dist/application-set.d.ts.map +1 -0
  6. package/dist/application-set.js +303 -0
  7. package/dist/cluster-secret.d.ts +36 -0
  8. package/dist/cluster-secret.d.ts.map +1 -0
  9. package/dist/cluster-secret.js +55 -0
  10. package/dist/components/kustomize-apply.d.ts +6 -0
  11. package/dist/components/kustomize-apply.d.ts.map +1 -1
  12. package/dist/components/kustomize-apply.js +1 -1
  13. package/dist/config-schema.d.ts +8 -0
  14. package/dist/config-schema.d.ts.map +1 -1
  15. package/dist/config-schema.js +6 -2
  16. package/dist/config.d.ts +26 -3
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/helm-references.d.ts +113 -0
  19. package/dist/helm-references.d.ts.map +1 -0
  20. package/dist/helm-references.js +389 -0
  21. package/dist/import/generator.d.ts +11 -2
  22. package/dist/import/generator.d.ts.map +1 -1
  23. package/dist/import/generator.js +37 -55
  24. package/dist/import/parser.d.ts.map +1 -1
  25. package/dist/import/parser.js +34 -5
  26. package/dist/import/typed-classes.d.ts +57 -0
  27. package/dist/import/typed-classes.d.ts.map +1 -0
  28. package/dist/import/typed-classes.js +126 -0
  29. package/dist/integrity.json +41 -41
  30. package/dist/kustomize/render.d.ts +41 -2
  31. package/dist/kustomize/render.d.ts.map +1 -1
  32. package/dist/kustomize/render.js +114 -7
  33. package/dist/kustomize/root.d.ts +3 -3
  34. package/dist/kustomize/root.d.ts.map +1 -1
  35. package/dist/kustomize/root.js +6 -1
  36. package/dist/lint/post-synth/argo-helpers.d.ts +3 -0
  37. package/dist/lint/post-synth/argo-helpers.d.ts.map +1 -1
  38. package/dist/lint/post-synth/argo-helpers.js +8 -2
  39. package/dist/lint/post-synth/argo002.d.ts.map +1 -1
  40. package/dist/lint/post-synth/argo002.js +2 -1
  41. package/dist/lint/post-synth/argo003.d.ts.map +1 -1
  42. package/dist/lint/post-synth/argo003.js +2 -1
  43. package/dist/lint/post-synth/argo005.d.ts.map +1 -1
  44. package/dist/lint/post-synth/argo005.js +36 -9
  45. package/dist/lint/post-synth/crd-schema-helpers.d.ts +1 -1
  46. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
  47. package/dist/lint/post-synth/crd-schema-helpers.js +3 -3
  48. package/dist/lint/post-synth/flux002.d.ts.map +1 -1
  49. package/dist/lint/post-synth/flux002.js +2 -1
  50. package/dist/lint/post-synth/flux003.d.ts.map +1 -1
  51. package/dist/lint/post-synth/flux003.js +2 -1
  52. package/dist/lint/post-synth/k8s-helpers.d.ts +32 -0
  53. package/dist/lint/post-synth/k8s-helpers.d.ts.map +1 -1
  54. package/dist/lint/post-synth/k8s-helpers.js +57 -10
  55. package/dist/lint/post-synth/wk8005.d.ts +9 -0
  56. package/dist/lint/post-synth/wk8005.d.ts.map +1 -1
  57. package/dist/lint/post-synth/wk8005.js +53 -3
  58. package/dist/lint/post-synth/wk8006.d.ts.map +1 -1
  59. package/dist/lint/post-synth/wk8006.js +4 -2
  60. package/dist/lint/post-synth/wk8041.d.ts.map +1 -1
  61. package/dist/lint/post-synth/wk8041.js +3 -2
  62. package/dist/lint/post-synth/wk8042.js +2 -2
  63. package/dist/lint/post-synth/wk8101.js +2 -2
  64. package/dist/lint/post-synth/wk8102.d.ts.map +1 -1
  65. package/dist/lint/post-synth/wk8102.js +7 -3
  66. package/dist/lint/post-synth/wk8103.d.ts.map +1 -1
  67. package/dist/lint/post-synth/wk8103.js +3 -2
  68. package/dist/lint/post-synth/wk8104.d.ts.map +1 -1
  69. package/dist/lint/post-synth/wk8104.js +3 -2
  70. package/dist/lint/post-synth/wk8105.d.ts.map +1 -1
  71. package/dist/lint/post-synth/wk8105.js +3 -2
  72. package/dist/lint/post-synth/wk8201.d.ts.map +1 -1
  73. package/dist/lint/post-synth/wk8201.js +3 -2
  74. package/dist/lint/post-synth/wk8202.d.ts.map +1 -1
  75. package/dist/lint/post-synth/wk8202.js +3 -2
  76. package/dist/lint/post-synth/wk8203.d.ts.map +1 -1
  77. package/dist/lint/post-synth/wk8203.js +3 -2
  78. package/dist/lint/post-synth/wk8204.d.ts.map +1 -1
  79. package/dist/lint/post-synth/wk8204.js +5 -2
  80. package/dist/lint/post-synth/wk8205.d.ts.map +1 -1
  81. package/dist/lint/post-synth/wk8205.js +3 -2
  82. package/dist/lint/post-synth/wk8207.js +2 -2
  83. package/dist/lint/post-synth/wk8208.js +2 -2
  84. package/dist/lint/post-synth/wk8209.js +2 -2
  85. package/dist/lint/post-synth/wk8301.d.ts.map +1 -1
  86. package/dist/lint/post-synth/wk8301.js +3 -2
  87. package/dist/lint/post-synth/wk8302.js +2 -2
  88. package/dist/lint/post-synth/wk8303.js +2 -2
  89. package/dist/lint/post-synth/wk8304.js +2 -2
  90. package/dist/lint/post-synth/wk8305.js +2 -2
  91. package/dist/lint/post-synth/wk8306.d.ts.map +1 -1
  92. package/dist/lint/post-synth/wk8306.js +3 -2
  93. package/dist/lint/post-synth/wk8401.js +2 -2
  94. package/dist/lint/post-synth/wk8402.js +2 -2
  95. package/dist/lint/post-synth/wk8403.js +2 -2
  96. package/dist/lint/post-synth/wk8404.d.ts.map +1 -1
  97. package/dist/lint/post-synth/wk8404.js +2 -2
  98. package/dist/lint/post-synth/wk8405.js +2 -2
  99. package/dist/lint/post-synth/wk8406.d.ts.map +1 -1
  100. package/dist/lint/post-synth/wk8406.js +3 -2
  101. package/dist/lint/post-synth/wk8407.js +2 -2
  102. package/dist/lint/post-synth/wk8503.js +2 -2
  103. package/dist/manifest.json +1 -1
  104. package/dist/reference-catalog.d.ts +3 -1
  105. package/dist/reference-catalog.d.ts.map +1 -1
  106. package/dist/reference-catalog.js +283 -15
  107. package/dist/rules/argo-helpers.ts +9 -2
  108. package/dist/rules/argo002.ts +2 -1
  109. package/dist/rules/argo003.ts +2 -1
  110. package/dist/rules/argo005.ts +36 -10
  111. package/dist/rules/crd-schema-helpers.ts +3 -3
  112. package/dist/rules/flux002.ts +2 -1
  113. package/dist/rules/flux003.ts +2 -1
  114. package/dist/rules/k8s-helpers.ts +56 -11
  115. package/dist/rules/wk8005.ts +56 -3
  116. package/dist/rules/wk8006.ts +4 -2
  117. package/dist/rules/wk8041.ts +3 -2
  118. package/dist/rules/wk8042.ts +2 -2
  119. package/dist/rules/wk8101.ts +2 -2
  120. package/dist/rules/wk8102.ts +7 -3
  121. package/dist/rules/wk8103.ts +3 -2
  122. package/dist/rules/wk8104.ts +3 -2
  123. package/dist/rules/wk8105.ts +3 -2
  124. package/dist/rules/wk8201.ts +3 -2
  125. package/dist/rules/wk8202.ts +3 -2
  126. package/dist/rules/wk8203.ts +3 -2
  127. package/dist/rules/wk8204.ts +5 -2
  128. package/dist/rules/wk8205.ts +3 -2
  129. package/dist/rules/wk8207.ts +2 -2
  130. package/dist/rules/wk8208.ts +2 -2
  131. package/dist/rules/wk8209.ts +2 -2
  132. package/dist/rules/wk8301.ts +3 -2
  133. package/dist/rules/wk8302.ts +2 -2
  134. package/dist/rules/wk8303.ts +2 -2
  135. package/dist/rules/wk8304.ts +2 -2
  136. package/dist/rules/wk8305.ts +2 -2
  137. package/dist/rules/wk8306.ts +3 -2
  138. package/dist/rules/wk8401.ts +2 -2
  139. package/dist/rules/wk8402.ts +2 -2
  140. package/dist/rules/wk8403.ts +2 -2
  141. package/dist/rules/wk8404.ts +2 -1
  142. package/dist/rules/wk8405.ts +2 -2
  143. package/dist/rules/wk8406.ts +3 -2
  144. package/dist/rules/wk8407.ts +2 -2
  145. package/dist/rules/wk8503.ts +2 -2
  146. package/dist/workspace-member.d.ts +15 -3
  147. package/dist/workspace-member.d.ts.map +1 -1
  148. package/dist/workspace-member.js +151 -21
  149. package/package.json +5 -5
  150. package/src/application-paths.ts +96 -0
  151. package/src/application-set.test.ts +130 -0
  152. package/src/application-set.ts +336 -0
  153. package/src/cluster-secret.test.ts +117 -0
  154. package/src/cluster-secret.ts +76 -0
  155. package/src/components/kustomize-apply.ts +7 -1
  156. package/src/config-schema.ts +6 -2
  157. package/src/config.ts +24 -4
  158. package/src/helm-references.test.ts +149 -0
  159. package/src/helm-references.ts +425 -0
  160. package/src/import/generator.test.ts +57 -0
  161. package/src/import/generator.ts +35 -61
  162. package/src/import/parser.test.ts +59 -0
  163. package/src/import/parser.ts +38 -5
  164. package/src/import/roundtrip-build.test.ts +91 -0
  165. package/src/import/typed-classes.ts +168 -0
  166. package/src/kustomize/helm.test.ts +183 -0
  167. package/src/kustomize/render.ts +142 -6
  168. package/src/kustomize/root.ts +8 -3
  169. package/src/lint/post-synth/argo-helpers.ts +9 -2
  170. package/src/lint/post-synth/argo002.ts +2 -1
  171. package/src/lint/post-synth/argo003.ts +2 -1
  172. package/src/lint/post-synth/argo005.ts +36 -10
  173. package/src/lint/post-synth/audit-identity.test.ts +65 -0
  174. package/src/lint/post-synth/crd-schema-helpers.ts +3 -3
  175. package/src/lint/post-synth/flux002.ts +2 -1
  176. package/src/lint/post-synth/flux003.ts +2 -1
  177. package/src/lint/post-synth/k8s-helpers.ts +56 -11
  178. package/src/lint/post-synth/post-synth.test.ts +144 -0
  179. package/src/lint/post-synth/wk8005.ts +56 -3
  180. package/src/lint/post-synth/wk8006.ts +4 -2
  181. package/src/lint/post-synth/wk8041.ts +3 -2
  182. package/src/lint/post-synth/wk8042.ts +2 -2
  183. package/src/lint/post-synth/wk8101.ts +2 -2
  184. package/src/lint/post-synth/wk8102.ts +7 -3
  185. package/src/lint/post-synth/wk8103.ts +3 -2
  186. package/src/lint/post-synth/wk8104.ts +3 -2
  187. package/src/lint/post-synth/wk8105.ts +3 -2
  188. package/src/lint/post-synth/wk8201.ts +3 -2
  189. package/src/lint/post-synth/wk8202.ts +3 -2
  190. package/src/lint/post-synth/wk8203.ts +3 -2
  191. package/src/lint/post-synth/wk8204.ts +5 -2
  192. package/src/lint/post-synth/wk8205.ts +3 -2
  193. package/src/lint/post-synth/wk8207.ts +2 -2
  194. package/src/lint/post-synth/wk8208.ts +2 -2
  195. package/src/lint/post-synth/wk8209.ts +2 -2
  196. package/src/lint/post-synth/wk8301.ts +3 -2
  197. package/src/lint/post-synth/wk8302.ts +2 -2
  198. package/src/lint/post-synth/wk8303.ts +2 -2
  199. package/src/lint/post-synth/wk8304.ts +2 -2
  200. package/src/lint/post-synth/wk8305.ts +2 -2
  201. package/src/lint/post-synth/wk8306.ts +3 -2
  202. package/src/lint/post-synth/wk8401.ts +2 -2
  203. package/src/lint/post-synth/wk8402.ts +2 -2
  204. package/src/lint/post-synth/wk8403.ts +2 -2
  205. package/src/lint/post-synth/wk8404.ts +2 -1
  206. package/src/lint/post-synth/wk8405.ts +2 -2
  207. package/src/lint/post-synth/wk8406.ts +3 -2
  208. package/src/lint/post-synth/wk8407.ts +2 -2
  209. package/src/lint/post-synth/wk8503.ts +2 -2
  210. package/src/reference-catalog.test.ts +78 -0
  211. package/src/reference-catalog.ts +297 -16
  212. package/src/testdata/helm-chart-missing/kustomization.yaml +8 -0
  213. package/src/testdata/helm-chart-root/charts/webchart/Chart.yaml +3 -0
  214. package/src/testdata/helm-chart-root/charts/webchart/templates/configmap.yaml +6 -0
  215. package/src/testdata/helm-chart-root/charts/webchart/values.yaml +1 -0
  216. package/src/testdata/helm-chart-root/kustomization.yaml +9 -0
  217. package/src/testdata/helm-chart-root/values.yaml +1 -0
  218. package/src/testdata/workspace-members/argo-clusters/clusters.yaml +34 -0
  219. package/src/testdata/workspace-members/argo-set/all.yaml +43 -0
  220. package/src/testdata/workspace-members/plain/deploy.yaml +27 -0
  221. package/src/testdata/workspace-members/plain/es.yaml +15 -0
  222. package/src/testdata/workspace-members/templated/block.yaml +6 -0
  223. package/src/testdata/workspace-members/templated/chart-cm.yaml +4 -0
  224. package/src/testdata/workspace-members/templated/cm.yaml +6 -0
  225. package/src/workspace-kinds.test.ts +9 -1
  226. package/src/workspace-member.test.ts +69 -3
  227. package/src/workspace-member.ts +165 -24
  228. package/workspace-kinds.json +45 -6
@@ -5,7 +5,7 @@
5
5
  * PodDisruptionBudget (PDB) to ensure minimum availability during
6
6
  * voluntary disruptions like node drains and cluster upgrades.
7
7
  */
8
- import { docsToManifests } from "./k8s-helpers.js";
8
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8303 = {
10
10
  id: "WK8303",
11
11
  description: "PDB recommended for HA Deployments — ensures availability during voluntary disruptions",
@@ -24,7 +24,7 @@ export const wk8303 = {
24
24
  // Only check HA deployments (replicas >= 2)
25
25
  if (typeof replicas !== "number" || replicas < 2)
26
26
  continue;
27
- const resourceName = manifest.metadata?.name ?? "Deployment";
27
+ const resourceName = nameOf(manifest, "Deployment");
28
28
  // Check if any PDB targets this Deployment's labels
29
29
  const selector = spec.selector;
30
30
  const matchLabels = selector?.matchLabels;
@@ -5,7 +5,7 @@
5
5
  * annotation set but are missing `alb.ingress.kubernetes.io/certificate-arn`
6
6
  * or don't have HTTPS in their listen-ports.
7
7
  */
8
- import { docsToManifests } from "./k8s-helpers.js";
8
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8304 = {
10
10
  id: "WK8304",
11
11
  description: "SSL redirect without certificate — ssl-redirect annotation requires a valid certificate-arn and HTTPS listen-ports",
@@ -20,7 +20,7 @@ export const wk8304 = {
20
20
  const sslRedirect = annotations["alb.ingress.kubernetes.io/ssl-redirect"];
21
21
  if (!sslRedirect)
22
22
  continue;
23
- const resourceName = manifest.metadata?.name ?? "Ingress";
23
+ const resourceName = nameOf(manifest, "Ingress");
24
24
  const certArn = annotations["alb.ingress.kubernetes.io/certificate-arn"];
25
25
  if (!certArn) {
26
26
  diagnostics.push({
@@ -4,7 +4,7 @@
4
4
  * Flags Ingress backends whose `service.port.number` does not match
5
5
  * any declared port on the referenced Service in the manifest set.
6
6
  */
7
- import { docsToManifests } from "./k8s-helpers.js";
7
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
8
8
  export const wk8305 = {
9
9
  id: "WK8305",
10
10
  description: "Ingress port not matching Service — backend port must match a declared Service port",
@@ -16,7 +16,7 @@ export const wk8305 = {
16
16
  for (const manifest of manifests) {
17
17
  if (manifest.kind !== "Ingress")
18
18
  continue;
19
- const ingressName = manifest.metadata?.name ?? "Ingress";
19
+ const ingressName = nameOf(manifest, "Ingress");
20
20
  const ingressNamespace = manifest.metadata?.namespace ?? "default";
21
21
  const spec = manifest.spec;
22
22
  if (!spec)
@@ -1 +1 @@
1
- {"version":3,"file":"wk8306.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8306.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAgCpB,CAAC"}
1
+ {"version":3,"file":"wk8306.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8306.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAiCpB,CAAC"}
@@ -6,7 +6,7 @@
6
6
  * This causes OCI runtime errors because the container runtime tries to
7
7
  * execute the flag as a binary.
8
8
  */
9
- import { docsToManifests, extractContainers, WORKLOAD_KINDS } from "./k8s-helpers.js";
9
+ import { docsToManifests, extractContainers, containerLocator, WORKLOAD_KINDS, nameOf } from "./k8s-helpers.js";
10
10
  export const wk8306 = {
11
11
  id: "WK8306",
12
12
  description: "Container command starts with flag — first element should be a binary, not a flag",
@@ -15,7 +15,7 @@ export const wk8306 = {
15
15
  for (const manifest of docsToManifests(ctx)) {
16
16
  if (!manifest.kind || !WORKLOAD_KINDS.has(manifest.kind))
17
17
  continue;
18
- const resourceName = manifest.metadata?.name ?? manifest.kind;
18
+ const resourceName = nameOf(manifest, manifest.kind);
19
19
  const containers = extractContainers(manifest);
20
20
  for (const container of containers) {
21
21
  const command = container.command;
@@ -28,6 +28,7 @@ export const wk8306 = {
28
28
  severity: "error",
29
29
  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`,
30
30
  entity: resourceName,
31
+ locator: containerLocator(manifest, container),
31
32
  lexicon: "k8s",
32
33
  });
33
34
  }
@@ -6,7 +6,7 @@
6
6
  * sizeLimit exceeds the container's memory limit the pod will never schedule
7
7
  * (Kubelet rejects it with "Invalid value … must be less than or equal to memory limit").
8
8
  */
9
- import { docsToManifests, parseMemoryBytes } from "./k8s-helpers.js";
9
+ import { docsToManifests, parseMemoryBytes, nameOf } from "./k8s-helpers.js";
10
10
  export const wk8401 = {
11
11
  id: "WK8401",
12
12
  description: "shmSize must not exceed the container memory limit — pod will not schedule if it does",
@@ -15,7 +15,7 @@ export const wk8401 = {
15
15
  for (const manifest of docsToManifests(ctx)) {
16
16
  if (manifest.kind !== "RayCluster")
17
17
  continue;
18
- const clusterName = manifest.metadata?.name ?? "RayCluster";
18
+ const clusterName = nameOf(manifest, "RayCluster");
19
19
  const spec = manifest.spec;
20
20
  if (!spec)
21
21
  continue;
@@ -5,7 +5,7 @@
5
5
  * Without it, KubeRay defaults to the "latest" tag — autoscaler and Ray head
6
6
  * may run mismatched versions, leading to silent protocol failures.
7
7
  */
8
- import { docsToManifests } from "./k8s-helpers.js";
8
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8402 = {
10
10
  id: "WK8402",
11
11
  description: "RayCluster should set spec.rayVersion so KubeRay selects the correct autoscaler image",
@@ -14,7 +14,7 @@ export const wk8402 = {
14
14
  for (const manifest of docsToManifests(ctx)) {
15
15
  if (manifest.kind !== "RayCluster")
16
16
  continue;
17
- const name = manifest.metadata?.name ?? "RayCluster";
17
+ const name = nameOf(manifest, "RayCluster");
18
18
  const rayVersion = manifest.spec?.rayVersion;
19
19
  if (!rayVersion) {
20
20
  diagnostics.push({
@@ -5,7 +5,7 @@
5
5
  * container image tag, the KubeRay autoscaler sidecar will run a different
6
6
  * Ray version than the cluster. This can cause gRPC compatibility failures.
7
7
  */
8
- import { docsToManifests, extractRayVersion } from "./k8s-helpers.js";
8
+ import { docsToManifests, extractRayVersion, nameOf } from "./k8s-helpers.js";
9
9
  export const wk8403 = {
10
10
  id: "WK8403",
11
11
  description: "spec.rayVersion should match the Ray version in the head container image tag",
@@ -14,7 +14,7 @@ export const wk8403 = {
14
14
  for (const manifest of docsToManifests(ctx)) {
15
15
  if (manifest.kind !== "RayCluster")
16
16
  continue;
17
- const clusterName = manifest.metadata?.name ?? "RayCluster";
17
+ const clusterName = nameOf(manifest, "RayCluster");
18
18
  const spec = manifest.spec;
19
19
  if (!spec)
20
20
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"wk8404.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8404.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAU9G,eAAO,MAAM,MAAM,EAAE,cA4BpB,CAAC"}
1
+ {"version":3,"file":"wk8404.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8404.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAW9G,eAAO,MAAM,MAAM,EAAE,cA4BpB,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * default). The pod sits `Pending` with `0/N nodes are available` until a
8
8
  * toleration is added.
9
9
  */
10
- import { docsToManifests, extractContainers, extractPodSpec, requestsGpu, toleratesGpu, GPU_POD_KINDS, } from "./k8s-helpers.js";
10
+ import { docsToManifests, extractContainers, extractPodSpec, requestsGpu, toleratesGpu, GPU_POD_KINDS, nameOf, } from "./k8s-helpers.js";
11
11
  export const wk8404 = {
12
12
  id: "WK8404",
13
13
  description: "GPU request without a matching nvidia.com/gpu toleration",
@@ -22,7 +22,7 @@ export const wk8404 = {
22
22
  const podSpec = extractPodSpec(manifest);
23
23
  if (toleratesGpu(podSpec?.tolerations))
24
24
  continue;
25
- const resourceName = manifest.metadata?.name ?? manifest.kind;
25
+ const resourceName = nameOf(manifest, manifest.kind);
26
26
  diagnostics.push({
27
27
  checkId: "WK8404",
28
28
  severity: "error",
@@ -8,7 +8,7 @@
8
8
  * upgrade), taking the model endpoint down. Serving workloads should ship
9
9
  * with a PDB.
10
10
  */
11
- import { docsToManifests } from "./k8s-helpers.js";
11
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
12
12
  /** `app.kubernetes.io/component` values this lexicon's composites use for serving workloads. */
13
13
  const SERVING_COMPONENTS = new Set(["inference-service", "vllm-serving-runtime", "model-serving"]);
14
14
  function isServingWorkload(manifest) {
@@ -30,7 +30,7 @@ export const wk8405 = {
30
30
  if (!isServingWorkload(manifest))
31
31
  continue;
32
32
  const labels = manifest.metadata?.labels;
33
- const resourceName = manifest.metadata?.name ?? manifest.kind ?? "workload";
33
+ const resourceName = nameOf(manifest, manifest.kind ?? "workload");
34
34
  if (!labels || !hasCoveringPdb(labels, pdbSelectors)) {
35
35
  diagnostics.push({
36
36
  checkId: "WK8405",
@@ -1 +1 @@
1
- {"version":3,"file":"wk8406.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8406.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cAyCpB,CAAC"}
1
+ {"version":3,"file":"wk8406.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/wk8406.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,MAAM,EAAE,cA0CpB,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * check is scoped to GPU-requesting containers specifically, since GPU node
8
8
  * capacity is costlier and more contended than a general-purpose pool.
9
9
  */
10
- import { docsToManifests, extractContainers, GPU_POD_KINDS, NVIDIA_GPU_RESOURCE } from "./k8s-helpers.js";
10
+ import { docsToManifests, extractContainers, containerLocator, GPU_POD_KINDS, NVIDIA_GPU_RESOURCE, nameOf } from "./k8s-helpers.js";
11
11
  export const wk8406 = {
12
12
  id: "WK8406",
13
13
  description: "GPU-requesting container has no cpu/memory resource limits",
@@ -17,7 +17,7 @@ export const wk8406 = {
17
17
  if (!manifest.kind || !GPU_POD_KINDS.has(manifest.kind))
18
18
  continue;
19
19
  const containers = extractContainers(manifest);
20
- const resourceName = manifest.metadata?.name ?? manifest.kind;
20
+ const resourceName = nameOf(manifest, manifest.kind);
21
21
  for (const container of containers) {
22
22
  const requests = container.resources?.requests;
23
23
  const limits = container.resources?.limits;
@@ -40,6 +40,7 @@ export const wk8406 = {
40
40
  severity: "warning",
41
41
  message: `GPU container "${container.name ?? "(unnamed)"}" in ${manifest.kind} "${resourceName}" is missing resource limits for ${missing.join(", ")} — a GPU pod without cpu/memory limits can starve its (scarce, expensive) node`,
42
42
  entity: resourceName,
43
+ locator: containerLocator(manifest, container),
43
44
  lexicon: "k8s",
44
45
  });
45
46
  }
@@ -10,7 +10,7 @@
10
10
  * `"latest"`/`"main"`). An unpinned reference means a redeploy of the same
11
11
  * InferenceService can silently pick up different weights.
12
12
  */
13
- import { docsToManifests } from "./k8s-helpers.js";
13
+ import { docsToManifests, nameOf } from "./k8s-helpers.js";
14
14
  /** Trailing path segments that mean "no explicit version" even though present. */
15
15
  const FLOATING_TAGS = new Set(["latest", "main", "master", "head"]);
16
16
  /**
@@ -43,7 +43,7 @@ export const wk8407 = {
43
43
  if (!storageUri)
44
44
  continue;
45
45
  if (!isPinnedStorageUri(storageUri)) {
46
- const resourceName = manifest.metadata?.name ?? "InferenceService";
46
+ const resourceName = nameOf(manifest, "InferenceService");
47
47
  diagnostics.push({
48
48
  checkId: "WK8407",
49
49
  severity: "warning",
@@ -1,5 +1,5 @@
1
1
  import { collectSecretDeclarations } from "@intentius/chant/secret-provenance";
2
- import { extractPodSpec } from "./k8s-helpers.js";
2
+ import { extractPodSpec, nameOf } from "./k8s-helpers.js";
3
3
  import { allManifests } from "./argo-helpers.js";
4
4
  import { resolveEncryptedSecretClaims } from "./sops-helpers.js";
5
5
  function asRecord(value) {
@@ -136,7 +136,7 @@ export const wk8503 = {
136
136
  const podSpec = extractPodSpec(manifest);
137
137
  if (!podSpec)
138
138
  continue;
139
- const workload = manifest.metadata?.name ?? manifest.kind ?? "workload";
139
+ const workload = nameOf(manifest, manifest.kind ?? "workload");
140
140
  const namespace = manifest.metadata?.namespace;
141
141
  const reported = new Set();
142
142
  for (const ref of collectSecretRefs(podSpec)) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k8s",
3
- "version": "0.124.97",
3
+ "version": "0.124.98",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "K8s",
6
6
  "intrinsics": [],
@@ -1,3 +1,5 @@
1
- import type { ReferenceCatalog } from "@intentius/chant/graph-refs";
1
+ import { type ReferenceCatalog } from "@intentius/chant/graph-refs";
2
+ export declare const GKE_ANNOTATION = "metadata.annotations[\"iam.gke.io/gcp-service-account\"]";
3
+ export declare const EKS_ANNOTATION = "metadata.annotations[\"eks.amazonaws.com/role-arn\"]";
2
4
  export declare const k8sReferenceCatalog: ReferenceCatalog;
3
5
  //# sourceMappingURL=reference-catalog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference-catalog.d.ts","sourceRoot":"","sources":["../src/reference-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,gBAAgB,EAAW,MAAM,6BAA6B,CAAC;AA4J3F,eAAO,MAAM,mBAAmB,EAAE,gBAAuC,CAAC"}
1
+ {"version":3,"file":"reference-catalog.d.ts","sourceRoot":"","sources":["../src/reference-catalog.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkE,KAAK,gBAAgB,EAAgC,MAAM,6BAA6B,CAAC;AA6SlK,eAAO,MAAM,cAAc,6DAA2D,CAAC;AACvF,eAAO,MAAM,cAAc,yDAAuD,CAAC;AAkInF,eAAO,MAAM,mBAAmB,EAAE,gBAA2I,CAAC"}
@@ -1,3 +1,8 @@
1
+ import { k8sDeclaredNode, registersCluster } from "./cluster-secret.js";
2
+ import { APPLICATION, APPLICATION_SET, generateApplications } from "./application-set.js";
3
+ import { applicationPathRules } from "./application-paths.js";
4
+ import { generatedValuesNodes } from "./helm-references.js";
5
+ import { readPath } from "@intentius/chant/graph-refs";
1
6
  /**
2
7
  * Kubernetes reference catalog (#4535): how Kubernetes objects name each
3
8
  * other, so chant's catalog pass (`reconstructIndexedEdges`, #4522) draws
@@ -15,9 +20,12 @@
15
20
  * object's location is its namespace (behold#1025), so the scoped join key
16
21
  * (behold#1023's ruling) keeps a `serviceAccountName: default` inside its own
17
22
  * namespace, and a namespaced holder also reaches cluster-scoped objects (a
18
- * `Namespace`, a `ClusterRole`, a `StorageClass`). A declared graph is one
19
- * scope, so two `default` service accounts in two namespaces make that
20
- * reference ambiguous there, and it draws no edge.
23
+ * `Namespace`, a `ClusterRole`, a `StorageClass`). On a declared graph,
24
+ * `chant workspace graph`'s catalog pass (#5097) reads the namespace from
25
+ * `metadata.namespace` through `scopes`, so a name joins across members
26
+ * inside one namespace, and a namespaced object that names none stays inside
27
+ * its own member. Two objects that match one name in one namespace make the
28
+ * reference ambiguous, and it draws no edge.
21
29
  *
22
30
  * ## Multi-kind fields
23
31
  *
@@ -33,17 +41,87 @@
33
41
  * env-value rules join such a value to an `AWS::S3::Bucket` of that name, and
34
42
  * are `optional`, since most env values name nothing. Over an index the
35
43
  * cluster and the AWS account are two scopes, so the join only draws on a
36
- * declared graph (one scope), which is where behold's matcher drew it.
44
+ * declared graph, where a cloud resource sits in the scope every namespace
45
+ * reaches, which is where behold's matcher drew it.
46
+ *
47
+ * ## External Secrets (#5098)
48
+ *
49
+ * An `ExternalSecret` names a store, and through it a secret in a cloud
50
+ * secret manager. Both are rules with a `join`, since neither is one value
51
+ * naming one node. The store rule reads `spec.secretStoreRef.name` as a
52
+ * `SecretStore` in the holder's namespace or a cluster-scoped
53
+ * `ClusterSecretStore`, as `spec.secretStoreRef.kind` says (absent is
54
+ * `SecretStore`, the operator's default): one rule per kind, each reading
55
+ * only the references of its own. The secret rule reads
56
+ * `spec.data[].remoteRef.key` and `spec.dataFrom[].extract.key` and joins
57
+ * the key to the cloud secret inside the scope the store names: a GCP store's
58
+ * `projectID` with a `google_secret_manager_secret`'s `secret_id` and
59
+ * `project`, an AWS Secrets Manager store's `region` with an
60
+ * `aws_secretsmanager_secret`'s `name`. The edge's `viaAttr` is
61
+ * `remoteRef.key via <store name>`, and a key that names no secret is
62
+ * dangling with the store's node as `through`. A store that is not found
63
+ * is dangling under the store rule, and its keys are not read. A Terraform
64
+ * argument that is not literal is not read (the pass counts it), so a secret
65
+ * whose `secret_id` or `project` is a variable matches nothing. An AWS secret
66
+ * matches on its name alone when it sets no literal `region`.
67
+ *
68
+ * ## Argo CD clusters (#5101)
69
+ *
70
+ * An Application's `spec.destination.name` or `.server` joins the cluster
71
+ * Secret whose `name` or `server` it is, and a cluster Secret's `name` joins
72
+ * the managed Kubernetes cluster block of that literal name in the terraform
73
+ * catalog. The Secret's values are read from `argoCluster` (./cluster-secret.ts),
74
+ * which only a cluster Secret has, decoded from `data` when it wrote them
75
+ * there. Application is scoped by `metadata.namespace` like the Secret, but is
76
+ * not a named kind, so it has no containment rule to a Namespace.
77
+ *
78
+ * ## ApplicationSets (#5102)
79
+ *
80
+ * An ApplicationSet's `list` and `clusters` generators are expanded into the
81
+ * Applications they generate (./application-set.ts), one node each, under the
82
+ * `generates` rule. An Application a `clusters` generator made for a cluster
83
+ * Secret joins that Secret under `generators[].clusters`, since the
84
+ * generator selected it; the destination rules draw no second edge for the
85
+ * pair. The other rules read a generated Application as one written by hand. The path rules
86
+ * (./application-paths.ts) read the directories and values files every
87
+ * Application names, and the pass lists one the repository does not have as
88
+ * dangling.
37
89
  *
38
90
  * ## What this does not do
39
91
  *
40
- * - Label selectors. A Service selects pods by labels, and the standard keys
41
- * (`app.kubernetes.io/name`) contain dots, which `readPath` reads as path
42
- * separators. Only the bare `app` label is matched: a Service's
43
- * `spec.selector.app` to a workload whose pod template carries the same
44
- * `app` label. behold's own k8s pass (src/k8s-edges.ts) still joins full
92
+ * - Stores other than GCP and AWS Secrets Manager (IBM, Vault), the legacy
93
+ * `kubernetes-client.io` ExternalSecret, and the Secret an ExternalSecret
94
+ * writes (`spec.target.name`).
95
+ * - Label selectors. A Service selects pods by a set of labels, and a rule
96
+ * matches one value at one path, so a selector on the standard keys
97
+ * (`app.kubernetes.io/name`) is not read. Only the bare `app` label is
98
+ * matched: a Service's `spec.selector.app` to a workload whose pod
99
+ * template carries the same `app` label. behold's own k8s pass (src/k8s-edges.ts) still joins full
45
100
  * selectors on behold's side.
46
- * - Annotations, for the same reason (`eks.amazonaws.com/role-arn`).
101
+ *
102
+ * Annotation keys are reachable since #5097, as a quoted step:
103
+ * `metadata.annotations["eks.amazonaws.com/role-arn"]`. Rules that read them
104
+ * come with the issues that need them.
105
+ *
106
+ * ## Helm values files (#5100)
107
+ *
108
+ * An Argo CD Application or ApplicationSet and a kustomization with
109
+ * `helmCharts` name their values files in `helmReferences.valuesFiles[]`, a
110
+ * key the reader stamps with each file's workspace-relative path
111
+ * (./helm-references.ts). A file that exists and parses is a `Helm::Values`
112
+ * node identified by that path, so a name with no node is dangling with the
113
+ * path. The edges to the charts are not rules here: a chart is shared by every
114
+ * member that names it, so the helm lexicon's catalog makes the node.
115
+ *
116
+ * ## Adding a rule
117
+ *
118
+ * A rule is one entry in `refs`: the holder kind, the path, the target kind
119
+ * and a label, through `ref` (or `anyOf` for a field that can name several
120
+ * kinds). Its id is `k8s:<holder kind>:<path>`, which every edge, dangling
121
+ * entry and ambiguous entry it makes carries as `rule`. A target kind that
122
+ * other objects name by `metadata.name` goes in `NAMED_KINDS`, and a
123
+ * namespaced one in `NAMESPACED_KINDS` too. The test "each rule draws its
124
+ * edge" covers a new rule with no test of its own.
47
125
  */
48
126
  /** Workload kinds and the path to their pod spec. */
49
127
  const POD_SPECS = [
@@ -70,21 +148,44 @@ const NAMESPACED_KINDS = [
70
148
  "K8s::Rbac::Role",
71
149
  "K8s::Rbac::RoleBinding",
72
150
  ];
151
+ /**
152
+ * Namespaced kinds that are scoped and named but draw no `in namespace`
153
+ * containment (#5098): an ExternalSecret and a SecretStore reach a store by
154
+ * name inside their namespace, and a report of every one whose Namespace is
155
+ * declared nowhere would bury the references this catalog is for.
156
+ */
157
+ const SCOPED_KINDS = ["K8s::ExternalSecrets::ExternalSecret", "K8s::ExternalSecrets::SecretStore"];
73
158
  /** Kinds other objects name by `metadata.name`. */
74
159
  const NAMED_KINDS = [
75
160
  ...NAMESPACED_KINDS,
161
+ ...SCOPED_KINDS,
76
162
  "K8s::Core::Namespace",
77
163
  "K8s::Core::PersistentVolume",
78
164
  "K8s::Networking::IngressClass",
79
165
  "K8s::Storage::StorageClass",
80
166
  "K8s::Rbac::ClusterRole",
167
+ "K8s::ExternalSecrets::ClusterSecretStore",
81
168
  ];
82
169
  /** Workloads whose pod template a Service's `app` selector can match. */
83
170
  const SELECTED_WORKLOADS = ["K8s::Apps::Deployment", "K8s::Apps::StatefulSet", "K8s::Apps::DaemonSet"];
84
- const identities = NAMED_KINDS.map((kind) => ({
85
- kind,
86
- ids: SELECTED_WORKLOADS.includes(kind) ? ["metadata.name", "spec.template.metadata.labels.app"] : ["metadata.name"],
87
- }));
171
+ /**
172
+ * What else names a kind, beyond `metadata.name`: a workload by its pod
173
+ * template's `app` label, and a Secret by the `name` and `server` an Argo CD
174
+ * cluster registration holds (#5101). `k8sDeclaredNode` (./cluster-secret.ts)
175
+ * puts them under `argoCluster` on a cluster Secret and on no other, so a
176
+ * Secret with a `stringData.name` of its own is not read as one.
177
+ */
178
+ const EXTRA_IDS = {
179
+ ...Object.fromEntries(SELECTED_WORKLOADS.map((kind) => [kind, ["spec.template.metadata.labels.app"]])),
180
+ "K8s::Core::Secret": ["argoCluster.name", "argoCluster.server"],
181
+ };
182
+ /** Objects that can name a chart and the values files for it (#5100); the reader stamps `helmReferences` on them (./helm-references.ts). */
183
+ const HELM_HOLDERS = ["K8s::Argo::Application", "K8s::Argo::ApplicationSet", "K8s::Kustomize::Kustomization"];
184
+ const identities = [
185
+ ...NAMED_KINDS.map((kind) => ({ kind, ids: ["metadata.name", ...(EXTRA_IDS[kind] ?? [])] })),
186
+ // A values file is the helm lexicon's node, read by this lexicon's reader and named by its workspace-relative path (#5100).
187
+ { kind: "Helm::Values", ids: ["path"] },
188
+ ];
88
189
  const ref = (from, path, targetKind, label, relation = "reference") => ({ from, path, targetKind, relation, label });
89
190
  const anyOf = (from, path, targetKinds, label) => targetKinds.map((targetKind) => ({ from, path, targetKind, relation: "reference", label, optional: true }));
90
191
  /** What a pod spec names: its service account, mounted config and secrets, claims, pull secrets. */
@@ -108,6 +209,143 @@ function podSpecRules(kind, p) {
108
209
  { from: kind, path: `${p}.containers[].env[].value`, targetKind: "AWS::S3::Bucket", relation: "reference", label: "uses bucket", optional: true },
109
210
  ];
110
211
  }
212
+ const EXTERNAL_SECRET = "K8s::ExternalSecrets::ExternalSecret";
213
+ const STORE_KINDS = ["K8s::ExternalSecrets::SecretStore", "K8s::ExternalSecrets::ClusterSecretStore"];
214
+ const SECRET_KEY_PATHS = ["spec.data[].remoteRef.key", "spec.dataFrom[].extract.key"];
215
+ const first = (node, path) => readPath(node.attrs, path).find((v) => v !== "");
216
+ /** The store kind an ExternalSecret names: `SecretStore` unless it says otherwise. */
217
+ const storeKindOf = (holder) => `K8s::ExternalSecrets::${first(holder, "spec.secretStoreRef.kind") ?? "SecretStore"}`;
218
+ /** The store rule for one store kind: reads only the ExternalSecrets that name a store of that kind. */
219
+ function storeRule(targetKind) {
220
+ return {
221
+ from: EXTERNAL_SECRET,
222
+ path: "spec.secretStoreRef.name",
223
+ targetKind,
224
+ relation: "reference",
225
+ label: "reads through",
226
+ join(holder, find) {
227
+ const name = first(holder, "spec.secretStoreRef.name");
228
+ if (name === undefined || storeKindOf(holder) !== targetKind)
229
+ return [];
230
+ return [{ value: name, targets: find(name).filter((n) => n.kind === targetKind), via: "secretStoreRef" }];
231
+ },
232
+ };
233
+ }
234
+ /** The one store an ExternalSecret reads through, or undefined when it is missing or ambiguous (the store rule reports that). */
235
+ function storeOf(holder, find) {
236
+ const name = first(holder, "spec.secretStoreRef.name");
237
+ if (name === undefined)
238
+ return undefined;
239
+ const stores = find(name).filter((n) => n.kind === storeKindOf(holder));
240
+ return stores.length === 1 ? stores[0] : undefined;
241
+ }
242
+ /**
243
+ * The secret rule for one key path and one secret manager: the cloud secret a
244
+ * key names inside the scope its store names, `inScope` deciding what counts
245
+ * as inside. Reads only the ExternalSecrets whose store is of `provider`.
246
+ */
247
+ function secretRule(path, targetKind, provider, inScope) {
248
+ return {
249
+ from: EXTERNAL_SECRET,
250
+ path,
251
+ targetKind,
252
+ relation: "reference",
253
+ label: "reads secret",
254
+ join(holder, find) {
255
+ const store = storeOf(holder, find);
256
+ const scope = store && provider(store);
257
+ if (!store || scope === undefined)
258
+ return [];
259
+ const refs = [];
260
+ for (const key of new Set(readPath(holder.attrs, path))) {
261
+ const targets = find(key).filter((n) => n.kind === targetKind && inScope(n, scope));
262
+ refs.push({ value: key, targets, via: `remoteRef.key via ${first(store, "metadata.name") ?? store.id}`, through: store });
263
+ }
264
+ return refs;
265
+ },
266
+ };
267
+ }
268
+ const gcpProject = (store) => first(store, "spec.provider.gcpsm.projectID");
269
+ const awsRegion = (store) => (first(store, "spec.provider.aws.service") === "SecretsManager" ? first(store, "spec.provider.aws.region") : undefined);
270
+ const externalSecretRules = [
271
+ ...STORE_KINDS.map(storeRule),
272
+ ...SECRET_KEY_PATHS.flatMap((path) => [
273
+ secretRule(path, "google_secret_manager_secret", gcpProject, (secret, project) => first(secret, "project") === project),
274
+ // The resource sets `region` only when it is not the provider's, so an AWS secret without one matches on its name.
275
+ secretRule(path, "aws_secretsmanager_secret", awsRegion, (secret, region) => (first(secret, "region") ?? region) === region),
276
+ ]),
277
+ ];
278
+ /**
279
+ * The cloud kinds a cluster Secret's `name` can be the literal name of (#5101).
280
+ * The `registers` rule has one entry per kind under one id, so the Secret
281
+ * dangles only when no kind matches.
282
+ */
283
+ const CLUSTER_KINDS = ["google_container_cluster", "aws_eks_cluster", "azurerm_kubernetes_cluster"];
284
+ const SERVICE_ACCOUNT = "K8s::Core::ServiceAccount";
285
+ export const GKE_ANNOTATION = 'metadata.annotations["iam.gke.io/gcp-service-account"]';
286
+ export const EKS_ANNOTATION = 'metadata.annotations["eks.amazonaws.com/role-arn"]';
287
+ const GCP_EMAIL = /^([a-z][a-z0-9-]*)@([a-z][a-z0-9-]*)\.iam\.gserviceaccount\.com$/i;
288
+ const AWS_ROLE_ARN = /^arn:aws[a-z-]*:iam::(\d{12}):role\/(?:(.*)\/)?([^/]+)$/;
289
+ /**
290
+ * The cloud identity a ServiceAccount's annotation names (#5099). Neither
291
+ * value is one identifier a target carries, so both are rules with a `join`:
292
+ *
293
+ * - GKE Workload Identity, `iam.gke.io/gcp-service-account`. The email is
294
+ * `<account_id>@<project>.iam.gserviceaccount.com`, and a
295
+ * `google_service_account` declares those two arguments while its email is
296
+ * computed. The rule finds the account by `account_id` and keeps the ones
297
+ * whose literal `project` is the email's, so two accounts of one id in
298
+ * different projects are told apart.
299
+ * - EKS IRSA, `eks.amazonaws.com/role-arn`. The role is found by the last
300
+ * segment of the ARN, kept when its literal `path` agrees with the ARN's
301
+ * and, if its literal `arn` is set, the account id agrees too. Terraform
302
+ * does not hold the account id otherwise, so a role with no `arn` argument
303
+ * is matched on its name and path.
304
+ *
305
+ * A value of another shape names no node, so it is dangling.
306
+ */
307
+ const identityRules = [
308
+ {
309
+ from: SERVICE_ACCOUNT,
310
+ path: GKE_ANNOTATION,
311
+ targetKind: "google_service_account",
312
+ relation: "reference",
313
+ label: "acts as",
314
+ join(holder, find) {
315
+ const email = first(holder, GKE_ANNOTATION);
316
+ if (email === undefined)
317
+ return [];
318
+ const m = GCP_EMAIL.exec(email);
319
+ const targets = m ? find(m[1]).filter((n) => n.kind === "google_service_account" && first(n, "account_id") === m[1] && first(n, "project") === m[2]) : [];
320
+ return [{ value: email, targets, via: "iam.gke.io/gcp-service-account" }];
321
+ },
322
+ },
323
+ {
324
+ from: SERVICE_ACCOUNT,
325
+ path: EKS_ANNOTATION,
326
+ targetKind: "aws_iam_role",
327
+ relation: "reference",
328
+ label: "acts as",
329
+ join(holder, find) {
330
+ const arn = first(holder, EKS_ANNOTATION);
331
+ if (arn === undefined)
332
+ return [];
333
+ const m = AWS_ROLE_ARN.exec(arn);
334
+ const targets = m
335
+ ? find(m[3]).filter((n) => {
336
+ if (n.kind !== "aws_iam_role" || first(n, "name") !== m[3])
337
+ return false;
338
+ const path = first(n, "path");
339
+ if (path !== undefined && path.replace(/^\/|\/$/g, "") !== (m[2] ?? ""))
340
+ return false;
341
+ const own = first(n, "arn")?.match(/^arn:aws[a-z-]*:iam::(\d{12}):/);
342
+ return own === null || own === undefined || own[1] === m[1];
343
+ })
344
+ : [];
345
+ return [{ value: arn, targets, via: "eks.amazonaws.com/role-arn" }];
346
+ },
347
+ },
348
+ ];
111
349
  const refs = [
112
350
  // ── containment: the namespace an object is in ──
113
351
  ...NAMESPACED_KINDS.map((kind) => ref(kind, "metadata.namespace", "K8s::Core::Namespace", "in namespace", "containment")),
@@ -123,6 +361,10 @@ const refs = [
123
361
  ref("K8s::Networking::Ingress", "spec.defaultBackend.service.name", "K8s::Core::Service", "routes to"),
124
362
  ref("K8s::Networking::Ingress", "spec.tls[].secretName", "K8s::Core::Secret", "tls"),
125
363
  ref("K8s::Networking::Ingress", "spec.ingressClassName", "K8s::Networking::IngressClass", "class"),
364
+ // ── Argo CD (#5101): where an Application deploys, and the cluster a registration names ──
365
+ ...anyOf("K8s::Argo::Application", "spec.destination.name", ["K8s::Core::Secret"], "deploys to"),
366
+ ...anyOf("K8s::Argo::Application", "spec.destination.server", ["K8s::Core::Secret"], "deploys to"),
367
+ ...CLUSTER_KINDS.map((kind) => ref("K8s::Core::Secret", "argoCluster.name", kind, "registers")),
126
368
  // ── scaling, storage, RBAC ──
127
369
  ...anyOf("K8s::Autoscaling::HorizontalPodAutoscaler", "spec.scaleTargetRef.name", ["K8s::Apps::Deployment", "K8s::Apps::StatefulSet", "K8s::Apps::ReplicaSet"], "scales"),
128
370
  ref("K8s::Core::PersistentVolumeClaim", "spec.volumeName", "K8s::Core::PersistentVolume", "bound to"),
@@ -134,5 +376,31 @@ const refs = [
134
376
  ...anyOf("K8s::Rbac::ClusterRoleBinding", "subjects[].name", ["K8s::Core::ServiceAccount"], "grants"),
135
377
  ref("K8s::Core::ServiceAccount", "secrets[].name", "K8s::Core::Secret", "token"),
136
378
  ref("K8s::Core::ServiceAccount", "imagePullSecrets[].name", "K8s::Core::Secret", "pulls with"),
379
+ // ── External Secrets: the store, and the cloud secret through it ──
380
+ ...externalSecretRules,
381
+ // ── cloud identity: the account a ServiceAccount acts as ──
382
+ ...identityRules,
383
+ // ── Helm values files (#5100): a path that names no file is dangling ──
384
+ ...HELM_HOLDERS.map((kind) => ref(kind, "helmReferences.valuesFiles[]", "Helm::Values", "values")),
385
+ ];
386
+ /** A namespaced object's names are unique inside its namespace (#5097). */
387
+ const scopes = [
388
+ ...[...NAMESPACED_KINDS, ...SCOPED_KINDS, "K8s::Argo::Application"].map((kind) => ({ kind, path: "metadata.namespace" })),
389
+ // A values file is read once per member that names it, and is held by that member alone: every holder reaches the one in its own member (#5100).
390
+ { kind: "Helm::Values" },
391
+ ];
392
+ /** An ApplicationSet's generated Applications (#5102). */
393
+ const generates = [
394
+ {
395
+ from: APPLICATION_SET,
396
+ path: "spec.generators",
397
+ targetKind: APPLICATION,
398
+ label: "generates",
399
+ generate: generateApplications,
400
+ // A clusters generator selected the Secret, so the generated Application deploys to it whatever namespace either sits in.
401
+ cluster: { path: "generators[].clusters", targetKind: "K8s::Core::Secret", label: "deploys to" },
402
+ // A generated Application is stamped as the reader stamps one written by hand, so its values files and their extraObjects are nodes too (#5094).
403
+ files: generatedValuesNodes,
404
+ },
137
405
  ];
138
- export const k8sReferenceCatalog = { identities, refs };
406
+ export const k8sReferenceCatalog = { identities, refs, scopes, declaredNode: k8sDeclaredNode, registersCluster, generates, pathRefs: applicationPathRules };