@intentius/chant-lexicon-k8s 0.124.48 → 0.124.50

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 (52) hide show
  1. package/dist/config-schema.d.ts +9 -0
  2. package/dist/config-schema.d.ts.map +1 -1
  3. package/dist/config-schema.js +7 -0
  4. package/dist/config.d.ts +18 -0
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/crd/crd-sources.d.ts.map +1 -1
  7. package/dist/crd/crd-sources.js +46 -0
  8. package/dist/generated/index.d.d.ts +87 -0
  9. package/dist/generated/index.d.ts +58 -0
  10. package/dist/generated/index.d.ts.map +1 -1
  11. package/dist/generated/index.js +58 -0
  12. package/dist/group-namespace.d.ts.map +1 -1
  13. package/dist/group-namespace.js +7 -0
  14. package/dist/integrity.json +4 -4
  15. package/dist/kustomize/render.d.ts +8 -0
  16. package/dist/kustomize/render.d.ts.map +1 -1
  17. package/dist/kustomize/render.js +12 -1
  18. package/dist/manifest.json +1 -1
  19. package/dist/meta.json +358 -10
  20. package/dist/okf/index.md +6 -0
  21. package/dist/okf/types/ClickHouseCluster.md +14 -0
  22. package/dist/okf/types/ClickHouseInstallation.md +14 -0
  23. package/dist/okf/types/ClickHouseInstallationTemplate.md +14 -0
  24. package/dist/okf/types/ClickHouseKeeperInstallation.md +14 -0
  25. package/dist/okf/types/ClickHouseOperatorConfiguration.md +14 -0
  26. package/dist/okf/types/KeeperCluster.md +14 -0
  27. package/dist/plugin.d.ts.map +1 -1
  28. package/dist/plugin.js +16 -0
  29. package/dist/types/index.d.ts +87 -0
  30. package/dist/workspace-member.d.ts +35 -0
  31. package/dist/workspace-member.d.ts.map +1 -0
  32. package/dist/workspace-member.js +99 -0
  33. package/package.json +8 -6
  34. package/src/config-schema.ts +7 -0
  35. package/src/config.ts +19 -0
  36. package/src/crd/clickhouse-operators.test.ts +105 -0
  37. package/src/crd/crd-sources.ts +48 -0
  38. package/src/generated/index.d.ts +87 -0
  39. package/src/generated/index.ts +58 -0
  40. package/src/generated/lexicon-k8s.json +358 -10
  41. package/src/generated/operations.json +96 -0
  42. package/src/group-namespace.ts +7 -0
  43. package/src/kustomize/render.ts +13 -1
  44. package/src/plugin.ts +17 -0
  45. package/src/testdata/workspace-members/argo/guestbook.yaml +28 -0
  46. package/src/testdata/workspace-members/argo/namespace.yaml +4 -0
  47. package/src/testdata/workspace-members/flux/apps.yaml +12 -0
  48. package/src/testdata/workspace-members/flux/kustomization.yaml +4 -0
  49. package/src/workspace-kinds.test.ts +35 -0
  50. package/src/workspace-member.test.ts +154 -0
  51. package/src/workspace-member.ts +128 -0
  52. package/workspace-kinds.json +94 -0
package/dist/okf/index.md CHANGED
@@ -30,6 +30,11 @@ okf_version: '0.2'
30
30
  * [CertificateSigningRequest](/types/CertificateSigningRequest.md) - K8s::Certificates::CertificateSigningRequest
31
31
  * [CertificateSigningRequestList](/types/CertificateSigningRequestList.md) - K8s::Certificates::CertificateSigningRequestList
32
32
  * [Challenge](/types/Challenge.md) - K8s::Acme::Challenge
33
+ * [ClickHouseCluster](/types/ClickHouseCluster.md) - K8s::ClickHouse::ClickHouseCluster
34
+ * [ClickHouseInstallation](/types/ClickHouseInstallation.md) - K8s::Altinity::ClickHouseInstallation
35
+ * [ClickHouseInstallationTemplate](/types/ClickHouseInstallationTemplate.md) - K8s::Altinity::ClickHouseInstallationTemplate
36
+ * [ClickHouseKeeperInstallation](/types/ClickHouseKeeperInstallation.md) - K8s::Altinity::ClickHouseKeeperInstallation
37
+ * [ClickHouseOperatorConfiguration](/types/ClickHouseOperatorConfiguration.md) - K8s::Altinity::ClickHouseOperatorConfiguration
33
38
  * [ClusterIssuer](/types/ClusterIssuer.md) - K8s::CertManager::ClusterIssuer
34
39
  * [ClusterObservability](/types/ClusterObservability.md) - K8s::OpenTelemetry::ClusterObservability
35
40
  * [ClusterResourceSet](/types/ClusterResourceSet.md) - K8s::Addons::ClusterResourceSet
@@ -125,6 +130,7 @@ okf_version: '0.2'
125
130
  * [Issuer](/types/Issuer.md) - K8s::CertManager::Issuer
126
131
  * [JobList](/types/JobList.md) - K8s::Batch::JobList
127
132
  * [K3sHelmChart](/types/K3sHelmChart.md) - K8s::K3s::HelmChart
133
+ * [KeeperCluster](/types/KeeperCluster.md) - K8s::ClickHouse::KeeperCluster
128
134
  * [Kustomization](/types/Kustomization.md) - K8s::Flux::Kustomization
129
135
  * [Lease](/types/Lease.md) - K8s::Coordination::Lease
130
136
  * [LeaseCandidate](/types/LeaseCandidate.md) - K8s::Coordination::LeaseCandidate
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: ClickHouseCluster
4
+ description: k8s resource type K8s::ClickHouse::ClickHouseCluster
5
+ name: ClickHouseCluster
6
+ lexicon: k8s
7
+ resource_type: K8s::ClickHouse::ClickHouseCluster
8
+ ---
9
+ `K8s::ClickHouse::ClickHouseCluster`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
14
+ - `spec` (`Record<string, unknown>`, optional): ClickHouseClusterSpec defines the desired state of ClickHouseCluster.
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: ClickHouseInstallation
4
+ description: k8s resource type K8s::Altinity::ClickHouseInstallation
5
+ name: ClickHouseInstallation
6
+ lexicon: k8s
7
+ resource_type: K8s::Altinity::ClickHouseInstallation
8
+ ---
9
+ `K8s::Altinity::ClickHouseInstallation`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `spec` (`Record<string, unknown>`, required): Specification of the desired behavior of one or more ClickHouse clusters More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
14
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: ClickHouseInstallationTemplate
4
+ description: k8s resource type K8s::Altinity::ClickHouseInstallationTemplate
5
+ name: ClickHouseInstallationTemplate
6
+ lexicon: k8s
7
+ resource_type: K8s::Altinity::ClickHouseInstallationTemplate
8
+ ---
9
+ `K8s::Altinity::ClickHouseInstallationTemplate`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `spec` (`Record<string, unknown>`, required): Specification of the desired behavior of one or more ClickHouse clusters More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
14
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: ClickHouseKeeperInstallation
4
+ description: k8s resource type K8s::Altinity::ClickHouseKeeperInstallation
5
+ name: ClickHouseKeeperInstallation
6
+ lexicon: k8s
7
+ resource_type: K8s::Altinity::ClickHouseKeeperInstallation
8
+ ---
9
+ `K8s::Altinity::ClickHouseKeeperInstallation`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `spec` (`Record<string, unknown>`, required): Specification of the desired behavior of one or more ClickHouse clusters More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
14
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: ClickHouseOperatorConfiguration
4
+ description: k8s resource type K8s::Altinity::ClickHouseOperatorConfiguration
5
+ name: ClickHouseOperatorConfiguration
6
+ lexicon: k8s
7
+ resource_type: K8s::Altinity::ClickHouseOperatorConfiguration
8
+ ---
9
+ `K8s::Altinity::ClickHouseOperatorConfiguration`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
14
+ - `spec` (`Record<string, unknown>`, optional): Allows to define settings of the clickhouse-operator. More info: https://github.com/Altinity/clickhouse-operator/blob/master/config/config.yaml Check into etc-clickhouse-operator* ConfigMaps if you need more control
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: resource-type
3
+ title: KeeperCluster
4
+ description: k8s resource type K8s::ClickHouse::KeeperCluster
5
+ name: KeeperCluster
6
+ lexicon: k8s
7
+ resource_type: K8s::ClickHouse::KeeperCluster
8
+ ---
9
+ `K8s::ClickHouse::KeeperCluster`, a resource type of the k8s lexicon.
10
+
11
+ ## Properties
12
+
13
+ - `metadata` (`ObjectMeta`, optional): Standard object's metadata.
14
+ - `spec` (`Record<string, unknown>`, optional): KeeperClusterSpec defines the desired state of KeeperCluster.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAgCjG,eAAO,MAAM,SAAS,EAAE,aA8uBvB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAiCjG,eAAO,MAAM,SAAS,EAAE,aA8vBvB,CAAC"}
package/dist/plugin.js CHANGED
@@ -26,6 +26,7 @@ import { k8sDeepNormalizationHooks } from "./deep-observe-hooks.js";
26
26
  import { LABEL_OWNERSHIP_KEYS } from "@intentius/chant/ownership";
27
27
  import { k8sConfigSchema } from "./config-schema.js";
28
28
  import { renderKustomizeRoots } from "./kustomize/root.js";
29
+ import { lastMemberReport, readK8sMember, setLastMemberReport } from "./workspace-member.js";
29
30
  import { encryptedSecretBuildRoot } from "./sops/encrypted-secret-file.js";
30
31
  import { k8sProjectCodegen } from "./crd/project-codegen.js";
31
32
  import { includeBuildRoot } from "./include/resolve.js";
@@ -95,6 +96,16 @@ export const k8sPlugin = {
95
96
  entities.set(name, entity);
96
97
  warnings.push(...rendered.warnings);
97
98
  }
99
+ // A workspace member's reader project (#3179): see ./workspace-member.ts.
100
+ setLastMemberReport(undefined);
101
+ const member = ctx.config.k8s?.member;
102
+ if (member) {
103
+ const read = await readK8sMember({ member });
104
+ for (const [name, entity] of read.entities)
105
+ entities.set(name, entity);
106
+ warnings.push(...read.warnings);
107
+ setLastMemberReport(read.report);
108
+ }
98
109
  const included = await includeBuildRoot(ctx);
99
110
  for (const [name, entity] of included.entities)
100
111
  entities.set(name, entity);
@@ -104,6 +115,11 @@ export const k8sPlugin = {
104
115
  warnings.push(...(encrypted.warnings ?? []));
105
116
  return { entities, warnings };
106
117
  },
118
+ // What the workspace member read (#3179): whether a kustomize member rendered, and why not.
119
+ graphMeta() {
120
+ const report = lastMemberReport();
121
+ return report ? { k8sMember: report } : undefined;
122
+ },
107
123
  // K8s YAML has no template interpolation functions like CloudFormation's
108
124
  // Fn::Sub or GitLab's !reference. Cross-resource references are handled by
109
125
  // the AttrRef system in the serializer (resolves to metadata.name).
@@ -331,6 +331,80 @@ export declare class Challenge {
331
331
  readonly uid: string;
332
332
  }
333
333
 
334
+ export declare class ClickHouseCluster {
335
+ constructor(props: {
336
+ /** Standard object's metadata. */
337
+ metadata?: ObjectMeta;
338
+ /** ClickHouseClusterSpec defines the desired state of ClickHouseCluster. */
339
+ spec?: Record<string, unknown>;
340
+ });
341
+ readonly name: string;
342
+ readonly namespace: string;
343
+ readonly status: Record<string, unknown>;
344
+ readonly uid: string;
345
+ }
346
+
347
+ export declare class ClickHouseInstallation {
348
+ constructor(props: {
349
+ /** Specification of the desired behavior of one or more ClickHouse clusters
350
+ More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
351
+ */
352
+ spec: Record<string, unknown>;
353
+ /** Standard object's metadata. */
354
+ metadata?: ObjectMeta;
355
+ });
356
+ readonly name: string;
357
+ readonly namespace: string;
358
+ readonly status: Record<string, unknown>;
359
+ readonly uid: string;
360
+ }
361
+
362
+ export declare class ClickHouseInstallationTemplate {
363
+ constructor(props: {
364
+ /** Specification of the desired behavior of one or more ClickHouse clusters
365
+ More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
366
+ */
367
+ spec: Record<string, unknown>;
368
+ /** Standard object's metadata. */
369
+ metadata?: ObjectMeta;
370
+ });
371
+ readonly name: string;
372
+ readonly namespace: string;
373
+ readonly status: Record<string, unknown>;
374
+ readonly uid: string;
375
+ }
376
+
377
+ export declare class ClickHouseKeeperInstallation {
378
+ constructor(props: {
379
+ /** Specification of the desired behavior of one or more ClickHouse clusters
380
+ More info: https://github.com/Altinity/clickhouse-operator/blob/master/docs/custom_resource_explained.md
381
+ */
382
+ spec: Record<string, unknown>;
383
+ /** Standard object's metadata. */
384
+ metadata?: ObjectMeta;
385
+ });
386
+ readonly name: string;
387
+ readonly namespace: string;
388
+ readonly status: Record<string, unknown>;
389
+ readonly uid: string;
390
+ }
391
+
392
+ export declare class ClickHouseOperatorConfiguration {
393
+ constructor(props: {
394
+ /** Standard object's metadata. */
395
+ metadata?: ObjectMeta;
396
+ /** Allows to define settings of the clickhouse-operator.
397
+ More info: https://github.com/Altinity/clickhouse-operator/blob/master/config/config.yaml
398
+ Check into etc-clickhouse-operator* ConfigMaps if you need more control
399
+ */
400
+ spec?: Record<string, unknown>;
401
+ });
402
+ readonly name: string;
403
+ readonly namespace: string;
404
+ readonly status: Record<string, unknown>;
405
+ readonly uid: string;
406
+ }
407
+
334
408
  export declare class ClusterIssuer {
335
409
  constructor(props: {
336
410
  /** Desired state of the ClusterIssuer resource. */
@@ -1694,6 +1768,19 @@ export declare class K3sHelmChart {
1694
1768
  readonly uid: string;
1695
1769
  }
1696
1770
 
1771
+ export declare class KeeperCluster {
1772
+ constructor(props: {
1773
+ /** Standard object's metadata. */
1774
+ metadata?: ObjectMeta;
1775
+ /** KeeperClusterSpec defines the desired state of KeeperCluster. */
1776
+ spec?: Record<string, unknown>;
1777
+ });
1778
+ readonly name: string;
1779
+ readonly namespace: string;
1780
+ readonly status: Record<string, unknown>;
1781
+ readonly uid: string;
1782
+ }
1783
+
1697
1784
  export declare class Kustomization {
1698
1785
  constructor(props: {
1699
1786
  /** Standard object's metadata. */
@@ -0,0 +1,35 @@
1
+ import type { Declarable } from "@intentius/chant/declarable";
2
+ import { type KustomizeRunner } from "./kustomize/render.js";
3
+ export type K8sMemberKind = "kustomize" | "argo-app" | "flux-kustomization";
4
+ export interface K8sMemberConfig {
5
+ kind: K8sMemberKind;
6
+ dir: string;
7
+ label?: string;
8
+ }
9
+ /** What one member's read found, carried on the graph's `meta.k8sMember`. */
10
+ export interface K8sMemberReport {
11
+ kind: K8sMemberKind;
12
+ /** Kustomize only: false when the render could not run. */
13
+ rendered?: boolean;
14
+ /** Why nothing was read; set with `rendered: false`. */
15
+ reason?: string;
16
+ /** The objects the member contributed. */
17
+ objects: number;
18
+ }
19
+ export declare function readK8sMember(opts: {
20
+ member: K8sMemberConfig;
21
+ /** Injectable renderer (tests); defaults to the real subprocess runner. */
22
+ run?: KustomizeRunner;
23
+ }): Promise<{
24
+ entities: Map<string, Declarable>;
25
+ warnings: string[];
26
+ report: K8sMemberReport;
27
+ }>;
28
+ /**
29
+ * The report of the read in this process. `graphMeta` receives only the
30
+ * entities, so the hook that read the member leaves its report here for the
31
+ * hook that publishes it; `chant graph` runs the two in order in one process.
32
+ */
33
+ export declare function setLastMemberReport(report: K8sMemberReport | undefined): void;
34
+ export declare function lastMemberReport(): K8sMemberReport | undefined;
35
+ //# sourceMappingURL=workspace-member.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-member.d.ts","sourceRoot":"","sources":["../src/workspace-member.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAiF,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGzI,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAE5E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AA8BD,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAC;IACxB,2EAA2E;IAC3E,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CAsC9F;AAID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAE7E;AAED,wBAAgB,gBAAgB,IAAI,eAAe,GAAG,SAAS,CAE9D"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Reading a workspace member into the graph (#3179).
3
+ *
4
+ * `chant workspace graph` writes a reader project for a member of kind
5
+ * `kustomize`, `argo-app` or `flux-kustomization`, with `k8s.member` in its
6
+ * config (see `workspace-kinds.json`). The k8s plugin's `buildRoots` hook calls
7
+ * {@link readK8sMember}, and the objects it returns are the member's nodes.
8
+ *
9
+ * - `kustomize` renders the directory through the kustomize runner (`kustomize
10
+ * build`, `kubectl kustomize` fallback). With neither binary installed there
11
+ * is nothing to read: the member contributes no objects and its report says
12
+ * `rendered: false` with the reason. A render the binary ran and refused is
13
+ * not that case and still throws.
14
+ * - `argo-app` and `flux-kustomization` read the directory's YAML files and keep
15
+ * the documents of their kind. No binary is involved.
16
+ */
17
+ import { readdirSync, readFileSync } from "node:fs";
18
+ import { basename, join } from "node:path";
19
+ import { loadAll } from "js-yaml";
20
+ import { defaultKustomizeRunner, KustomizeBinaryMissingError, renderKustomizeDocuments } from "./kustomize/render.js";
21
+ import { addRenderedEntity, renderedManifestEntity } from "./kustomize/rendered-entity.js";
22
+ /** The apiVersion group and kind each manifest kind is made of. */
23
+ const MANIFEST_KINDS = {
24
+ "argo-app": { group: "argoproj.io", kind: "Application" },
25
+ "flux-kustomization": { group: "kustomize.toolkit.fluxcd.io", kind: "Kustomization" },
26
+ };
27
+ function objectDocuments(text) {
28
+ const out = [];
29
+ for (const doc of loadAll(text)) {
30
+ if (doc && typeof doc === "object" && !Array.isArray(doc))
31
+ out.push(doc);
32
+ }
33
+ return out;
34
+ }
35
+ /** The documents of `kind` in the YAML files directly in `dir`, in file-name order. */
36
+ function manifestDocuments(dir, kind) {
37
+ const want = MANIFEST_KINDS[kind];
38
+ const files = readdirSync(dir).filter((f) => /\.ya?ml$/.test(f)).sort();
39
+ const docs = [];
40
+ for (const file of files) {
41
+ for (const doc of objectDocuments(readFileSync(join(dir, file), "utf-8"))) {
42
+ const apiVersion = doc.apiVersion;
43
+ if (typeof apiVersion === "string" && apiVersion.startsWith(`${want.group}/`) && doc.kind === want.kind)
44
+ docs.push(doc);
45
+ }
46
+ }
47
+ return docs;
48
+ }
49
+ export async function readK8sMember(opts) {
50
+ const { member } = opts;
51
+ const label = member.label ?? basename(member.dir);
52
+ const entities = new Map();
53
+ const warnings = [];
54
+ let documents;
55
+ let rendered;
56
+ let reason;
57
+ if (member.kind === "kustomize") {
58
+ try {
59
+ documents = await renderKustomizeDocuments(member.dir, opts.run ?? defaultKustomizeRunner);
60
+ rendered = true;
61
+ }
62
+ catch (err) {
63
+ if (!(err instanceof KustomizeBinaryMissingError))
64
+ throw err;
65
+ documents = [];
66
+ rendered = false;
67
+ reason = err.message;
68
+ warnings.push(`kustomize member "${label}" was not rendered: ${err.message}`);
69
+ }
70
+ }
71
+ else {
72
+ documents = manifestDocuments(member.dir, member.kind);
73
+ }
74
+ for (const doc of documents) {
75
+ const entity = renderedManifestEntity(doc, label);
76
+ if (!entity) {
77
+ warnings.push(`${member.kind} member "${label}" has a document without apiVersion/kind; skipped`);
78
+ continue;
79
+ }
80
+ addRenderedEntity(entities, label, entity);
81
+ }
82
+ return {
83
+ entities,
84
+ warnings,
85
+ report: { kind: member.kind, ...(rendered === undefined ? {} : { rendered }), ...(reason ? { reason } : {}), objects: entities.size },
86
+ };
87
+ }
88
+ let lastReport;
89
+ /**
90
+ * The report of the read in this process. `graphMeta` receives only the
91
+ * entities, so the hook that read the member leaves its report here for the
92
+ * hook that publishes it; `chant graph` runs the two in order in one process.
93
+ */
94
+ export function setLastMemberReport(report) {
95
+ lastReport = report;
96
+ }
97
+ export function lastMemberReport() {
98
+ return lastReport;
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-k8s",
3
- "version": "0.124.48",
3
+ "version": "0.124.50",
4
4
  "description": "Kubernetes lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -23,12 +23,14 @@
23
23
  "type": "module",
24
24
  "files": [
25
25
  "src/",
26
- "dist/"
26
+ "dist/",
27
+ "workspace-kinds.json"
27
28
  ],
28
29
  "publishConfig": {
29
30
  "access": "public"
30
31
  },
31
32
  "exports": {
33
+ "./workspace-kinds": "./workspace-kinds.json",
32
34
  ".": {
33
35
  "development": "./src/index.ts",
34
36
  "types": "./dist/index.d.ts",
@@ -72,13 +74,13 @@
72
74
  "build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json && cp src/generated/index.d.ts dist/generated/index.d.d.ts"
73
75
  },
74
76
  "dependencies": {
75
- "@intentius/chant-lexicon-otel": "^0.124.48",
76
- "@intentius/chant-lexicon-prometheus": "^0.124.48",
77
+ "@intentius/chant-lexicon-otel": "^0.124.50",
78
+ "@intentius/chant-lexicon-prometheus": "^0.124.50",
77
79
  "js-yaml": "^4.3.1",
78
80
  "@types/js-yaml": "^4.0.9"
79
81
  },
80
82
  "optionalDependencies": {
81
- "@intentius/chant-k8s-client": "^0.124.48"
83
+ "@intentius/chant-k8s-client": "^0.124.50"
82
84
  },
83
85
  "devDependencies": {
84
86
  "@intentius/chant": "*",
@@ -86,6 +88,6 @@
86
88
  },
87
89
  "peerDependencies": {
88
90
  "zod": "^4.3.6",
89
- "@intentius/chant": "^0.124.48"
91
+ "@intentius/chant": "^0.124.50"
90
92
  }
91
93
  }
@@ -73,6 +73,13 @@ export const k8sConfigSchema = z.strictObject({
73
73
  .optional(),
74
74
  })
75
75
  .optional(),
76
+ member: z
77
+ .strictObject({
78
+ kind: z.enum(["kustomize", "argo-app", "flux-kustomization"]),
79
+ dir: z.string().min(1),
80
+ label: z.string().optional(),
81
+ })
82
+ .optional(),
76
83
  receipts: z
77
84
  .strictObject({
78
85
  namespace: z.string().optional(),
package/src/config.ts CHANGED
@@ -121,6 +121,25 @@ export interface K8sChantConfig {
121
121
  roots?: Array<string | { path: string; patches?: RenderedPatch[] }>;
122
122
  };
123
123
 
124
+ /**
125
+ * One workspace member read into the graph (#3179). `chant workspace graph`
126
+ * writes this into the reader project it makes for a member of kind
127
+ * `kustomize`, `argo-app` or `flux-kustomization`; it is not meant to be
128
+ * written by hand. `dir` is the member's directory, absolute; `label` names
129
+ * the entities (`<label>/deploymentWeb`), the member's name.
130
+ *
131
+ * A kustomize member is rendered, so it needs `kustomize` or `kubectl`. With
132
+ * neither installed the graph carries no objects for it and says why on
133
+ * `meta.k8sMember` (`rendered: false`, `reason`); a render the binary ran
134
+ * and refused still fails. An Argo or Flux member is read from its manifests
135
+ * and needs no binary.
136
+ */
137
+ member?: {
138
+ kind: "kustomize" | "argo-app" | "flux-kustomization";
139
+ dir: string;
140
+ label?: string;
141
+ };
142
+
124
143
  /**
125
144
  * Effect receipt settings (#2074, epic #1703).
126
145
  *
@@ -0,0 +1,105 @@
1
+ /**
2
+ * ClickHouse operator CRDs: ClickHouse Inc.'s (clickhouse.com) and Altinity's
3
+ * (clickhouse.altinity.com, clickhouse-keeper.altinity.com). One resource of
4
+ * each operator's main kind, plus the namespace split between the two.
5
+ */
6
+
7
+ import { describe, test, expect } from "vitest";
8
+ import {
9
+ ClickHouseCluster,
10
+ KeeperCluster,
11
+ ClickHouseInstallation,
12
+ ClickHouseInstallationTemplate,
13
+ ClickHouseKeeperInstallation,
14
+ ClickHouseOperatorConfiguration,
15
+ } from "../generated";
16
+ import lexiconJson from "../generated/lexicon-k8s.json";
17
+ import { k8sSerializer } from "../serializer";
18
+ import { namespaceSegmentForGroup } from "../group-namespace";
19
+ import { parseYAML } from "@intentius/chant/yaml";
20
+
21
+ function synth(logicalName: string, resource: unknown): any {
22
+ const yaml = k8sSerializer.serialize(new Map([[logicalName, resource as never]])) as string;
23
+ return parseYAML(yaml);
24
+ }
25
+
26
+ describe("ClickHouse operator (clickhouse.com)", () => {
27
+ test("ClickHouseCluster carries the apiVersion and kind", () => {
28
+ const doc = synth(
29
+ "analytics",
30
+ new ClickHouseCluster({
31
+ metadata: { name: "analytics", namespace: "data" },
32
+ spec: { replicas: 2, shards: 1, keeperClusterRef: { name: "analytics-keeper" } },
33
+ }),
34
+ );
35
+ expect(doc.apiVersion).toBe("clickhouse.com/v1alpha1");
36
+ expect(doc.kind).toBe("ClickHouseCluster");
37
+ expect(doc.metadata.name).toBe("analytics");
38
+ expect(doc.spec.replicas).toBe(2);
39
+ expect(doc.spec.keeperClusterRef).toEqual({ name: "analytics-keeper" });
40
+ });
41
+
42
+ test("KeeperCluster carries the apiVersion and kind", () => {
43
+ const doc = synth(
44
+ "analyticsKeeper",
45
+ new KeeperCluster({ metadata: { name: "analytics-keeper" }, spec: { replicas: 3 } }),
46
+ );
47
+ expect(doc.apiVersion).toBe("clickhouse.com/v1alpha1");
48
+ expect(doc.kind).toBe("KeeperCluster");
49
+ expect(doc.spec.replicas).toBe(3);
50
+ });
51
+ });
52
+
53
+ describe("Altinity ClickHouse operator (clickhouse.altinity.com)", () => {
54
+ test("ClickHouseInstallation carries the apiVersion and kind", () => {
55
+ const doc = synth(
56
+ "analytics",
57
+ new ClickHouseInstallation({
58
+ metadata: { name: "analytics", namespace: "data" },
59
+ spec: {
60
+ configuration: {
61
+ clusters: [{ name: "main", layout: { shardsCount: 1, replicasCount: 2 } }],
62
+ },
63
+ },
64
+ }),
65
+ );
66
+ expect(doc.apiVersion).toBe("clickhouse.altinity.com/v1");
67
+ expect(doc.kind).toBe("ClickHouseInstallation");
68
+ expect(doc.spec.configuration.clusters[0].layout).toEqual({ shardsCount: 1, replicasCount: 2 });
69
+ });
70
+
71
+ test("the other three kinds keep their groups", () => {
72
+ const kinds: Array<[unknown, string, string]> = [
73
+ [new ClickHouseInstallationTemplate({ metadata: { name: "t" }, spec: {} }), "clickhouse.altinity.com/v1", "ClickHouseInstallationTemplate"],
74
+ [new ClickHouseOperatorConfiguration({ metadata: { name: "c" }, spec: {} }), "clickhouse.altinity.com/v1", "ClickHouseOperatorConfiguration"],
75
+ [new ClickHouseKeeperInstallation({ metadata: { name: "k" }, spec: {} }), "clickhouse-keeper.altinity.com/v1", "ClickHouseKeeperInstallation"],
76
+ ];
77
+ for (const [resource, apiVersion, kind] of kinds) {
78
+ const doc = synth("r", resource);
79
+ expect(doc.apiVersion).toBe(apiVersion);
80
+ expect(doc.kind).toBe(kind);
81
+ }
82
+ });
83
+ });
84
+
85
+ describe("namespaces", () => {
86
+ test("the two operators do not share one", () => {
87
+ expect(namespaceSegmentForGroup("clickhouse.com")).toBe("ClickHouse");
88
+ expect(namespaceSegmentForGroup("clickhouse.altinity.com")).toBe("Altinity");
89
+ expect(namespaceSegmentForGroup("clickhouse-keeper.altinity.com")).toBe("Altinity");
90
+ });
91
+
92
+ test("every kind is generated under its operator's namespace", () => {
93
+ const types = Object.values(lexiconJson as Record<string, { resourceType?: string }>).map((e) => e.resourceType);
94
+ for (const t of [
95
+ "K8s::ClickHouse::ClickHouseCluster",
96
+ "K8s::ClickHouse::KeeperCluster",
97
+ "K8s::Altinity::ClickHouseInstallation",
98
+ "K8s::Altinity::ClickHouseInstallationTemplate",
99
+ "K8s::Altinity::ClickHouseKeeperInstallation",
100
+ "K8s::Altinity::ClickHouseOperatorConfiguration",
101
+ ]) {
102
+ expect(types).toContain(t);
103
+ }
104
+ });
105
+ });
@@ -529,6 +529,48 @@ const GRAFANA_OPERATOR_CRD_BASE = `https://raw.githubusercontent.com/grafana/gra
529
529
  const OTEL_OPERATOR_VERSION = "v0.160.0";
530
530
  const OTEL_OPERATOR_CRD_BASE = `https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/${OTEL_OPERATOR_VERSION}/config/crd/bases`;
531
531
 
532
+ /**
533
+ * ClickHouse Kubernetes Operator CRDs (ClickHouse Inc.) — clickhouse.com/v1alpha1
534
+ *
535
+ * The vendor's own operator, repo `ClickHouse/clickhouse-operator`. Pinned to
536
+ * tag v0.0.8 (the latest release; commit ebcb5b6). Both CRDs are read from
537
+ * `config/crd/bases/` at that tag, which exists there. Produces, under the
538
+ * `ClickHouse` namespace (GROUP_NAMESPACE_OVERRIDES in group-namespace.ts):
539
+ * K8s::ClickHouse::ClickHouseCluster → apiVersion: clickhouse.com/v1alpha1, kind: ClickHouseCluster
540
+ * K8s::ClickHouse::KeeperCluster → apiVersion: clickhouse.com/v1alpha1, kind: KeeperCluster
541
+ *
542
+ * Not the same operator as Altinity's below: different group, different kinds,
543
+ * and a `ClickHouseCluster` here is unrelated to Altinity's
544
+ * `ClickHouseInstallation`. Do not install both against one cluster.
545
+ *
546
+ * Operator install: kubectl apply -f
547
+ * https://github.com/ClickHouse/clickhouse-operator/releases/download/v0.0.8/clickhouse-operator.yaml
548
+ */
549
+ const CLICKHOUSE_OPERATOR_VERSION = "v0.0.8";
550
+ const CLICKHOUSE_OPERATOR_CRD_BASE = `https://raw.githubusercontent.com/ClickHouse/clickhouse-operator/${CLICKHOUSE_OPERATOR_VERSION}/config/crd/bases`;
551
+
552
+ /**
553
+ * Altinity ClickHouse Operator CRDs — clickhouse.altinity.com/v1 and
554
+ * clickhouse-keeper.altinity.com/v1
555
+ *
556
+ * Repo `Altinity/clickhouse-operator`. Pinned to tag release-0.27.4 (the latest
557
+ * release; commit 8249865). The CRDs are read from
558
+ * `deploy/helm/clickhouse-operator/crds/` at that tag, which exists there; the
559
+ * file names carry a `CustomResourceDefinition-` prefix. Both groups map to the
560
+ * `Altinity` namespace (GROUP_NAMESPACE_OVERRIDES in group-namespace.ts); the
561
+ * first-segment rule would give `Clickhouse` for both, which
562
+ * would sit beside the vendor operator above under a near-identical name:
563
+ * K8s::Altinity::ClickHouseInstallation → clickhouse.altinity.com/v1
564
+ * K8s::Altinity::ClickHouseInstallationTemplate → clickhouse.altinity.com/v1
565
+ * K8s::Altinity::ClickHouseOperatorConfiguration → clickhouse.altinity.com/v1
566
+ * K8s::Altinity::ClickHouseKeeperInstallation → clickhouse-keeper.altinity.com/v1
567
+ *
568
+ * Operator install: kubectl apply -f
569
+ * https://raw.githubusercontent.com/Altinity/clickhouse-operator/release-0.27.4/deploy/operator/clickhouse-operator-install-bundle.yaml
570
+ */
571
+ const ALTINITY_OPERATOR_VERSION = "release-0.27.4";
572
+ const ALTINITY_OPERATOR_CRD_BASE = `https://raw.githubusercontent.com/Altinity/clickhouse-operator/${ALTINITY_OPERATOR_VERSION}/deploy/helm/clickhouse-operator/crds`;
573
+
532
574
  export const CRD_SOURCES: CRDSource[] = [
533
575
  { type: "url", url: `${KUBERAY_CRD_BASE}/ray.io_rayclusters.yaml` },
534
576
  { type: "url", url: `${KUBERAY_CRD_BASE}/ray.io_rayjobs.yaml` },
@@ -637,4 +679,10 @@ export const CRD_SOURCES: CRDSource[] = [
637
679
  { type: "url", url: `${OTEL_OPERATOR_CRD_BASE}/opentelemetry.io_targetallocators.yaml` },
638
680
  { type: "url", url: `${OTEL_OPERATOR_CRD_BASE}/opentelemetry.io_opampbridges.yaml` },
639
681
  { type: "url", url: `${OTEL_OPERATOR_CRD_BASE}/opentelemetry.io_clusterobservabilities.yaml` },
682
+ { type: "url", url: `${CLICKHOUSE_OPERATOR_CRD_BASE}/clickhouse.com_clickhouseclusters.yaml` },
683
+ { type: "url", url: `${CLICKHOUSE_OPERATOR_CRD_BASE}/clickhouse.com_keeperclusters.yaml` },
684
+ { type: "url", url: `${ALTINITY_OPERATOR_CRD_BASE}/CustomResourceDefinition-clickhouseinstallations.clickhouse.altinity.com.yaml` },
685
+ { type: "url", url: `${ALTINITY_OPERATOR_CRD_BASE}/CustomResourceDefinition-clickhouseinstallationtemplates.clickhouse.altinity.com.yaml` },
686
+ { type: "url", url: `${ALTINITY_OPERATOR_CRD_BASE}/CustomResourceDefinition-clickhousekeeperinstallations.clickhouse-keeper.altinity.com.yaml` },
687
+ { type: "url", url: `${ALTINITY_OPERATOR_CRD_BASE}/CustomResourceDefinition-clickhouseoperatorconfigurations.clickhouse.altinity.com.yaml` },
640
688
  ];