@intentius/chant-lexicon-k8s 0.0.12

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 (123) hide show
  1. package/dist/integrity.json +32 -0
  2. package/dist/manifest.json +8 -0
  3. package/dist/meta.json +1413 -0
  4. package/dist/rules/hardcoded-namespace.ts +56 -0
  5. package/dist/rules/k8s-helpers.ts +149 -0
  6. package/dist/rules/wk8005.ts +59 -0
  7. package/dist/rules/wk8006.ts +68 -0
  8. package/dist/rules/wk8041.ts +73 -0
  9. package/dist/rules/wk8042.ts +48 -0
  10. package/dist/rules/wk8101.ts +65 -0
  11. package/dist/rules/wk8102.ts +42 -0
  12. package/dist/rules/wk8103.ts +45 -0
  13. package/dist/rules/wk8104.ts +69 -0
  14. package/dist/rules/wk8105.ts +45 -0
  15. package/dist/rules/wk8201.ts +55 -0
  16. package/dist/rules/wk8202.ts +46 -0
  17. package/dist/rules/wk8203.ts +46 -0
  18. package/dist/rules/wk8204.ts +54 -0
  19. package/dist/rules/wk8205.ts +56 -0
  20. package/dist/rules/wk8207.ts +45 -0
  21. package/dist/rules/wk8208.ts +45 -0
  22. package/dist/rules/wk8209.ts +45 -0
  23. package/dist/rules/wk8301.ts +51 -0
  24. package/dist/rules/wk8302.ts +46 -0
  25. package/dist/rules/wk8303.ts +96 -0
  26. package/dist/skills/chant-k8s.md +433 -0
  27. package/dist/types/index.d.ts +2934 -0
  28. package/package.json +30 -0
  29. package/src/actions/actions.test.ts +83 -0
  30. package/src/actions/apps.ts +23 -0
  31. package/src/actions/batch.ts +9 -0
  32. package/src/actions/core.ts +62 -0
  33. package/src/actions/index.ts +50 -0
  34. package/src/actions/networking.ts +15 -0
  35. package/src/actions/rbac.ts +13 -0
  36. package/src/codegen/docs-cli.ts +3 -0
  37. package/src/codegen/docs.ts +1147 -0
  38. package/src/codegen/generate-cli.ts +41 -0
  39. package/src/codegen/generate-lexicon.ts +69 -0
  40. package/src/codegen/generate-typescript.ts +97 -0
  41. package/src/codegen/generate.ts +144 -0
  42. package/src/codegen/naming.test.ts +63 -0
  43. package/src/codegen/naming.ts +187 -0
  44. package/src/codegen/package.ts +56 -0
  45. package/src/codegen/patches.ts +108 -0
  46. package/src/codegen/snapshot.test.ts +95 -0
  47. package/src/codegen/typecheck.test.ts +24 -0
  48. package/src/codegen/typecheck.ts +4 -0
  49. package/src/codegen/versions.ts +43 -0
  50. package/src/composites/autoscaled-service.ts +236 -0
  51. package/src/composites/composites.test.ts +1109 -0
  52. package/src/composites/cron-workload.ts +167 -0
  53. package/src/composites/index.ts +14 -0
  54. package/src/composites/namespace-env.ts +163 -0
  55. package/src/composites/node-agent.ts +224 -0
  56. package/src/composites/stateful-app.ts +134 -0
  57. package/src/composites/web-app.ts +180 -0
  58. package/src/composites/worker-pool.ts +230 -0
  59. package/src/coverage.test.ts +27 -0
  60. package/src/coverage.ts +35 -0
  61. package/src/crd/loader.ts +112 -0
  62. package/src/crd/parser.test.ts +217 -0
  63. package/src/crd/parser.ts +279 -0
  64. package/src/crd/types.ts +54 -0
  65. package/src/default-labels.test.ts +111 -0
  66. package/src/default-labels.ts +122 -0
  67. package/src/generated/index.d.ts +2934 -0
  68. package/src/generated/index.ts +203 -0
  69. package/src/generated/lexicon-k8s.json +1413 -0
  70. package/src/generated/runtime.ts +4 -0
  71. package/src/import/generator.test.ts +121 -0
  72. package/src/import/generator.ts +285 -0
  73. package/src/import/parser.test.ts +156 -0
  74. package/src/import/parser.ts +204 -0
  75. package/src/import/roundtrip.test.ts +86 -0
  76. package/src/index.ts +38 -0
  77. package/src/lint/post-synth/k8s-helpers.test.ts +219 -0
  78. package/src/lint/post-synth/k8s-helpers.ts +149 -0
  79. package/src/lint/post-synth/post-synth.test.ts +969 -0
  80. package/src/lint/post-synth/wk8005.ts +59 -0
  81. package/src/lint/post-synth/wk8006.ts +68 -0
  82. package/src/lint/post-synth/wk8041.ts +73 -0
  83. package/src/lint/post-synth/wk8042.ts +48 -0
  84. package/src/lint/post-synth/wk8101.ts +65 -0
  85. package/src/lint/post-synth/wk8102.ts +42 -0
  86. package/src/lint/post-synth/wk8103.ts +45 -0
  87. package/src/lint/post-synth/wk8104.ts +69 -0
  88. package/src/lint/post-synth/wk8105.ts +45 -0
  89. package/src/lint/post-synth/wk8201.ts +55 -0
  90. package/src/lint/post-synth/wk8202.ts +46 -0
  91. package/src/lint/post-synth/wk8203.ts +46 -0
  92. package/src/lint/post-synth/wk8204.ts +54 -0
  93. package/src/lint/post-synth/wk8205.ts +56 -0
  94. package/src/lint/post-synth/wk8207.ts +45 -0
  95. package/src/lint/post-synth/wk8208.ts +45 -0
  96. package/src/lint/post-synth/wk8209.ts +45 -0
  97. package/src/lint/post-synth/wk8301.ts +51 -0
  98. package/src/lint/post-synth/wk8302.ts +46 -0
  99. package/src/lint/post-synth/wk8303.ts +96 -0
  100. package/src/lint/rules/hardcoded-namespace.ts +56 -0
  101. package/src/lint/rules/rules.test.ts +69 -0
  102. package/src/lsp/completions.test.ts +64 -0
  103. package/src/lsp/completions.ts +20 -0
  104. package/src/lsp/hover.test.ts +69 -0
  105. package/src/lsp/hover.ts +68 -0
  106. package/src/package-cli.ts +28 -0
  107. package/src/plugin.test.ts +209 -0
  108. package/src/plugin.ts +915 -0
  109. package/src/serializer.test.ts +275 -0
  110. package/src/serializer.ts +278 -0
  111. package/src/spec/fetch.test.ts +24 -0
  112. package/src/spec/fetch.ts +68 -0
  113. package/src/spec/parse.test.ts +102 -0
  114. package/src/spec/parse.ts +477 -0
  115. package/src/testdata/manifests/configmap.yaml +7 -0
  116. package/src/testdata/manifests/deployment.yaml +22 -0
  117. package/src/testdata/manifests/full-app.yaml +61 -0
  118. package/src/testdata/manifests/secret.yaml +7 -0
  119. package/src/testdata/manifests/service.yaml +15 -0
  120. package/src/validate-cli.ts +21 -0
  121. package/src/validate.test.ts +29 -0
  122. package/src/validate.ts +46 -0
  123. package/src/variables.ts +36 -0
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * CLI entry point for Kubernetes lexicon validation.
4
+ */
5
+
6
+ import { validate } from "./validate";
7
+ import { printValidationResult } from "@intentius/chant/codegen/validate";
8
+
9
+ async function main() {
10
+ const result = await validate();
11
+ printValidationResult(result);
12
+
13
+ if (!result.success) {
14
+ process.exit(1);
15
+ }
16
+ }
17
+
18
+ main().catch((err) => {
19
+ console.error("Validation failed:", err);
20
+ process.exit(1);
21
+ });
@@ -0,0 +1,29 @@
1
+ import { describe, test, expect } from "bun:test";
2
+ import { validate } from "./validate";
3
+
4
+ describe("validate", () => {
5
+ test("validate function exists and returns ValidateResult", async () => {
6
+ // validate runs against generated files — may fail if not generated
7
+ try {
8
+ const result = await validate();
9
+ expect(result).toBeDefined();
10
+ expect(typeof result.success).toBe("boolean");
11
+ expect(Array.isArray(result.checks)).toBe(true);
12
+ } catch {
13
+ // Expected if generated files don't exist
14
+ }
15
+ });
16
+
17
+ test("result has checks array", async () => {
18
+ try {
19
+ const result = await validate();
20
+ expect(Array.isArray(result.checks)).toBe(true);
21
+ for (const check of result.checks) {
22
+ expect(check).toHaveProperty("name");
23
+ expect(check).toHaveProperty("passed");
24
+ }
25
+ } catch {
26
+ // Expected if generated files don't exist
27
+ }
28
+ });
29
+ });
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Validate generated lexicon-k8s artifacts.
3
+ *
4
+ * Thin wrapper around the core validation framework
5
+ * with Kubernetes-specific configuration.
6
+ */
7
+
8
+ import { dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { validateLexiconArtifacts, type ValidateResult } from "@intentius/chant/codegen/validate";
11
+
12
+ export type { ValidateCheck, ValidateResult } from "@intentius/chant/codegen/validate";
13
+
14
+ const REQUIRED_NAMES = [
15
+ // Core resources
16
+ "Pod", "Service", "ConfigMap", "Secret", "Namespace",
17
+ "ServiceAccount", "PersistentVolume", "PersistentVolumeClaim",
18
+ // Apps
19
+ "Deployment", "StatefulSet", "DaemonSet", "ReplicaSet",
20
+ // Batch
21
+ "Job", "CronJob",
22
+ // Networking
23
+ "Ingress", "NetworkPolicy",
24
+ // RBAC
25
+ "Role", "ClusterRole", "RoleBinding", "ClusterRoleBinding",
26
+ // Autoscaling
27
+ "HorizontalPodAutoscaler",
28
+ // Policy
29
+ "PodDisruptionBudget",
30
+ // Property types
31
+ "Container", "Volume", "VolumeMount", "EnvVar", "ServicePort",
32
+ "Probe", "ResourceRequirements", "SecurityContext",
33
+ ];
34
+
35
+ /**
36
+ * Validate the generated lexicon-k8s artifacts.
37
+ */
38
+ export async function validate(opts?: { basePath?: string }): Promise<ValidateResult> {
39
+ const basePath = opts?.basePath ?? dirname(dirname(fileURLToPath(import.meta.url)));
40
+
41
+ return validateLexiconArtifacts({
42
+ lexiconJsonFilename: "lexicon-k8s.json",
43
+ requiredNames: REQUIRED_NAMES,
44
+ basePath,
45
+ });
46
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Kubernetes pseudo-parameters / well-known variables.
3
+ *
4
+ * Unlike AWS which has built-in pseudo-parameters (AWS::Region, etc.),
5
+ * Kubernetes doesn't have equivalent built-in variables. This module
6
+ * provides common label key constants for use in resource definitions.
7
+ */
8
+
9
+ /**
10
+ * Well-known Kubernetes label keys from the standard label taxonomy.
11
+ * These are string constants, not runtime-resolved pseudo-parameters.
12
+ */
13
+ export const K8sLabels = {
14
+ /** app.kubernetes.io/name */
15
+ AppName: "app.kubernetes.io/name",
16
+ /** app.kubernetes.io/instance */
17
+ AppInstance: "app.kubernetes.io/instance",
18
+ /** app.kubernetes.io/version */
19
+ AppVersion: "app.kubernetes.io/version",
20
+ /** app.kubernetes.io/component */
21
+ AppComponent: "app.kubernetes.io/component",
22
+ /** app.kubernetes.io/part-of */
23
+ AppPartOf: "app.kubernetes.io/part-of",
24
+ /** app.kubernetes.io/managed-by */
25
+ AppManagedBy: "app.kubernetes.io/managed-by",
26
+ } as const;
27
+
28
+ /**
29
+ * Well-known Kubernetes annotation keys.
30
+ */
31
+ export const K8sAnnotations = {
32
+ /** kubernetes.io/change-cause */
33
+ ChangeCause: "kubernetes.io/change-cause",
34
+ /** kubernetes.io/description */
35
+ Description: "kubernetes.io/description",
36
+ } as const;