@intentius/chant-lexicon-k8s 0.106.4 → 0.108.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 (167) hide show
  1. package/dist/codegen/naming.d.ts.map +1 -1
  2. package/dist/composites/catalog.d.ts.map +1 -1
  3. package/dist/composites/index.d.ts +2 -0
  4. package/dist/composites/index.d.ts.map +1 -1
  5. package/dist/composites/otel-collector-shape.d.ts +2 -0
  6. package/dist/composites/otel-collector-shape.d.ts.map +1 -1
  7. package/dist/composites/otel-operator-collector.d.ts +101 -0
  8. package/dist/composites/otel-operator-collector.d.ts.map +1 -0
  9. package/dist/config-schema.d.ts +115 -1
  10. package/dist/config-schema.d.ts.map +1 -1
  11. package/dist/config.d.ts +58 -3
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/crd/crd-sources.d.ts.map +1 -1
  14. package/dist/crd/loader.d.ts +4 -0
  15. package/dist/crd/loader.d.ts.map +1 -1
  16. package/dist/crd/parser.d.ts +5 -0
  17. package/dist/crd/parser.d.ts.map +1 -1
  18. package/dist/crd/project-codegen.d.ts +33 -0
  19. package/dist/crd/project-codegen.d.ts.map +1 -0
  20. package/dist/generated/index.d.d.ts +172 -2
  21. package/dist/generated/index.d.ts +301 -0
  22. package/dist/generated/index.d.ts.map +1 -1
  23. package/dist/group-namespace.d.ts.map +1 -1
  24. package/dist/import/embedded.d.ts +3 -0
  25. package/dist/import/embedded.d.ts.map +1 -1
  26. package/dist/include/entity.d.ts +73 -0
  27. package/dist/include/entity.d.ts.map +1 -0
  28. package/dist/include/resolve.d.ts +29 -0
  29. package/dist/include/resolve.d.ts.map +1 -0
  30. package/dist/index.d.ts +9 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/integrity.json +17 -10
  33. package/dist/kustomize/rendered-entity.d.ts +15 -1
  34. package/dist/kustomize/rendered-entity.d.ts.map +1 -1
  35. package/dist/kustomize/root.d.ts +11 -2
  36. package/dist/kustomize/root.d.ts.map +1 -1
  37. package/dist/lint/audit-catalog.d.ts.map +1 -1
  38. package/dist/lint/post-synth/crd-schema-helpers.d.ts +5 -1
  39. package/dist/lint/post-synth/crd-schema-helpers.d.ts.map +1 -1
  40. package/dist/lint/post-synth/index.d.ts.map +1 -1
  41. package/dist/lint/post-synth/monitoring-selection-helpers.d.ts +55 -0
  42. package/dist/lint/post-synth/monitoring-selection-helpers.d.ts.map +1 -0
  43. package/dist/lint/post-synth/otel-placement-helpers.d.ts +16 -0
  44. package/dist/lint/post-synth/otel-placement-helpers.d.ts.map +1 -1
  45. package/dist/lint/post-synth/wk8604.d.ts +6 -0
  46. package/dist/lint/post-synth/wk8604.d.ts.map +1 -1
  47. package/dist/lint/post-synth/wk8605.d.ts.map +1 -1
  48. package/dist/lint/post-synth/wk8606.d.ts +17 -0
  49. package/dist/lint/post-synth/wk8606.d.ts.map +1 -0
  50. package/dist/lint/post-synth/wk8701.d.ts +17 -0
  51. package/dist/lint/post-synth/wk8701.d.ts.map +1 -0
  52. package/dist/lint/post-synth/wk8702.d.ts +17 -0
  53. package/dist/lint/post-synth/wk8702.d.ts.map +1 -0
  54. package/dist/lint/post-synth/wk8703.d.ts +17 -0
  55. package/dist/lint/post-synth/wk8703.d.ts.map +1 -0
  56. package/dist/lint/post-synth/wk8704.d.ts +21 -0
  57. package/dist/lint/post-synth/wk8704.d.ts.map +1 -0
  58. package/dist/lint/post-synth/wk8705.d.ts +18 -0
  59. package/dist/lint/post-synth/wk8705.d.ts.map +1 -0
  60. package/dist/manifest.json +1 -1
  61. package/dist/meta.json +2284 -370
  62. package/dist/okf/index.md +20 -1
  63. package/dist/okf/rules/WK8604.md +6 -2
  64. package/dist/okf/rules/WK8605.md +4 -0
  65. package/dist/okf/rules/WK8606.md +15 -0
  66. package/dist/okf/rules/WK8701.md +18 -0
  67. package/dist/okf/rules/WK8702.md +20 -0
  68. package/dist/okf/rules/WK8703.md +17 -0
  69. package/dist/okf/rules/WK8704.md +22 -0
  70. package/dist/okf/rules/WK8705.md +18 -0
  71. package/dist/okf/types/Alertmanager.md +18 -0
  72. package/dist/okf/types/AlertmanagerConfig.md +18 -0
  73. package/dist/okf/types/ClusterObservability.md +14 -0
  74. package/dist/okf/types/CronJob.md +1 -0
  75. package/dist/okf/types/DaemonSet.md +1 -0
  76. package/dist/okf/types/Instrumentation.md +14 -0
  77. package/dist/okf/types/MonitoringProbe.md +14 -0
  78. package/dist/okf/types/Namespace.md +3 -0
  79. package/dist/okf/types/OpAMPBridge.md +14 -0
  80. package/dist/okf/types/OpenTelemetryCollector.md +19 -0
  81. package/dist/okf/types/Pod.md +1 -0
  82. package/dist/okf/types/PodMonitor.md +20 -0
  83. package/dist/okf/types/Prometheus.md +21 -0
  84. package/dist/okf/types/PrometheusAgent.md +18 -0
  85. package/dist/okf/types/PrometheusRule.md +6 -1
  86. package/dist/okf/types/ScrapeConfig.md +19 -0
  87. package/dist/okf/types/Service.md +1 -0
  88. package/dist/okf/types/ServiceMonitor.md +7 -1
  89. package/dist/okf/types/StatefulSet.md +1 -0
  90. package/dist/okf/types/TargetAllocator.md +14 -0
  91. package/dist/okf/types/ThanosRuler.md +18 -0
  92. package/dist/patch/json-patch.d.ts +51 -0
  93. package/dist/patch/json-patch.d.ts.map +1 -0
  94. package/dist/patch/rendered-patch.d.ts +90 -0
  95. package/dist/patch/rendered-patch.d.ts.map +1 -0
  96. package/dist/plugin.d.ts.map +1 -1
  97. package/dist/project-kinds.d.ts +46 -0
  98. package/dist/project-kinds.d.ts.map +1 -0
  99. package/dist/rules/crd-schema-helpers.ts +10 -2
  100. package/dist/rules/monitoring-selection-helpers.ts +185 -0
  101. package/dist/rules/otel-placement-helpers.ts +61 -1
  102. package/dist/rules/wk8601.ts +1 -1
  103. package/dist/rules/wk8603.ts +1 -1
  104. package/dist/rules/wk8604.ts +8 -2
  105. package/dist/rules/wk8605.ts +5 -3
  106. package/dist/rules/wk8606.ts +27 -0
  107. package/dist/rules/wk8701.ts +37 -0
  108. package/dist/rules/wk8702.ts +43 -0
  109. package/dist/rules/wk8703.ts +37 -0
  110. package/dist/rules/wk8704.ts +134 -0
  111. package/dist/rules/wk8705.ts +45 -0
  112. package/dist/serializer.d.ts.map +1 -1
  113. package/dist/types/index.d.ts +172 -2
  114. package/package.json +3 -3
  115. package/src/codegen/naming.ts +15 -1
  116. package/src/composites/catalog.ts +105 -0
  117. package/src/composites/index.ts +2 -0
  118. package/src/composites/otel-collector-shape.ts +2 -0
  119. package/src/composites/otel-operator-collector.test.ts +267 -0
  120. package/src/composites/otel-operator-collector.ts +221 -0
  121. package/src/config-augmentation.test.ts +28 -0
  122. package/src/config-schema.ts +47 -1
  123. package/src/config.ts +44 -3
  124. package/src/crd/crd-sources.ts +41 -2
  125. package/src/crd/loader.ts +1 -1
  126. package/src/crd/parser.ts +9 -5
  127. package/src/crd/project-codegen.test.ts +239 -0
  128. package/src/crd/project-codegen.ts +327 -0
  129. package/src/generated/index.d.ts +172 -2
  130. package/src/generated/index.ts +303 -2
  131. package/src/generated/lexicon-k8s.json +2284 -370
  132. package/src/generated/operations.json +208 -0
  133. package/src/group-namespace.test.ts +4 -0
  134. package/src/group-namespace.ts +4 -0
  135. package/src/import/embedded.ts +26 -0
  136. package/src/import/operator-collector-roundtrip.test.ts +105 -0
  137. package/src/include/entity.ts +119 -0
  138. package/src/include/include.test.ts +345 -0
  139. package/src/include/resolve.ts +204 -0
  140. package/src/index.ts +25 -2
  141. package/src/kustomize/rendered-entity.ts +43 -1
  142. package/src/kustomize/root.test.ts +39 -0
  143. package/src/kustomize/root.ts +16 -30
  144. package/src/lint/audit-catalog.ts +6 -0
  145. package/src/lint/post-synth/crd-schema-helpers.ts +10 -2
  146. package/src/lint/post-synth/index.ts +12 -0
  147. package/src/lint/post-synth/monitoring-selection-helpers.ts +185 -0
  148. package/src/lint/post-synth/monitoring-selection.test.ts +316 -0
  149. package/src/lint/post-synth/otel-placement-helpers.ts +61 -1
  150. package/src/lint/post-synth/wk8601.ts +1 -1
  151. package/src/lint/post-synth/wk8603.ts +1 -1
  152. package/src/lint/post-synth/wk8604.ts +8 -2
  153. package/src/lint/post-synth/wk8605.ts +5 -3
  154. package/src/lint/post-synth/wk8606.ts +27 -0
  155. package/src/lint/post-synth/wk8701.ts +37 -0
  156. package/src/lint/post-synth/wk8702.ts +43 -0
  157. package/src/lint/post-synth/wk8703.ts +37 -0
  158. package/src/lint/post-synth/wk8704.ts +134 -0
  159. package/src/lint/post-synth/wk8705.ts +45 -0
  160. package/src/patch/json-patch.test.ts +91 -0
  161. package/src/patch/json-patch.ts +189 -0
  162. package/src/patch/rendered-patch.test.ts +143 -0
  163. package/src/patch/rendered-patch.ts +180 -0
  164. package/src/plugin.ts +16 -2
  165. package/src/project-kinds.ts +75 -0
  166. package/src/serializer.ts +10 -0
  167. package/src/testdata/include/bundle.yaml +45 -0
@@ -0,0 +1,327 @@
1
+ /**
2
+ * Project-local CRD classes: the k8s lexicon's `projectCodegen` hook
3
+ * (`chant generate`, core's project-codegen.ts).
4
+ *
5
+ * A project lists CRD sources under `k8s.crds` in `chant.config.ts`. Generation
6
+ * parses each CRD with the same parser the lexicon's own CRD_SOURCES go
7
+ * through (./parser.ts), so the entity type, GVK and spec field schema match
8
+ * what a shipped CRD gets, and writes two files to `<outDir>/k8s/`:
9
+ *
10
+ * - `index.ts`: a typed class per kind. Its props are typed from the CRD's
11
+ * `openAPIV3Schema` (a shipped CRD's `.d.ts` types `spec` as a record; a
12
+ * project's own types it fully). The module registers its kinds with
13
+ * ../project-kinds.ts when imported.
14
+ * - `kinds.json`: each kind's GVK and spec field schema, which a build loads
15
+ * (`load`) so the serializer and the WK8501/WK8502 spec checks know the
16
+ * kinds whatever process imported the module.
17
+ */
18
+
19
+ import { createHash } from "node:crypto";
20
+ import { existsSync, readFileSync } from "node:fs";
21
+ import { join, resolve } from "node:path";
22
+ import { loadAll } from "js-yaml";
23
+ import { GENERATED_TS_HEADER, type ProjectCodegen, type ProjectCodegenContext } from "@intentius/chant/project-codegen";
24
+ import { jsdocLines, schemaToTypeScript, tsPropertyKey } from "@intentius/chant/codegen/json-schema-to-ts";
25
+ import { fetchWithRetry } from "@intentius/chant/codegen/fetch";
26
+ import type { K8sProjectCrdSource } from "../config";
27
+ import { namespaceSegmentForGroup } from "../group-namespace";
28
+ import { registerProjectKinds, type ProjectKind } from "../project-kinds";
29
+ import { gvkToApiVersion } from "../spec/parse";
30
+ import { fetchCRDContent } from "./loader";
31
+ import { crdTargetVersion, parseCRDSpec } from "./parser";
32
+ import type { CRDSpec } from "./types";
33
+
34
+ /** The registry file written beside the module. */
35
+ export const KINDS_FILE = "kinds.json";
36
+
37
+ /** Fields every resource class handles itself; a CRD's own schema for them is ignored. */
38
+ const RESERVED_FIELDS = new Set(["apiVersion", "kind", "metadata", "status"]);
39
+
40
+ /** How `generate` reaches a source's content. Tests replace these. */
41
+ export interface CrdSourceReaders {
42
+ /** Fetch a URL source's body. Default: `ctx.fetch`, else core's retrying fetch. */
43
+ fetchUrl?: (url: string) => Promise<string>;
44
+ /** Read a Helm chart's CRDs. Default: the lexicon's CRD loader. */
45
+ readChart?: (source: Extract<K8sProjectCrdSource, { type: "helm" }>) => Promise<string>;
46
+ }
47
+
48
+ /** The hook, with injectable readers. */
49
+ export function k8sProjectCodegen(readers: CrdSourceReaders = {}): ProjectCodegen {
50
+ return {
51
+ inputs: (ctx) => {
52
+ const sources = declaredSources(ctx);
53
+ if (!sources) return undefined;
54
+ return sources.map((source, i) => describeSource(source, i, ctx.projectRoot));
55
+ },
56
+
57
+ async generate(ctx) {
58
+ const sources = declaredSources(ctx) ?? [];
59
+ const fetchUrl =
60
+ readers.fetchUrl ??
61
+ (async (url: string) => {
62
+ const response = ctx.fetch ? await ctx.fetch(url) : await fetchWithRetry(url);
63
+ if (!response.ok) throw new Error(`${url}: HTTP ${response.status}`);
64
+ return response.text();
65
+ });
66
+ const readChart =
67
+ readers.readChart ??
68
+ ((s: Extract<K8sProjectCrdSource, { type: "helm" }>) =>
69
+ fetchCRDContent({ type: "helm", chart: s.chart, version: s.version, digest: s.digest, chartSubdir: s.chartSubdir }));
70
+
71
+ const kinds: GeneratedKind[] = [];
72
+ for (const [i, source] of sources.entries()) {
73
+ describeSource(source, i, ctx.projectRoot); // validates the pin before any fetch
74
+ let content: string;
75
+ if (source.type === "file") {
76
+ content = readFileSync(resolve(ctx.projectRoot, source.path), "utf8");
77
+ } else if (source.type === "url") {
78
+ content = await fetchUrl(source.url);
79
+ const actual = sha256(content);
80
+ if (actual !== normalizeSha(source.sha256)) {
81
+ throw new Error(
82
+ `k8s.crds[${i}]: ${source.url} has sha256 ${actual}, but the config pins ${normalizeSha(source.sha256)}. ` +
83
+ "Check the URL points at a fixed release, then update the pin.",
84
+ );
85
+ }
86
+ } else {
87
+ content = await readChart(source);
88
+ }
89
+ const found = crdKinds(content, source.kinds);
90
+ if (found.length === 0) {
91
+ throw new Error(`k8s.crds[${i}] (${sourceLabel(source)}) holds no CustomResourceDefinition${source.kinds ? ` of kind ${source.kinds.join(", ")}` : ""}`);
92
+ }
93
+ kinds.push(...found);
94
+ }
95
+
96
+ assignClassNames(kinds);
97
+ return {
98
+ files: { "index.ts": renderModule(kinds), [KINDS_FILE]: renderKinds(kinds) },
99
+ summary: kinds.map((k) => `${k.className} (${k.apiVersion}, ${k.scope === "Cluster" ? "cluster-scoped" : "namespaced"})`),
100
+ };
101
+ },
102
+
103
+ load(ctx) {
104
+ const path = join(ctx.outDir, KINDS_FILE);
105
+ if (!existsSync(path)) return;
106
+ registerProjectKinds(JSON.parse(readFileSync(path, "utf8")) as ProjectKind[]);
107
+ },
108
+ };
109
+ }
110
+
111
+ function declaredSources(ctx: ProjectCodegenContext): K8sProjectCrdSource[] | undefined {
112
+ const k8s = ctx.config.k8s as { crds?: K8sProjectCrdSource[] } | undefined;
113
+ return k8s?.crds && k8s.crds.length > 0 ? k8s.crds : undefined;
114
+ }
115
+
116
+ /**
117
+ * A source as a JSON value for the drift digest: a file by the hash of its
118
+ * content, a remote source by its pin. Throws on an unpinned remote source
119
+ * or a missing file.
120
+ */
121
+ function describeSource(source: K8sProjectCrdSource, i: number, projectRoot: string): Record<string, unknown> {
122
+ const kinds = source.kinds ? { kinds: [...source.kinds].sort() } : {};
123
+ switch (source.type) {
124
+ case "file": {
125
+ const path = resolve(projectRoot, source.path);
126
+ if (!existsSync(path)) throw new Error(`k8s.crds[${i}]: CRD file not found: ${source.path}`);
127
+ return { type: "file", path: source.path, sha256: sha256(readFileSync(path)), ...kinds };
128
+ }
129
+ case "url":
130
+ if (typeof source.sha256 !== "string" || !/^(sha256:)?[0-9a-f]{64}$/.test(source.sha256)) {
131
+ throw new Error(
132
+ `k8s.crds[${i}]: ${source.url} needs a sha256 pin of its content. An unpinned URL makes the generated classes depend on when they were generated.`,
133
+ );
134
+ }
135
+ return { type: "url", url: source.url, sha256: normalizeSha(source.sha256), ...kinds };
136
+ case "helm":
137
+ if (!source.version) {
138
+ throw new Error(`k8s.crds[${i}]: chart ${source.chart} needs a version. An unpinned chart makes the generated classes depend on when they were generated.`);
139
+ }
140
+ return {
141
+ type: "helm",
142
+ chart: source.chart,
143
+ version: source.version,
144
+ ...(source.digest ? { digest: source.digest } : {}),
145
+ ...(source.chartSubdir ? { chartSubdir: source.chartSubdir } : {}),
146
+ ...kinds,
147
+ };
148
+ default:
149
+ throw new Error(`k8s.crds[${i}]: unsupported source type ${JSON.stringify((source as { type?: unknown }).type)}`);
150
+ }
151
+ }
152
+
153
+ function sourceLabel(source: K8sProjectCrdSource): string {
154
+ return source.type === "file" ? source.path : source.type === "url" ? source.url : `${source.chart} ${source.version}`;
155
+ }
156
+
157
+ function sha256(content: string | Buffer): string {
158
+ return createHash("sha256").update(content).digest("hex");
159
+ }
160
+
161
+ function normalizeSha(pin: string): string {
162
+ return pin.replace(/^sha256:/, "");
163
+ }
164
+
165
+ interface GeneratedKind {
166
+ resourceType: string;
167
+ apiVersion: string;
168
+ kind: string;
169
+ group: string;
170
+ scope: "Namespaced" | "Cluster";
171
+ attributes: Array<{ name: string; tsType: string }>;
172
+ specSchema?: ProjectKind["specSchema"];
173
+ schema?: Record<string, unknown>;
174
+ className: string;
175
+ }
176
+
177
+ /** Every CRD in a (multi-document) YAML text, filtered to `allow` when given. */
178
+ function crdKinds(content: string, allow: string[] | undefined): GeneratedKind[] {
179
+ const docs: unknown[] = [];
180
+ loadAll(content, (doc) => docs.push(doc));
181
+ const out: GeneratedKind[] = [];
182
+ for (const doc of docs) {
183
+ if (!doc || typeof doc !== "object") continue;
184
+ const d = doc as { kind?: unknown; spec?: CRDSpec };
185
+ if (d.kind !== "CustomResourceDefinition" || !d.spec?.group || !d.spec.names?.kind || !d.spec.versions) continue;
186
+ if (allow && allow.length > 0 && !allow.includes(d.spec.names.kind)) continue;
187
+ const [parsed] = parseCRDSpec(d.spec);
188
+ const version = crdTargetVersion(d.spec);
189
+ if (!parsed || !version) continue;
190
+ out.push({
191
+ resourceType: parsed.resource.typeName,
192
+ apiVersion: gvkToApiVersion(parsed.gvk),
193
+ kind: parsed.gvk.kind,
194
+ group: d.spec.group,
195
+ scope: d.spec.scope ?? "Namespaced",
196
+ attributes: parsed.resource.attributes,
197
+ ...(parsed.specSchema ? { specSchema: parsed.specSchema } : {}),
198
+ schema: version.schema?.openAPIV3Schema as Record<string, unknown> | undefined,
199
+ className: parsed.gvk.kind,
200
+ });
201
+ }
202
+ return out;
203
+ }
204
+
205
+ /**
206
+ * Class names are the kind. Two kinds of the same name from different groups
207
+ * both take the group's namespace segment as a prefix (`CertManagerCertificate`);
208
+ * the same group and kind twice is an error.
209
+ */
210
+ function assignClassNames(kinds: GeneratedKind[]): void {
211
+ const seen = new Set<string>();
212
+ for (const k of kinds) {
213
+ const key = `${k.group}/${k.kind}`;
214
+ if (seen.has(key)) throw new Error(`k8s.crds declares ${k.kind} (${k.group}) more than once`);
215
+ seen.add(key);
216
+ }
217
+ const byKind = new Map<string, GeneratedKind[]>();
218
+ for (const k of kinds) byKind.set(k.kind, [...(byKind.get(k.kind) ?? []), k]);
219
+ for (const group of byKind.values()) {
220
+ if (group.length < 2) continue;
221
+ for (const k of group) k.className = `${namespaceSegmentForGroup(k.group).replace(/[^A-Za-z0-9]/g, "")}${k.kind}`;
222
+ }
223
+ kinds.sort((a, b) => a.className.localeCompare(b.className));
224
+ }
225
+
226
+ function renderKinds(kinds: GeneratedKind[]): string {
227
+ const entries: ProjectKind[] = kinds.map((k) => ({
228
+ resourceType: k.resourceType,
229
+ apiVersion: k.apiVersion,
230
+ kind: k.kind,
231
+ ...(k.specSchema ? { specSchema: k.specSchema } : {}),
232
+ }));
233
+ return JSON.stringify(entries, null, 2) + "\n";
234
+ }
235
+
236
+ /**
237
+ * The metadata a manifest author sets. Declared in the module rather than
238
+ * imported: the lexicon's `ObjectMeta` export is a runtime constructor, and
239
+ * its typed declaration is not reachable from every install.
240
+ */
241
+ const OBJECT_META = [
242
+ "/** Standard object metadata: the fields a manifest sets. */",
243
+ "export interface ObjectMeta {",
244
+ " name?: string;",
245
+ " generateName?: string;",
246
+ " namespace?: string;",
247
+ " labels?: Record<string, string>;",
248
+ " annotations?: Record<string, string>;",
249
+ " finalizers?: string[];",
250
+ " ownerReferences?: Array<{",
251
+ " apiVersion: string;",
252
+ " kind: string;",
253
+ " name: string;",
254
+ " uid: string;",
255
+ " controller?: boolean;",
256
+ " blockOwnerDeletion?: boolean;",
257
+ " }>;",
258
+ "}",
259
+ ];
260
+
261
+ function renderModule(kinds: GeneratedKind[]): string {
262
+ const lines: string[] = [
263
+ GENERATED_TS_HEADER,
264
+ "// Classes for the custom resources k8s.crds declares in chant.config.",
265
+ 'import type { Declarable } from "@intentius/chant";',
266
+ 'import { createResource } from "@intentius/chant/runtime";',
267
+ 'import { registerProjectKinds } from "@intentius/chant-lexicon-k8s";',
268
+ "",
269
+ "registerProjectKinds([",
270
+ ...kinds.map((k) => ` ${JSON.stringify({ resourceType: k.resourceType, apiVersion: k.apiVersion, kind: k.kind })},`),
271
+ "]);",
272
+ "",
273
+ ...OBJECT_META,
274
+ ];
275
+
276
+ for (const k of kinds) {
277
+ const name = k.className;
278
+ const properties = (k.schema?.properties ?? {}) as Record<string, Record<string, unknown>>;
279
+ const required = new Set((k.schema?.required as string[] | undefined) ?? []);
280
+ const fields = Object.keys(properties).filter((f) => !RESERVED_FIELDS.has(f));
281
+
282
+ const members: string[] = [" /** Standard object's metadata. */", " metadata?: ObjectMeta;"];
283
+ for (const field of fields) {
284
+ const typeName = `${name}${pascal(field)}`;
285
+ const { type, declarations } = schemaToTypeScript(properties[field], {
286
+ openByDefault: false,
287
+ namePrefix: typeName,
288
+ });
289
+ for (const d of declarations) {
290
+ lines.push("", ...jsdocLines(d.description, ""), `export type ${d.name} = ${d.type};`);
291
+ }
292
+ lines.push(
293
+ "",
294
+ `/** The \`${field}\` of a ${k.kind} (${k.apiVersion}). */`,
295
+ `export type ${typeName} = ${type};`,
296
+ );
297
+ members.push(...jsdocLines(properties[field].description, " "));
298
+ members.push(` ${tsPropertyKey(field)}${required.has(field) ? "" : "?"}: ${typeName};`);
299
+ }
300
+
301
+ const attrMap = Object.fromEntries(k.attributes.map((a) => [a.name, a.name]));
302
+ lines.push(
303
+ "",
304
+ `/** Props for a ${k.kind}, a custom resource of ${k.apiVersion}. */`,
305
+ `export interface ${name}Props {`,
306
+ ...members,
307
+ "}",
308
+ "",
309
+ `/** A ${k.kind} (${k.apiVersion}, ${k.scope === "Cluster" ? "cluster-scoped" : "namespaced"}). */`,
310
+ `export interface ${name} extends Declarable {`,
311
+ ...k.attributes.map((a) => ` readonly ${a.name}: ${a.tsType};`),
312
+ "}",
313
+ "",
314
+ `export const ${name}: new (props: ${name}Props) => ${name} = createResource(${JSON.stringify(k.resourceType)}, "k8s", ${JSON.stringify(attrMap)}) as never;`,
315
+ );
316
+ }
317
+ lines.push("");
318
+ return lines.join("\n");
319
+ }
320
+
321
+ function pascal(name: string): string {
322
+ return name
323
+ .split(/[^A-Za-z0-9]+/)
324
+ .filter(Boolean)
325
+ .map((p) => p.charAt(0).toUpperCase() + p.slice(1))
326
+ .join("");
327
+ }
@@ -26,6 +26,33 @@ export declare class Alert {
26
26
  readonly uid: string;
27
27
  }
28
28
 
29
+ export declare class Alertmanager {
30
+ constructor(props: {
31
+ /** spec defines the specification of the desired behavior of the Alertmanager cluster. More info:
32
+ https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status */
33
+ spec: Record<string, unknown>;
34
+ /** Standard object's metadata. */
35
+ metadata?: ObjectMeta;
36
+ });
37
+ readonly name: string;
38
+ readonly namespace: string;
39
+ readonly status: Record<string, unknown>;
40
+ readonly uid: string;
41
+ }
42
+
43
+ export declare class AlertmanagerConfig {
44
+ constructor(props: {
45
+ /** spec defines the specification of AlertmanagerConfigSpec */
46
+ spec: Record<string, unknown>;
47
+ /** Standard object's metadata. */
48
+ metadata?: ObjectMeta;
49
+ });
50
+ readonly name: string;
51
+ readonly namespace: string;
52
+ readonly status: Record<string, unknown>;
53
+ readonly uid: string;
54
+ }
55
+
29
56
  export declare class APIGroup {
30
57
  constructor(props: {
31
58
  /** name is the name of the group. */
@@ -317,6 +344,18 @@ export declare class ClusterIssuer {
317
344
  readonly uid: string;
318
345
  }
319
346
 
347
+ export declare class ClusterObservability {
348
+ constructor(props: {
349
+ /** Standard object's metadata. */
350
+ metadata?: ObjectMeta;
351
+ spec?: Record<string, unknown>;
352
+ });
353
+ readonly name: string;
354
+ readonly namespace: string;
355
+ readonly status: Record<string, unknown>;
356
+ readonly uid: string;
357
+ }
358
+
320
359
  export declare class ClusterResourceSet {
321
360
  constructor(props: {
322
361
  /** spec is the desired state of ClusterResourceSet. */
@@ -1569,6 +1608,18 @@ export declare class IngressRouteUDP {
1569
1608
  readonly uid: string;
1570
1609
  }
1571
1610
 
1611
+ export declare class Instrumentation {
1612
+ constructor(props: {
1613
+ /** Standard object's metadata. */
1614
+ metadata?: ObjectMeta;
1615
+ spec?: Record<string, unknown>;
1616
+ });
1617
+ readonly name: string;
1618
+ readonly namespace: string;
1619
+ readonly status: Record<string, unknown>;
1620
+ readonly uid: string;
1621
+ }
1622
+
1572
1623
  export declare class IPAddress {
1573
1624
  constructor(props: {
1574
1625
  /** spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status */
@@ -1837,6 +1888,19 @@ export declare class MiddlewareTCP {
1837
1888
  readonly uid: string;
1838
1889
  }
1839
1890
 
1891
+ export declare class MonitoringProbe {
1892
+ constructor(props: {
1893
+ /** spec defines the specification of desired Ingress selection for target discovery by Prometheus. */
1894
+ spec: Record<string, unknown>;
1895
+ /** Standard object's metadata. */
1896
+ metadata?: ObjectMeta;
1897
+ });
1898
+ readonly name: string;
1899
+ readonly namespace: string;
1900
+ readonly status: Record<string, unknown>;
1901
+ readonly uid: string;
1902
+ }
1903
+
1840
1904
  export declare class MutatingAdmissionPolicy {
1841
1905
  constructor(props: {
1842
1906
  /** metadata is the standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata. */
@@ -2032,6 +2096,30 @@ export declare class OCIRepository {
2032
2096
  readonly uid: string;
2033
2097
  }
2034
2098
 
2099
+ export declare class OpAMPBridge {
2100
+ constructor(props: {
2101
+ /** Standard object's metadata. */
2102
+ metadata?: ObjectMeta;
2103
+ spec?: Record<string, unknown>;
2104
+ });
2105
+ readonly name: string;
2106
+ readonly namespace: string;
2107
+ readonly status: Record<string, unknown>;
2108
+ readonly uid: string;
2109
+ }
2110
+
2111
+ export declare class OpenTelemetryCollector {
2112
+ constructor(props: {
2113
+ /** Standard object's metadata. */
2114
+ metadata?: ObjectMeta;
2115
+ spec?: Record<string, unknown>;
2116
+ });
2117
+ readonly name: string;
2118
+ readonly namespace: string;
2119
+ readonly status: Record<string, unknown>;
2120
+ readonly uid: string;
2121
+ }
2122
+
2035
2123
  export declare class Order {
2036
2124
  constructor(props: {
2037
2125
  spec: Record<string, unknown>;
@@ -2193,6 +2281,19 @@ export declare class PodList {
2193
2281
  readonly uid: string;
2194
2282
  }
2195
2283
 
2284
+ export declare class PodMonitor {
2285
+ constructor(props: {
2286
+ /** spec defines the specification of desired Pod selection for target discovery by Prometheus. */
2287
+ spec: Record<string, unknown>;
2288
+ /** Standard object's metadata. */
2289
+ metadata?: ObjectMeta;
2290
+ });
2291
+ readonly name: string;
2292
+ readonly namespace: string;
2293
+ readonly status: Record<string, unknown>;
2294
+ readonly uid: string;
2295
+ }
2296
+
2196
2297
  export declare class PodTemplate {
2197
2298
  constructor(props: {
2198
2299
  /** Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */
@@ -2307,15 +2408,44 @@ export declare class PriorityLevelConfigurationList {
2307
2408
  readonly uid: string;
2308
2409
  }
2309
2410
 
2411
+ export declare class Prometheus {
2412
+ constructor(props: {
2413
+ /** spec defines the specification of the desired behavior of the Prometheus cluster. More info:
2414
+ https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status */
2415
+ spec: Record<string, unknown>;
2416
+ /** Standard object's metadata. */
2417
+ metadata?: ObjectMeta;
2418
+ });
2419
+ readonly name: string;
2420
+ readonly namespace: string;
2421
+ readonly status: Record<string, unknown>;
2422
+ readonly uid: string;
2423
+ }
2424
+
2425
+ export declare class PrometheusAgent {
2426
+ constructor(props: {
2427
+ /** spec defines the specification of the desired behavior of the Prometheus agent. More info:
2428
+ https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status */
2429
+ spec: Record<string, unknown>;
2430
+ /** Standard object's metadata. */
2431
+ metadata?: ObjectMeta;
2432
+ });
2433
+ readonly name: string;
2434
+ readonly namespace: string;
2435
+ readonly status: Record<string, unknown>;
2436
+ readonly uid: string;
2437
+ }
2438
+
2310
2439
  export declare class PrometheusRule {
2311
2440
  constructor(props: {
2312
- /** Specification of desired alerting rule definitions for Prometheus. */
2441
+ /** spec defines the specification of desired alerting rule definitions for Prometheus. */
2313
2442
  spec: Record<string, unknown>;
2314
2443
  /** Standard object's metadata. */
2315
2444
  metadata?: ObjectMeta;
2316
2445
  });
2317
2446
  readonly name: string;
2318
2447
  readonly namespace: string;
2448
+ readonly status: Record<string, unknown>;
2319
2449
  readonly uid: string;
2320
2450
  }
2321
2451
 
@@ -2726,6 +2856,19 @@ More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-
2726
2856
  readonly uid: string;
2727
2857
  }
2728
2858
 
2859
+ export declare class ScrapeConfig {
2860
+ constructor(props: {
2861
+ /** spec defines the specification of ScrapeConfigSpec. */
2862
+ spec: Record<string, unknown>;
2863
+ /** Standard object's metadata. */
2864
+ metadata?: ObjectMeta;
2865
+ });
2866
+ readonly name: string;
2867
+ readonly namespace: string;
2868
+ readonly status: Record<string, unknown>;
2869
+ readonly uid: string;
2870
+ }
2871
+
2729
2872
  export declare class Sec {
2730
2873
  constructor(props: {
2731
2874
  /** Data contains the secret data. Each key must consist of alphanumeric characters, '-', '_' or '.'. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4 */
@@ -2910,7 +3053,7 @@ export declare class ServiceList {
2910
3053
 
2911
3054
  export declare class ServiceMonitor {
2912
3055
  constructor(props: {
2913
- /** Specification of desired Service selection for target discovery by
3056
+ /** spec defines the specification of desired Service selection for target discovery by
2914
3057
  Prometheus. */
2915
3058
  spec: Record<string, unknown>;
2916
3059
  /** Standard object's metadata. */
@@ -2918,6 +3061,7 @@ Prometheus. */
2918
3061
  });
2919
3062
  readonly name: string;
2920
3063
  readonly namespace: string;
3064
+ readonly status: Record<string, unknown>;
2921
3065
  readonly uid: string;
2922
3066
  }
2923
3067
 
@@ -3059,6 +3203,32 @@ export declare class SubjectAccessReview {
3059
3203
  readonly uid: string;
3060
3204
  }
3061
3205
 
3206
+ export declare class TargetAllocator {
3207
+ constructor(props: {
3208
+ /** Standard object's metadata. */
3209
+ metadata?: ObjectMeta;
3210
+ spec?: Record<string, unknown>;
3211
+ });
3212
+ readonly name: string;
3213
+ readonly namespace: string;
3214
+ readonly status: Record<string, unknown>;
3215
+ readonly uid: string;
3216
+ }
3217
+
3218
+ export declare class ThanosRuler {
3219
+ constructor(props: {
3220
+ /** spec defines the specification of the desired behavior of the ThanosRuler cluster. More info:
3221
+ https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status */
3222
+ spec: Record<string, unknown>;
3223
+ /** Standard object's metadata. */
3224
+ metadata?: ObjectMeta;
3225
+ });
3226
+ readonly name: string;
3227
+ readonly namespace: string;
3228
+ readonly status: Record<string, unknown>;
3229
+ readonly uid: string;
3230
+ }
3231
+
3062
3232
  export declare class TLSOption {
3063
3233
  constructor(props: {
3064
3234
  /** TLSOptionSpec defines the desired state of a TLSOption. */