@intentius/chant-lexicon-k8s 0.18.36 → 0.19.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.
@@ -2,6 +2,17 @@
2
2
 
3
3
  // --- Kubernetes Resource classes ---
4
4
 
5
+ export declare class Alert {
6
+ constructor(props: {
7
+ metadata?: Record<string, unknown>;
8
+ /** AlertSpec defines an alerting rule for events involving a list of objects. */
9
+ spec?: Record<string, unknown>;
10
+ });
11
+ readonly name: string;
12
+ readonly namespace: string;
13
+ readonly uid: string;
14
+ }
15
+
5
16
  export declare class APIGroup {
6
17
  constructor(props: {
7
18
  /** name is the name of the group. */
@@ -137,6 +148,19 @@ export declare class Binding {
137
148
  readonly uid: string;
138
149
  }
139
150
 
151
+ export declare class Bucket {
152
+ constructor(props: {
153
+ metadata?: Record<string, unknown>;
154
+ /** BucketSpec specifies the required configuration to produce an Artifact for
155
+ an object storage bucket. */
156
+ spec?: Record<string, unknown>;
157
+ });
158
+ readonly name: string;
159
+ readonly namespace: string;
160
+ readonly status: Record<string, unknown>;
161
+ readonly uid: string;
162
+ }
163
+
140
164
  export declare class Certificate {
141
165
  constructor(props: {
142
166
  metadata?: Record<string, unknown>;
@@ -858,6 +882,30 @@ export declare class FlowSchemaList {
858
882
  readonly uid: string;
859
883
  }
860
884
 
885
+ export declare class FluxInstance {
886
+ constructor(props: {
887
+ metadata?: Record<string, unknown>;
888
+ /** FluxInstanceSpec defines the desired state of FluxInstance */
889
+ spec?: Record<string, unknown>;
890
+ });
891
+ readonly name: string;
892
+ readonly namespace: string;
893
+ readonly status: Record<string, unknown>;
894
+ readonly uid: string;
895
+ }
896
+
897
+ export declare class FluxReport {
898
+ constructor(props: {
899
+ metadata?: Record<string, unknown>;
900
+ /** FluxReportSpec defines the observed state of a Flux installation. */
901
+ spec?: Record<string, unknown>;
902
+ });
903
+ readonly name: string;
904
+ readonly namespace: string;
905
+ readonly status: Record<string, unknown>;
906
+ readonly uid: string;
907
+ }
908
+
861
909
  export declare class Gateway {
862
910
  constructor(props: {
863
911
  /** Spec defines the desired state of Gateway. */
@@ -882,6 +930,19 @@ export declare class GatewayClass {
882
930
  readonly uid: string;
883
931
  }
884
932
 
933
+ export declare class GitRepository {
934
+ constructor(props: {
935
+ metadata?: Record<string, unknown>;
936
+ /** GitRepositorySpec specifies the required configuration to produce an
937
+ Artifact for a Git repository. */
938
+ spec?: Record<string, unknown>;
939
+ });
940
+ readonly name: string;
941
+ readonly namespace: string;
942
+ readonly status: Record<string, unknown>;
943
+ readonly uid: string;
944
+ }
945
+
885
946
  export declare class GRPCRoute {
886
947
  constructor(props: {
887
948
  metadata?: Record<string, unknown>;
@@ -894,6 +955,43 @@ export declare class GRPCRoute {
894
955
  readonly uid: string;
895
956
  }
896
957
 
958
+ export declare class HelmChart {
959
+ constructor(props: {
960
+ metadata?: Record<string, unknown>;
961
+ /** HelmChartSpec specifies the desired state of a Helm chart. */
962
+ spec?: Record<string, unknown>;
963
+ });
964
+ readonly name: string;
965
+ readonly namespace: string;
966
+ readonly status: Record<string, unknown>;
967
+ readonly uid: string;
968
+ }
969
+
970
+ export declare class HelmRelease {
971
+ constructor(props: {
972
+ metadata?: Record<string, unknown>;
973
+ /** HelmReleaseSpec defines the desired state of a Helm release. */
974
+ spec?: Record<string, unknown>;
975
+ });
976
+ readonly name: string;
977
+ readonly namespace: string;
978
+ readonly status: Record<string, unknown>;
979
+ readonly uid: string;
980
+ }
981
+
982
+ export declare class HelmRepository {
983
+ constructor(props: {
984
+ metadata?: Record<string, unknown>;
985
+ /** HelmRepositorySpec specifies the required configuration to produce an
986
+ Artifact for a Helm repository index YAML. */
987
+ spec?: Record<string, unknown>;
988
+ });
989
+ readonly name: string;
990
+ readonly namespace: string;
991
+ readonly status: Record<string, unknown>;
992
+ readonly uid: string;
993
+ }
994
+
897
995
  export declare class HorizontalPodAutoscaler {
898
996
  constructor(props: {
899
997
  /** spec is the specification for the behaviour of the autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. */
@@ -942,6 +1040,44 @@ export declare class HTTPRoute {
942
1040
  readonly uid: string;
943
1041
  }
944
1042
 
1043
+ export declare class ImagePolicy {
1044
+ constructor(props: {
1045
+ metadata?: Record<string, unknown>;
1046
+ /** ImagePolicySpec defines the parameters for calculating the
1047
+ ImagePolicy. */
1048
+ spec?: Record<string, unknown>;
1049
+ });
1050
+ readonly name: string;
1051
+ readonly namespace: string;
1052
+ readonly status: Record<string, unknown>;
1053
+ readonly uid: string;
1054
+ }
1055
+
1056
+ export declare class ImageRepository {
1057
+ constructor(props: {
1058
+ metadata?: Record<string, unknown>;
1059
+ /** ImageRepositorySpec defines the parameters for scanning an image
1060
+ repository, e.g., `fluxcd/flux`. */
1061
+ spec?: Record<string, unknown>;
1062
+ });
1063
+ readonly name: string;
1064
+ readonly namespace: string;
1065
+ readonly status: Record<string, unknown>;
1066
+ readonly uid: string;
1067
+ }
1068
+
1069
+ export declare class ImageUpdateAutomation {
1070
+ constructor(props: {
1071
+ metadata?: Record<string, unknown>;
1072
+ /** ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation */
1073
+ spec?: Record<string, unknown>;
1074
+ });
1075
+ readonly name: string;
1076
+ readonly namespace: string;
1077
+ readonly status: Record<string, unknown>;
1078
+ readonly uid: string;
1079
+ }
1080
+
945
1081
  export declare class Ing {
946
1082
  constructor(props: {
947
1083
  /** Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */
@@ -1062,6 +1198,19 @@ export declare class JobList {
1062
1198
  readonly uid: string;
1063
1199
  }
1064
1200
 
1201
+ export declare class Kustomization {
1202
+ constructor(props: {
1203
+ metadata?: Record<string, unknown>;
1204
+ /** KustomizationSpec defines the configuration to calculate the desired state
1205
+ from a Source using Kustomize. */
1206
+ spec?: Record<string, unknown>;
1207
+ });
1208
+ readonly name: string;
1209
+ readonly namespace: string;
1210
+ readonly status: Record<string, unknown>;
1211
+ readonly uid: string;
1212
+ }
1213
+
1065
1214
  export declare class Lease {
1066
1215
  constructor(props: {
1067
1216
  /** More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */
@@ -1314,6 +1463,18 @@ export declare class NS {
1314
1463
  readonly uid: string;
1315
1464
  }
1316
1465
 
1466
+ export declare class OCIRepository {
1467
+ constructor(props: {
1468
+ metadata?: Record<string, unknown>;
1469
+ /** OCIRepositorySpec defines the desired state of OCIRepository */
1470
+ spec?: Record<string, unknown>;
1471
+ });
1472
+ readonly name: string;
1473
+ readonly namespace: string;
1474
+ readonly status: Record<string, unknown>;
1475
+ readonly uid: string;
1476
+ }
1477
+
1317
1478
  export declare class Order {
1318
1479
  constructor(props: {
1319
1480
  metadata: Record<string, unknown>;
@@ -1546,6 +1707,17 @@ export declare class PrometheusRule {
1546
1707
  readonly uid: string;
1547
1708
  }
1548
1709
 
1710
+ export declare class Provider {
1711
+ constructor(props: {
1712
+ metadata?: Record<string, unknown>;
1713
+ /** ProviderSpec defines the desired state of the Provider. */
1714
+ spec?: Record<string, unknown>;
1715
+ });
1716
+ readonly name: string;
1717
+ readonly namespace: string;
1718
+ readonly uid: string;
1719
+ }
1720
+
1549
1721
  export declare class PV {
1550
1722
  constructor(props: {
1551
1723
  /** Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata */
@@ -1603,6 +1775,18 @@ export declare class RayService {
1603
1775
  readonly uid: string;
1604
1776
  }
1605
1777
 
1778
+ export declare class Receiver {
1779
+ constructor(props: {
1780
+ metadata?: Record<string, unknown>;
1781
+ /** ReceiverSpec defines the desired state of the Receiver. */
1782
+ spec?: Record<string, unknown>;
1783
+ });
1784
+ readonly name: string;
1785
+ readonly namespace: string;
1786
+ readonly status: Record<string, unknown>;
1787
+ readonly uid: string;
1788
+ }
1789
+
1606
1790
  export declare class ReferenceGrant {
1607
1791
  constructor(props: {
1608
1792
  metadata?: Record<string, unknown>;
@@ -1736,6 +1920,30 @@ export declare class ResourceQuotaList {
1736
1920
  readonly uid: string;
1737
1921
  }
1738
1922
 
1923
+ export declare class ResourceSet {
1924
+ constructor(props: {
1925
+ metadata?: Record<string, unknown>;
1926
+ /** ResourceSetSpec defines the desired state of ResourceSet */
1927
+ spec?: Record<string, unknown>;
1928
+ });
1929
+ readonly name: string;
1930
+ readonly namespace: string;
1931
+ readonly status: Record<string, unknown>;
1932
+ readonly uid: string;
1933
+ }
1934
+
1935
+ export declare class ResourceSetInputProvider {
1936
+ constructor(props: {
1937
+ metadata?: Record<string, unknown>;
1938
+ /** ResourceSetInputProviderSpec defines the desired state of ResourceSetInputProvider */
1939
+ spec?: Record<string, unknown>;
1940
+ });
1941
+ readonly name: string;
1942
+ readonly namespace: string;
1943
+ readonly status: Record<string, unknown>;
1944
+ readonly uid: string;
1945
+ }
1946
+
1739
1947
  export declare class ResourceSlice {
1740
1948
  constructor(props: {
1741
1949
  /** Contains the information published by the driver.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-k8s",
3
- "version": "0.18.36",
3
+ "version": "0.19.0",
4
4
  "description": "Kubernetes lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -75,7 +75,7 @@
75
75
  "typescript": "^5.9.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@intentius/chant": "^0.18.36",
78
+ "@intentius/chant": "^0.19.0",
79
79
  "typescript": "^5.9.3"
80
80
  }
81
81
  }
@@ -107,6 +107,49 @@ const CERT_MANAGER_CRD_BUNDLE = `https://github.com/cert-manager/cert-manager/re
107
107
  const PROM_OPERATOR_VERSION = "v0.79.2";
108
108
  const PROM_OPERATOR_CRD_BASE = `https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/${PROM_OPERATOR_VERSION}/example/prometheus-operator-crd`;
109
109
 
110
+ /**
111
+ * Flux GitOps Toolkit CRDs — the five `*.toolkit.fluxcd.io` groups.
112
+ *
113
+ * The flux2 release `install.yaml` is a single multi-doc bundle (controllers,
114
+ * RBAC, and CRDs); the parser keeps only the CustomResourceDefinition docs, and
115
+ * the `kinds` allowlist below narrows those to the supported set — the bundle
116
+ * also carries `ExternalArtifact` and `ArtifactGenerator` (experimental, and a
117
+ * separate `source.extensions.fluxcd.io` group), which are intentionally left
118
+ * out. All groups map to the `Flux` namespace (see GROUP_NAMESPACE_OVERRIDES in
119
+ * crd/parser.ts):
120
+ * K8s::Flux::GitRepository / OCIRepository / HelmRepository / HelmChart / Bucket
121
+ * → source.toolkit.fluxcd.io/v1
122
+ * K8s::Flux::Kustomization → kustomize.toolkit.fluxcd.io/v1
123
+ * K8s::Flux::HelmRelease → helm.toolkit.fluxcd.io/v2
124
+ * K8s::Flux::Provider / Alert → notification.toolkit.fluxcd.io/v1beta3
125
+ * K8s::Flux::Receiver → notification.toolkit.fluxcd.io/v1
126
+ * K8s::Flux::ImagePolicy / ImageRepository / ImageUpdateAutomation
127
+ * → image.toolkit.fluxcd.io/v1
128
+ *
129
+ * Controller install: kubectl apply -f
130
+ * https://github.com/fluxcd/flux2/releases/download/v2.9.1/install.yaml
131
+ */
132
+ const FLUX_TOOLKIT_VERSION = "v2.9.1";
133
+ const FLUX_TOOLKIT_INSTALL = `https://github.com/fluxcd/flux2/releases/download/${FLUX_TOOLKIT_VERSION}/install.yaml`;
134
+
135
+ /**
136
+ * Flux Operator CRDs — fluxcd.controlplane.io/v1
137
+ *
138
+ * The operator that installs and manages a Flux instance declaratively. Its
139
+ * release `install.yaml` bundles the four CRDs alongside the operator
140
+ * Deployment/RBAC; the parser keeps only the CRDs. They map to the `Flux`
141
+ * namespace (GROUP_NAMESPACE_OVERRIDES):
142
+ * K8s::Flux::FluxInstance → fluxcd.controlplane.io/v1
143
+ * K8s::Flux::FluxReport → fluxcd.controlplane.io/v1
144
+ * K8s::Flux::ResourceSet → fluxcd.controlplane.io/v1
145
+ * K8s::Flux::ResourceSetInputProvider → fluxcd.controlplane.io/v1
146
+ *
147
+ * Operator install: kubectl apply -f
148
+ * https://github.com/controlplaneio-fluxcd/flux-operator/releases/download/v0.54.1/install.yaml
149
+ */
150
+ const FLUX_OPERATOR_VERSION = "v0.54.1";
151
+ const FLUX_OPERATOR_INSTALL = `https://github.com/controlplaneio-fluxcd/flux-operator/releases/download/${FLUX_OPERATOR_VERSION}/install.yaml`;
152
+
110
153
  export const CRD_SOURCES: CRDSource[] = [
111
154
  { type: "url", url: `${KUBERAY_CRD_BASE}/ray.io_rayclusters.yaml` },
112
155
  { type: "url", url: `${KUBERAY_CRD_BASE}/ray.io_rayjobs.yaml` },
@@ -123,4 +166,28 @@ export const CRD_SOURCES: CRDSource[] = [
123
166
  { type: "url", url: CERT_MANAGER_CRD_BUNDLE },
124
167
  { type: "url", url: `${PROM_OPERATOR_CRD_BASE}/monitoring.coreos.com_servicemonitors.yaml` },
125
168
  { type: "url", url: `${PROM_OPERATOR_CRD_BASE}/monitoring.coreos.com_prometheusrules.yaml` },
169
+ {
170
+ type: "url",
171
+ url: FLUX_TOOLKIT_INSTALL,
172
+ kinds: [
173
+ "GitRepository",
174
+ "OCIRepository",
175
+ "HelmRepository",
176
+ "HelmChart",
177
+ "Bucket",
178
+ "Kustomization",
179
+ "HelmRelease",
180
+ "Provider",
181
+ "Alert",
182
+ "Receiver",
183
+ "ImagePolicy",
184
+ "ImageRepository",
185
+ "ImageUpdateAutomation",
186
+ ],
187
+ },
188
+ {
189
+ type: "url",
190
+ url: FLUX_OPERATOR_INSTALL,
191
+ kinds: ["FluxInstance", "FluxReport", "ResourceSet", "ResourceSetInputProvider"],
192
+ },
126
193
  ];
@@ -0,0 +1,60 @@
1
+ import { describe, test, expect, afterAll } from "vitest";
2
+ import { writeFileSync, rmSync, mkdtempSync } from "fs";
3
+ import { join } from "path";
4
+ import { tmpdir } from "os";
5
+ import { loadCRDs } from "./loader";
6
+
7
+ // A two-CRD bundle standing in for a multi-doc install.yaml.
8
+ const BUNDLE = `
9
+ apiVersion: apiextensions.k8s.io/v1
10
+ kind: CustomResourceDefinition
11
+ metadata:
12
+ name: gitrepositories.source.toolkit.fluxcd.io
13
+ spec:
14
+ group: source.toolkit.fluxcd.io
15
+ names: { kind: GitRepository, plural: gitrepositories }
16
+ scope: Namespaced
17
+ versions:
18
+ - name: v1
19
+ served: true
20
+ storage: true
21
+ schema: { openAPIV3Schema: { type: object } }
22
+ ---
23
+ apiVersion: apiextensions.k8s.io/v1
24
+ kind: CustomResourceDefinition
25
+ metadata:
26
+ name: externalartifacts.source.toolkit.fluxcd.io
27
+ spec:
28
+ group: source.toolkit.fluxcd.io
29
+ names: { kind: ExternalArtifact, plural: externalartifacts }
30
+ scope: Namespaced
31
+ versions:
32
+ - name: v1
33
+ served: true
34
+ storage: true
35
+ schema: { openAPIV3Schema: { type: object } }
36
+ `;
37
+
38
+ const dir = mkdtempSync(join(tmpdir(), "chant-crd-loader-"));
39
+
40
+ afterAll(() => {
41
+ rmSync(dir, { recursive: true, force: true });
42
+ });
43
+
44
+ describe("loadCRDs kinds allowlist", () => {
45
+ test("keeps only allowlisted kinds from a multi-doc bundle", async () => {
46
+ const path = join(dir, "bundle.yaml");
47
+ writeFileSync(path, BUNDLE);
48
+
49
+ const kept = await loadCRDs({ type: "file", path, kinds: ["GitRepository"] });
50
+ expect(kept.map((r) => r.gvk.kind)).toEqual(["GitRepository"]);
51
+ });
52
+
53
+ test("without a kinds filter, every CRD in the bundle is parsed", async () => {
54
+ const path = join(dir, "bundle.yaml");
55
+ writeFileSync(path, BUNDLE);
56
+
57
+ const all = await loadCRDs({ type: "file", path });
58
+ expect(all.map((r) => r.gvk.kind).sort()).toEqual(["ExternalArtifact", "GitRepository"]);
59
+ });
60
+ });
package/src/crd/loader.ts CHANGED
@@ -16,7 +16,12 @@ import { parseCRD } from "./parser";
16
16
  */
17
17
  export async function loadCRDs(source: CRDSource): Promise<K8sParseResult[]> {
18
18
  const content = await fetchCRDContent(source);
19
- return parseCRD(content);
19
+ const parsed = parseCRD(content);
20
+ if (source.kinds && source.kinds.length > 0) {
21
+ const allow = new Set(source.kinds);
22
+ return parsed.filter((r) => allow.has(r.gvk.kind));
23
+ }
24
+ return parsed;
20
25
  }
21
26
 
22
27
  /**
@@ -229,6 +229,26 @@ describe("parseCRDSpec", () => {
229
229
  expect(results[0].resource.typeName).toBe("K8s::Argo::Application");
230
230
  });
231
231
 
232
+ test("all Flux toolkit + operator groups collapse to the Flux namespace", () => {
233
+ const cases: Array<[string, string]> = [
234
+ ["source.toolkit.fluxcd.io", "GitRepository"],
235
+ ["kustomize.toolkit.fluxcd.io", "Kustomization"],
236
+ ["helm.toolkit.fluxcd.io", "HelmRelease"],
237
+ ["notification.toolkit.fluxcd.io", "Alert"],
238
+ ["image.toolkit.fluxcd.io", "ImagePolicy"],
239
+ ["fluxcd.controlplane.io", "FluxInstance"],
240
+ ];
241
+ for (const [group, kind] of cases) {
242
+ const results = parseCRDSpec({
243
+ group,
244
+ names: { kind, plural: `${kind.toLowerCase()}s` },
245
+ scope: "Namespaced" as const,
246
+ versions: [{ name: "v1", served: true, storage: true }],
247
+ });
248
+ expect(results[0].resource.typeName).toBe(`K8s::Flux::${kind}`);
249
+ }
250
+ });
251
+
232
252
  test("dedupes property-type names when a scalar and array sibling collide", () => {
233
253
  // Argo Application has both `source` (object) and `sources` (array of the
234
254
  // same shape); singularizing `sources` → `Source` would collide.
package/src/crd/parser.ts CHANGED
@@ -16,9 +16,22 @@ import { loadAll } from "js-yaml";
16
16
  * Group names whose first segment doesn't yield the conventional namespace.
17
17
  * "argoproj.io" → "Argo" (not "Argoproj") to match the Argo CD vocabulary
18
18
  * and the ArgoAppFor / ArgoAppSetForRegions composites.
19
+ *
20
+ * The Flux toolkit spreads across five `*.toolkit.fluxcd.io` groups plus the
21
+ * Flux Operator's `fluxcd.controlplane.io`; all six collapse to a single `Flux`
22
+ * namespace so a GitRepository and a Kustomization read as `K8s::Flux::*`
23
+ * siblings rather than scattering to Source / Kustomize / Helm / Notification /
24
+ * Image / Fluxcd. (`helm.toolkit.fluxcd.io` → `Helm` would also collide
25
+ * confusingly with the separate helm lexicon.)
19
26
  */
20
27
  const GROUP_NAMESPACE_OVERRIDES: Record<string, string> = {
21
28
  "argoproj.io": "Argo",
29
+ "source.toolkit.fluxcd.io": "Flux",
30
+ "kustomize.toolkit.fluxcd.io": "Flux",
31
+ "helm.toolkit.fluxcd.io": "Flux",
32
+ "notification.toolkit.fluxcd.io": "Flux",
33
+ "image.toolkit.fluxcd.io": "Flux",
34
+ "fluxcd.controlplane.io": "Flux",
22
35
  };
23
36
 
24
37
  /**
package/src/crd/types.ts CHANGED
@@ -19,6 +19,13 @@ export interface CRDSource {
19
19
  context?: string;
20
20
  /** Namespace to scope the CRD lookup for type="cluster" */
21
21
  namespace?: string;
22
+ /**
23
+ * Optional allowlist of CRD `kind` names to keep from this source. When a
24
+ * source is a multi-doc install bundle (as with Flux, whose release
25
+ * `install.yaml` also carries out-of-scope CRDs), this restricts codegen to
26
+ * the intended kinds. Omit to generate every CRD the source contains.
27
+ */
28
+ kinds?: string[];
22
29
  }
23
30
 
24
31
  /**