@intentius/chant-lexicon-k8s 0.101.0 → 0.104.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 (266) hide show
  1. package/dist/actions/apps.d.ts +4 -4
  2. package/dist/actions/apps.d.ts.map +1 -1
  3. package/dist/actions/core.d.ts +5 -5
  4. package/dist/actions/core.d.ts.map +1 -1
  5. package/dist/actions/networking.d.ts.map +1 -1
  6. package/dist/codegen/generate-typescript.d.ts +2 -2
  7. package/dist/codegen/generate-typescript.d.ts.map +1 -1
  8. package/dist/codegen/generate.d.ts +26 -0
  9. package/dist/codegen/generate.d.ts.map +1 -1
  10. package/dist/codegen/naming.d.ts.map +1 -1
  11. package/dist/codegen/versions.d.ts.map +1 -1
  12. package/dist/components/capability-plugin.d.ts.map +1 -1
  13. package/dist/components/kubectl-apply.d.ts +4 -1
  14. package/dist/components/kubectl-apply.d.ts.map +1 -1
  15. package/dist/composites/catalog.d.ts.map +1 -1
  16. package/dist/composites/cockroachdb-cluster.d.ts +2 -2
  17. package/dist/composites/gke-otel-collector.d.ts.map +1 -1
  18. package/dist/composites/index.d.ts +1 -0
  19. package/dist/composites/index.d.ts.map +1 -1
  20. package/dist/composites/otel-collector-agent.d.ts +19 -1
  21. package/dist/composites/otel-collector-agent.d.ts.map +1 -1
  22. package/dist/composites/otel-collector-node.d.ts +88 -0
  23. package/dist/composites/otel-collector-node.d.ts.map +1 -0
  24. package/dist/composites/otel-collector-rbac.d.ts.map +1 -1
  25. package/dist/composites/otel-collector-shape.d.ts +3 -1
  26. package/dist/composites/otel-collector-shape.d.ts.map +1 -1
  27. package/dist/composites/otel-collector.d.ts +9 -1
  28. package/dist/composites/otel-collector.d.ts.map +1 -1
  29. package/dist/composites/ray-cluster.d.ts +6 -6
  30. package/dist/composites/ray-job.d.ts +5 -5
  31. package/dist/composites/ray-service.d.ts +6 -6
  32. package/dist/crd/crd-sources.d.ts.map +1 -1
  33. package/dist/crd/loader.d.ts.map +1 -1
  34. package/dist/crd/oci-chart.d.ts +50 -0
  35. package/dist/crd/oci-chart.d.ts.map +1 -0
  36. package/dist/crd/types.d.ts +5 -0
  37. package/dist/crd/types.d.ts.map +1 -1
  38. package/dist/effect-receipt-row.d.ts.map +1 -1
  39. package/dist/generated/index.d.ts +764 -729
  40. package/dist/generated/index.d.ts.map +1 -1
  41. package/dist/import/embedded.d.ts +4 -2
  42. package/dist/import/embedded.d.ts.map +1 -1
  43. package/dist/import/generator.d.ts.map +1 -1
  44. package/dist/import/parser.d.ts.map +1 -1
  45. package/dist/import/testdata/embedded/fixtures.d.ts +6 -0
  46. package/dist/import/testdata/embedded/fixtures.d.ts.map +1 -1
  47. package/dist/integrity.json +8 -7
  48. package/dist/lint/audit-catalog.d.ts.map +1 -1
  49. package/dist/lint/post-synth/index.d.ts.map +1 -1
  50. package/dist/lint/post-synth/otel-placement-helpers.d.ts.map +1 -1
  51. package/dist/lint/post-synth/wk8604.d.ts +3 -2
  52. package/dist/lint/post-synth/wk8604.d.ts.map +1 -1
  53. package/dist/lint/post-synth/wk8605.d.ts +23 -0
  54. package/dist/lint/post-synth/wk8605.d.ts.map +1 -0
  55. package/dist/manifest.json +1 -1
  56. package/dist/meta.json +194 -17
  57. package/dist/okf/index.md +5 -0
  58. package/dist/okf/rules/WK8605.md +11 -0
  59. package/dist/okf/types/APIGroup.md +3 -3
  60. package/dist/okf/types/APIGroupList.md +1 -1
  61. package/dist/okf/types/APIResourceList.md +1 -1
  62. package/dist/okf/types/APIService.md +1 -1
  63. package/dist/okf/types/APIServiceList.md +2 -2
  64. package/dist/okf/types/APIVersions.md +1 -1
  65. package/dist/okf/types/BatchJob.md +1 -1
  66. package/dist/okf/types/CSIDriver.md +1 -1
  67. package/dist/okf/types/CSIDriverList.md +2 -2
  68. package/dist/okf/types/CSINode.md +1 -1
  69. package/dist/okf/types/CSINodeList.md +2 -2
  70. package/dist/okf/types/CSIStorageCapacity.md +2 -2
  71. package/dist/okf/types/CSIStorageCapacityList.md +2 -2
  72. package/dist/okf/types/CertificateSigningRequest.md +1 -1
  73. package/dist/okf/types/CertificateSigningRequestList.md +2 -2
  74. package/dist/okf/types/ClusterRole.md +1 -1
  75. package/dist/okf/types/ClusterRoleBindingList.md +2 -2
  76. package/dist/okf/types/ClusterRoleList.md +2 -2
  77. package/dist/okf/types/ClusterTrustBundle.md +1 -1
  78. package/dist/okf/types/ClusterTrustBundleList.md +2 -2
  79. package/dist/okf/types/ComponentStatus.md +1 -1
  80. package/dist/okf/types/ComponentStatusList.md +2 -2
  81. package/dist/okf/types/ConfigMapList.md +2 -2
  82. package/dist/okf/types/ControllerRevisionList.md +2 -2
  83. package/dist/okf/types/CoreEventList.md +2 -2
  84. package/dist/okf/types/CronJob.md +1 -1
  85. package/dist/okf/types/CronJobList.md +2 -2
  86. package/dist/okf/types/CustomResourceDefinition.md +1 -1
  87. package/dist/okf/types/CustomResourceDefinitionList.md +2 -2
  88. package/dist/okf/types/DaemonSet.md +1 -1
  89. package/dist/okf/types/DaemonSetList.md +2 -2
  90. package/dist/okf/types/DeleteOptions.md +1 -1
  91. package/dist/okf/types/Deploy.md +1 -1
  92. package/dist/okf/types/DeploymentList.md +2 -2
  93. package/dist/okf/types/DeviceClass.md +1 -1
  94. package/dist/okf/types/DeviceClassList.md +2 -2
  95. package/dist/okf/types/DeviceTaintRule.md +1 -1
  96. package/dist/okf/types/DeviceTaintRuleList.md +2 -2
  97. package/dist/okf/types/EndpointSlice.md +2 -2
  98. package/dist/okf/types/EndpointSliceList.md +2 -2
  99. package/dist/okf/types/Endpoints.md +1 -1
  100. package/dist/okf/types/EndpointsList.md +2 -2
  101. package/dist/okf/types/Event.md +2 -2
  102. package/dist/okf/types/EventsEvent.md +2 -2
  103. package/dist/okf/types/EventsEventList.md +2 -2
  104. package/dist/okf/types/Eviction.md +1 -1
  105. package/dist/okf/types/FlowSchema.md +1 -1
  106. package/dist/okf/types/FlowSchemaList.md +2 -2
  107. package/dist/okf/types/GrafanaDashboard.md +14 -0
  108. package/dist/okf/types/GrafanaDatasource.md +14 -0
  109. package/dist/okf/types/GrafanaFolder.md +14 -0
  110. package/dist/okf/types/GrafanaLibraryPanel.md +14 -0
  111. package/dist/okf/types/HorizontalPodAutoscaler.md +1 -1
  112. package/dist/okf/types/HorizontalPodAutoscalerList.md +2 -2
  113. package/dist/okf/types/IPAddress.md +1 -1
  114. package/dist/okf/types/IPAddressList.md +2 -2
  115. package/dist/okf/types/Ing.md +1 -1
  116. package/dist/okf/types/IngressClass.md +1 -1
  117. package/dist/okf/types/IngressClassList.md +2 -2
  118. package/dist/okf/types/IngressList.md +2 -2
  119. package/dist/okf/types/JobList.md +2 -2
  120. package/dist/okf/types/Lease.md +1 -1
  121. package/dist/okf/types/LeaseCandidate.md +1 -1
  122. package/dist/okf/types/LeaseCandidateList.md +2 -2
  123. package/dist/okf/types/LeaseList.md +2 -2
  124. package/dist/okf/types/LimitRange.md +1 -1
  125. package/dist/okf/types/LimitRangeList.md +2 -2
  126. package/dist/okf/types/LocalSubjectAccessReview.md +1 -1
  127. package/dist/okf/types/MutatingAdmissionPolicy.md +1 -1
  128. package/dist/okf/types/MutatingAdmissionPolicyBinding.md +1 -1
  129. package/dist/okf/types/MutatingAdmissionPolicyBindingList.md +2 -2
  130. package/dist/okf/types/MutatingAdmissionPolicyList.md +2 -2
  131. package/dist/okf/types/MutatingWebhookConfiguration.md +1 -1
  132. package/dist/okf/types/MutatingWebhookConfigurationList.md +2 -2
  133. package/dist/okf/types/Namespace.md +1 -1
  134. package/dist/okf/types/NamespaceList.md +2 -2
  135. package/dist/okf/types/NetPol.md +1 -1
  136. package/dist/okf/types/NetworkPolicyList.md +2 -2
  137. package/dist/okf/types/Node.md +1 -1
  138. package/dist/okf/types/NodeList.md +2 -2
  139. package/dist/okf/types/PersistentVolume.md +1 -1
  140. package/dist/okf/types/PersistentVolumeClaimList.md +2 -2
  141. package/dist/okf/types/PersistentVolumeList.md +2 -2
  142. package/dist/okf/types/PodCertificateRequest.md +1 -1
  143. package/dist/okf/types/PodCertificateRequestList.md +2 -2
  144. package/dist/okf/types/PodDisruptionBudgetList.md +2 -2
  145. package/dist/okf/types/PodList.md +2 -2
  146. package/dist/okf/types/PodTemplateList.md +2 -2
  147. package/dist/okf/types/PriorityClassList.md +2 -2
  148. package/dist/okf/types/PriorityLevelConfiguration.md +1 -1
  149. package/dist/okf/types/PriorityLevelConfigurationList.md +2 -2
  150. package/dist/okf/types/ReplicaSet.md +1 -1
  151. package/dist/okf/types/ReplicaSetList.md +2 -2
  152. package/dist/okf/types/ReplicationController.md +1 -1
  153. package/dist/okf/types/ReplicationControllerList.md +2 -2
  154. package/dist/okf/types/ResourceClaim.md +1 -1
  155. package/dist/okf/types/ResourceClaimList.md +2 -2
  156. package/dist/okf/types/ResourceClaimTemplate.md +1 -1
  157. package/dist/okf/types/ResourceClaimTemplateList.md +2 -2
  158. package/dist/okf/types/ResourceQuota.md +1 -1
  159. package/dist/okf/types/ResourceQuotaList.md +2 -2
  160. package/dist/okf/types/ResourceSlice.md +1 -1
  161. package/dist/okf/types/ResourceSliceList.md +2 -2
  162. package/dist/okf/types/RoleBindingList.md +2 -2
  163. package/dist/okf/types/RoleList.md +2 -2
  164. package/dist/okf/types/RuntimeClass.md +2 -2
  165. package/dist/okf/types/RuntimeClassList.md +2 -2
  166. package/dist/okf/types/Scale.md +1 -1
  167. package/dist/okf/types/SecretList.md +2 -2
  168. package/dist/okf/types/SelfSubjectAccessReview.md +1 -1
  169. package/dist/okf/types/SelfSubjectRulesReview.md +1 -1
  170. package/dist/okf/types/Service.md +1 -1
  171. package/dist/okf/types/ServiceAccountList.md +2 -2
  172. package/dist/okf/types/ServiceCIDR.md +1 -1
  173. package/dist/okf/types/ServiceCIDRList.md +2 -2
  174. package/dist/okf/types/ServiceList.md +2 -2
  175. package/dist/okf/types/StatefulSet.md +1 -1
  176. package/dist/okf/types/StatefulSetList.md +2 -2
  177. package/dist/okf/types/Status.md +2 -2
  178. package/dist/okf/types/StorageClass.md +1 -1
  179. package/dist/okf/types/StorageClassList.md +2 -2
  180. package/dist/okf/types/StorageVersionMigration.md +1 -1
  181. package/dist/okf/types/StorageVersionMigrationList.md +2 -2
  182. package/dist/okf/types/SubjectAccessReview.md +1 -1
  183. package/dist/okf/types/TokenRequest.md +1 -1
  184. package/dist/okf/types/TokenReview.md +1 -1
  185. package/dist/okf/types/ValidatingAdmissionPolicy.md +1 -1
  186. package/dist/okf/types/ValidatingAdmissionPolicyBinding.md +1 -1
  187. package/dist/okf/types/ValidatingAdmissionPolicyBindingList.md +2 -2
  188. package/dist/okf/types/ValidatingAdmissionPolicyList.md +2 -2
  189. package/dist/okf/types/ValidatingWebhookConfiguration.md +1 -1
  190. package/dist/okf/types/ValidatingWebhookConfigurationList.md +2 -2
  191. package/dist/okf/types/VolumeAttachment.md +1 -1
  192. package/dist/okf/types/VolumeAttachmentList.md +2 -2
  193. package/dist/okf/types/VolumeAttributesClassList.md +2 -2
  194. package/dist/op/activities/argo.d.ts.map +1 -1
  195. package/dist/op/activities/index.d.ts +3 -3
  196. package/dist/op/activities/index.d.ts.map +1 -1
  197. package/dist/op/activities/wait-for-ready.d.ts.map +1 -1
  198. package/dist/op/builders.d.ts.map +1 -1
  199. package/dist/rules/wk8602.ts +2 -2
  200. package/dist/rules/wk8604.ts +3 -2
  201. package/dist/rules/wk8605.ts +131 -0
  202. package/dist/serializer.d.ts +0 -3
  203. package/dist/serializer.d.ts.map +1 -1
  204. package/dist/skills/chant-k8s.md +1 -1
  205. package/dist/spec/parse.d.ts +27 -0
  206. package/dist/spec/parse.d.ts.map +1 -1
  207. package/dist/telemetry-release.d.ts +15 -0
  208. package/dist/telemetry-release.d.ts.map +1 -0
  209. package/dist/types/index.d.ts +5373 -972
  210. package/dist/variables.d.ts.map +1 -1
  211. package/package.json +4 -4
  212. package/src/codegen/declarations.test.ts +118 -0
  213. package/src/codegen/generate-crd-sources.test.ts +49 -0
  214. package/src/codegen/generate-typescript.ts +69 -4
  215. package/src/codegen/generate.ts +66 -18
  216. package/src/components/kubectl-apply.test.ts +87 -0
  217. package/src/components/kubectl-apply.ts +17 -1
  218. package/src/composites/catalog.ts +6 -0
  219. package/src/composites/gke-otel-collector.ts +6 -1
  220. package/src/composites/index.ts +1 -0
  221. package/src/composites/otel-collector-agent.ts +39 -2
  222. package/src/composites/otel-collector-gateway.test.ts +24 -1
  223. package/src/composites/otel-collector-gateway.ts +1 -1
  224. package/src/composites/otel-collector-node.test.ts +193 -0
  225. package/src/composites/otel-collector-node.ts +211 -0
  226. package/src/composites/otel-collector-rbac.test.ts +11 -0
  227. package/src/composites/otel-collector-rbac.ts +6 -4
  228. package/src/composites/otel-collector-shape.ts +9 -8
  229. package/src/composites/otel-collector.ts +16 -2
  230. package/src/crd/crd-sources.ts +28 -0
  231. package/src/crd/loader.test.ts +9 -1
  232. package/src/crd/loader.ts +26 -3
  233. package/src/crd/oci-chart.test.ts +149 -0
  234. package/src/crd/oci-chart.ts +178 -0
  235. package/src/crd/types.ts +5 -0
  236. package/src/generated/index.d.ts +5373 -972
  237. package/src/generated/index.ts +35 -0
  238. package/src/generated/lexicon-k8s.json +194 -17
  239. package/src/generated/operations.json +64 -0
  240. package/src/import/embedded-live.test.ts +46 -4
  241. package/src/import/embedded-roundtrip.test.ts +73 -7
  242. package/src/import/embedded-types.e2e.test.ts +3 -1
  243. package/src/import/embedded.test.ts +64 -0
  244. package/src/import/embedded.ts +31 -2
  245. package/src/import/generator.test.ts +19 -0
  246. package/src/import/generator.ts +20 -2
  247. package/src/import/testdata/embedded/README.md +4 -1
  248. package/src/import/testdata/embedded/alertmanager-configmap.yaml +91 -0
  249. package/src/import/testdata/embedded/fixtures.ts +18 -0
  250. package/src/import/testdata/embedded/grafana-operator-dashboard.yaml +363 -0
  251. package/src/import/testdata/embedded/grafana-v2-dashboard-configmap.yaml +851 -0
  252. package/src/lint/audit-catalog.ts +1 -0
  253. package/src/lint/post-synth/index.ts +2 -0
  254. package/src/lint/post-synth/otel-placement.test.ts +14 -0
  255. package/src/lint/post-synth/post-synth.test.ts +3 -3
  256. package/src/lint/post-synth/wk8602.ts +2 -2
  257. package/src/lint/post-synth/wk8604.ts +3 -2
  258. package/src/lint/post-synth/wk8605.test.ts +153 -0
  259. package/src/lint/post-synth/wk8605.ts +131 -0
  260. package/src/serializer-telemetry.test.ts +146 -0
  261. package/src/serializer.ts +75 -0
  262. package/src/skills/chant-k8s.md +1 -1
  263. package/src/spec/parse.test.ts +118 -0
  264. package/src/spec/parse.ts +250 -29
  265. package/src/telemetry-build.test.ts +79 -0
  266. package/src/telemetry-release.ts +93 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Where a workload keeps its pod spec, and the release attributes a deploy
3
+ * writes onto it (#3059, #3061, ws-081).
4
+ *
5
+ * The build stamps each container of a workload with `OTEL_SERVICE_NAME` and
6
+ * `OTEL_RESOURCE_ATTRIBUTES` (the serializer), and with
7
+ * `CHANT_RELEASE_ATTRIBUTES` read through the downward API from the pod
8
+ * annotation `chant.intentius.io/release-attributes`, which
9
+ * `OTEL_RESOURCE_ATTRIBUTES` ends with as `$(CHANT_RELEASE_ATTRIBUTES)`. An
10
+ * absent annotation reads as empty, so the built manifest works as it is. A
11
+ * release deploy (`kubectl-apply` with a release on its context) sets the
12
+ * annotation on the pod template of each stamped workload in what it applies,
13
+ * leaving the committed manifest the same bytes.
14
+ *
15
+ * Kept free of the API client and the serializer so the capability module can
16
+ * import it without loading either.
17
+ */
18
+ import { RELEASE_ATTRIBUTES_ANNOTATION, RELEASE_ATTRIBUTES_VARIABLE } from "@intentius/chant/telemetry-attribution";
19
+
20
+ /** Where each workload kind keeps its pod spec. */
21
+ export const POD_SPEC_PATHS: Record<string, readonly string[]> = {
22
+ Pod: ["spec"],
23
+ Deployment: ["spec", "template", "spec"],
24
+ StatefulSet: ["spec", "template", "spec"],
25
+ DaemonSet: ["spec", "template", "spec"],
26
+ ReplicaSet: ["spec", "template", "spec"],
27
+ Job: ["spec", "template", "spec"],
28
+ CronJob: ["spec", "jobTemplate", "spec", "template", "spec"],
29
+ };
30
+
31
+ /** The core API groups those kinds live in; a CRD that reuses a kind name is not a workload. */
32
+ const WORKLOAD_API_VERSIONS = new Set(["v1", "apps/v1", "batch/v1"]);
33
+
34
+ type Obj = Record<string, unknown>;
35
+
36
+ function isObj(value: unknown): value is Obj {
37
+ return typeof value === "object" && value !== null && !Array.isArray(value);
38
+ }
39
+
40
+ function at(value: unknown, path: readonly string[]): unknown {
41
+ let cur = value;
42
+ for (const key of path) {
43
+ if (!isObj(cur)) return undefined;
44
+ cur = cur[key];
45
+ }
46
+ return cur;
47
+ }
48
+
49
+ /** A workload's pod spec, or undefined for anything else. */
50
+ export function podSpecOf(manifest: Obj): Obj | undefined {
51
+ const path = POD_SPEC_PATHS[manifest.kind as string];
52
+ if (!path || !WORKLOAD_API_VERSIONS.has(manifest.apiVersion as string)) return undefined;
53
+ const spec = at(manifest, path);
54
+ return isObj(spec) ? spec : undefined;
55
+ }
56
+
57
+ /** The env entry that reads the release attributes from the pod annotation. */
58
+ export function releaseAttributesEnv(): Obj {
59
+ return {
60
+ name: RELEASE_ATTRIBUTES_VARIABLE,
61
+ valueFrom: { fieldRef: { fieldPath: `metadata.annotations['${RELEASE_ATTRIBUTES_ANNOTATION}']` } },
62
+ };
63
+ }
64
+
65
+ /** True when some container of the workload reads the release attributes, i.e. the build stamped it. */
66
+ function readsRelease(podSpec: Obj): boolean {
67
+ const containers = podSpec.containers;
68
+ if (!Array.isArray(containers)) return false;
69
+ return containers.some(
70
+ (c) => isObj(c) && Array.isArray(c.env) && c.env.some((e) => isObj(e) && e.name === RELEASE_ATTRIBUTES_VARIABLE && isObj(e.valueFrom)),
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Set the release-attributes annotation on the pod template (or the Pod) of
76
+ * every stamped workload in `documents`, in place, and return how many it
77
+ * set. A workload the build did not stamp is left alone.
78
+ */
79
+ export function annotateRelease(documents: Obj[], suffix: string): number {
80
+ let count = 0;
81
+ for (const doc of documents) {
82
+ const podSpec = podSpecOf(doc);
83
+ if (!podSpec || !readsRelease(podSpec)) continue;
84
+ const path = POD_SPEC_PATHS[doc.kind as string]!;
85
+ const owner = path.length === 1 ? doc : at(doc, path.slice(0, -1));
86
+ if (!isObj(owner)) continue;
87
+ const metadata = isObj(owner.metadata) ? owner.metadata : {};
88
+ const annotations = isObj(metadata.annotations) ? metadata.annotations : {};
89
+ owner.metadata = { ...metadata, annotations: { ...annotations, [RELEASE_ATTRIBUTES_ANNOTATION]: suffix } };
90
+ count++;
91
+ }
92
+ return count;
93
+ }