@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.
- package/dist/integrity.json +32 -0
- package/dist/manifest.json +8 -0
- package/dist/meta.json +1413 -0
- package/dist/rules/hardcoded-namespace.ts +56 -0
- package/dist/rules/k8s-helpers.ts +149 -0
- package/dist/rules/wk8005.ts +59 -0
- package/dist/rules/wk8006.ts +68 -0
- package/dist/rules/wk8041.ts +73 -0
- package/dist/rules/wk8042.ts +48 -0
- package/dist/rules/wk8101.ts +65 -0
- package/dist/rules/wk8102.ts +42 -0
- package/dist/rules/wk8103.ts +45 -0
- package/dist/rules/wk8104.ts +69 -0
- package/dist/rules/wk8105.ts +45 -0
- package/dist/rules/wk8201.ts +55 -0
- package/dist/rules/wk8202.ts +46 -0
- package/dist/rules/wk8203.ts +46 -0
- package/dist/rules/wk8204.ts +54 -0
- package/dist/rules/wk8205.ts +56 -0
- package/dist/rules/wk8207.ts +45 -0
- package/dist/rules/wk8208.ts +45 -0
- package/dist/rules/wk8209.ts +45 -0
- package/dist/rules/wk8301.ts +51 -0
- package/dist/rules/wk8302.ts +46 -0
- package/dist/rules/wk8303.ts +96 -0
- package/dist/skills/chant-k8s.md +433 -0
- package/dist/types/index.d.ts +2934 -0
- package/package.json +30 -0
- package/src/actions/actions.test.ts +83 -0
- package/src/actions/apps.ts +23 -0
- package/src/actions/batch.ts +9 -0
- package/src/actions/core.ts +62 -0
- package/src/actions/index.ts +50 -0
- package/src/actions/networking.ts +15 -0
- package/src/actions/rbac.ts +13 -0
- package/src/codegen/docs-cli.ts +3 -0
- package/src/codegen/docs.ts +1147 -0
- package/src/codegen/generate-cli.ts +41 -0
- package/src/codegen/generate-lexicon.ts +69 -0
- package/src/codegen/generate-typescript.ts +97 -0
- package/src/codegen/generate.ts +144 -0
- package/src/codegen/naming.test.ts +63 -0
- package/src/codegen/naming.ts +187 -0
- package/src/codegen/package.ts +56 -0
- package/src/codegen/patches.ts +108 -0
- package/src/codegen/snapshot.test.ts +95 -0
- package/src/codegen/typecheck.test.ts +24 -0
- package/src/codegen/typecheck.ts +4 -0
- package/src/codegen/versions.ts +43 -0
- package/src/composites/autoscaled-service.ts +236 -0
- package/src/composites/composites.test.ts +1109 -0
- package/src/composites/cron-workload.ts +167 -0
- package/src/composites/index.ts +14 -0
- package/src/composites/namespace-env.ts +163 -0
- package/src/composites/node-agent.ts +224 -0
- package/src/composites/stateful-app.ts +134 -0
- package/src/composites/web-app.ts +180 -0
- package/src/composites/worker-pool.ts +230 -0
- package/src/coverage.test.ts +27 -0
- package/src/coverage.ts +35 -0
- package/src/crd/loader.ts +112 -0
- package/src/crd/parser.test.ts +217 -0
- package/src/crd/parser.ts +279 -0
- package/src/crd/types.ts +54 -0
- package/src/default-labels.test.ts +111 -0
- package/src/default-labels.ts +122 -0
- package/src/generated/index.d.ts +2934 -0
- package/src/generated/index.ts +203 -0
- package/src/generated/lexicon-k8s.json +1413 -0
- package/src/generated/runtime.ts +4 -0
- package/src/import/generator.test.ts +121 -0
- package/src/import/generator.ts +285 -0
- package/src/import/parser.test.ts +156 -0
- package/src/import/parser.ts +204 -0
- package/src/import/roundtrip.test.ts +86 -0
- package/src/index.ts +38 -0
- package/src/lint/post-synth/k8s-helpers.test.ts +219 -0
- package/src/lint/post-synth/k8s-helpers.ts +149 -0
- package/src/lint/post-synth/post-synth.test.ts +969 -0
- package/src/lint/post-synth/wk8005.ts +59 -0
- package/src/lint/post-synth/wk8006.ts +68 -0
- package/src/lint/post-synth/wk8041.ts +73 -0
- package/src/lint/post-synth/wk8042.ts +48 -0
- package/src/lint/post-synth/wk8101.ts +65 -0
- package/src/lint/post-synth/wk8102.ts +42 -0
- package/src/lint/post-synth/wk8103.ts +45 -0
- package/src/lint/post-synth/wk8104.ts +69 -0
- package/src/lint/post-synth/wk8105.ts +45 -0
- package/src/lint/post-synth/wk8201.ts +55 -0
- package/src/lint/post-synth/wk8202.ts +46 -0
- package/src/lint/post-synth/wk8203.ts +46 -0
- package/src/lint/post-synth/wk8204.ts +54 -0
- package/src/lint/post-synth/wk8205.ts +56 -0
- package/src/lint/post-synth/wk8207.ts +45 -0
- package/src/lint/post-synth/wk8208.ts +45 -0
- package/src/lint/post-synth/wk8209.ts +45 -0
- package/src/lint/post-synth/wk8301.ts +51 -0
- package/src/lint/post-synth/wk8302.ts +46 -0
- package/src/lint/post-synth/wk8303.ts +96 -0
- package/src/lint/rules/hardcoded-namespace.ts +56 -0
- package/src/lint/rules/rules.test.ts +69 -0
- package/src/lsp/completions.test.ts +64 -0
- package/src/lsp/completions.ts +20 -0
- package/src/lsp/hover.test.ts +69 -0
- package/src/lsp/hover.ts +68 -0
- package/src/package-cli.ts +28 -0
- package/src/plugin.test.ts +209 -0
- package/src/plugin.ts +915 -0
- package/src/serializer.test.ts +275 -0
- package/src/serializer.ts +278 -0
- package/src/spec/fetch.test.ts +24 -0
- package/src/spec/fetch.ts +68 -0
- package/src/spec/parse.test.ts +102 -0
- package/src/spec/parse.ts +477 -0
- package/src/testdata/manifests/configmap.yaml +7 -0
- package/src/testdata/manifests/deployment.yaml +22 -0
- package/src/testdata/manifests/full-app.yaml +61 -0
- package/src/testdata/manifests/secret.yaml +7 -0
- package/src/testdata/manifests/service.yaml +15 -0
- package/src/validate-cli.ts +21 -0
- package/src/validate.test.ts +29 -0
- package/src/validate.ts +46 -0
- package/src/variables.ts +36 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Labels & Annotations — declares project-wide labels/annotations
|
|
3
|
+
* for all Kubernetes resources.
|
|
4
|
+
*
|
|
5
|
+
* When a project exports a `defaultLabels(...)` or `defaultAnnotations(...)`
|
|
6
|
+
* declaration, the serializer automatically injects them into every resource's
|
|
7
|
+
* metadata at synthesis time. Explicit labels/annotations on individual
|
|
8
|
+
* resources take precedence.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { DECLARABLE_MARKER, type Declarable } from "@intentius/chant/declarable";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Marker symbol for default labels identification.
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_LABELS_MARKER = Symbol.for("chant.k8s.defaultLabels");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Marker symbol for default annotations identification.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_ANNOTATIONS_MARKER = Symbol.for("chant.k8s.defaultAnnotations");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A default labels declaration — wraps a label map into a Declarable
|
|
25
|
+
* that the serializer uses to inject labels into all resources.
|
|
26
|
+
*/
|
|
27
|
+
export interface DefaultLabels extends Declarable {
|
|
28
|
+
readonly [DEFAULT_LABELS_MARKER]: true;
|
|
29
|
+
readonly [DECLARABLE_MARKER]: true;
|
|
30
|
+
readonly lexicon: "k8s";
|
|
31
|
+
readonly entityType: "chant:k8s:defaultLabels";
|
|
32
|
+
readonly labels: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A default annotations declaration — wraps an annotation map into a Declarable
|
|
37
|
+
* that the serializer uses to inject annotations into all resources.
|
|
38
|
+
*/
|
|
39
|
+
export interface DefaultAnnotations extends Declarable {
|
|
40
|
+
readonly [DEFAULT_ANNOTATIONS_MARKER]: true;
|
|
41
|
+
readonly [DECLARABLE_MARKER]: true;
|
|
42
|
+
readonly lexicon: "k8s";
|
|
43
|
+
readonly entityType: "chant:k8s:defaultAnnotations";
|
|
44
|
+
readonly annotations: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Type guard for DefaultLabels.
|
|
49
|
+
*/
|
|
50
|
+
export function isDefaultLabels(value: unknown): value is DefaultLabels {
|
|
51
|
+
return (
|
|
52
|
+
typeof value === "object" &&
|
|
53
|
+
value !== null &&
|
|
54
|
+
DEFAULT_LABELS_MARKER in value &&
|
|
55
|
+
(value as Record<symbol, unknown>)[DEFAULT_LABELS_MARKER] === true
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Type guard for DefaultAnnotations.
|
|
61
|
+
*/
|
|
62
|
+
export function isDefaultAnnotations(value: unknown): value is DefaultAnnotations {
|
|
63
|
+
return (
|
|
64
|
+
typeof value === "object" &&
|
|
65
|
+
value !== null &&
|
|
66
|
+
DEFAULT_ANNOTATIONS_MARKER in value &&
|
|
67
|
+
(value as Record<symbol, unknown>)[DEFAULT_ANNOTATIONS_MARKER] === true
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Declare project-wide default labels for all Kubernetes resources.
|
|
73
|
+
*
|
|
74
|
+
* Labels are injected at synthesis time into every resource's
|
|
75
|
+
* `metadata.labels`. If a resource has an explicit label with the
|
|
76
|
+
* same key, the explicit value wins.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { defaultLabels } from "@intentius/chant-lexicon-k8s";
|
|
81
|
+
*
|
|
82
|
+
* export const labels = defaultLabels({
|
|
83
|
+
* "app.kubernetes.io/managed-by": "chant",
|
|
84
|
+
* "app.kubernetes.io/part-of": "my-app",
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function defaultLabels(labels: Record<string, unknown>): DefaultLabels {
|
|
89
|
+
return {
|
|
90
|
+
[DEFAULT_LABELS_MARKER]: true,
|
|
91
|
+
[DECLARABLE_MARKER]: true,
|
|
92
|
+
lexicon: "k8s",
|
|
93
|
+
entityType: "chant:k8s:defaultLabels",
|
|
94
|
+
labels,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Declare project-wide default annotations for all Kubernetes resources.
|
|
100
|
+
*
|
|
101
|
+
* Annotations are injected at synthesis time into every resource's
|
|
102
|
+
* `metadata.annotations`. If a resource has an explicit annotation with
|
|
103
|
+
* the same key, the explicit value wins.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { defaultAnnotations } from "@intentius/chant-lexicon-k8s";
|
|
108
|
+
*
|
|
109
|
+
* export const annotations = defaultAnnotations({
|
|
110
|
+
* "app.kubernetes.io/managed-by": "chant",
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export function defaultAnnotations(annotations: Record<string, unknown>): DefaultAnnotations {
|
|
115
|
+
return {
|
|
116
|
+
[DEFAULT_ANNOTATIONS_MARKER]: true,
|
|
117
|
+
[DECLARABLE_MARKER]: true,
|
|
118
|
+
lexicon: "k8s",
|
|
119
|
+
entityType: "chant:k8s:defaultAnnotations",
|
|
120
|
+
annotations,
|
|
121
|
+
};
|
|
122
|
+
}
|