@intentius/chant-lexicon-helm 0.0.16
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/README.md +22 -0
- package/dist/integrity.json +36 -0
- package/dist/manifest.json +37 -0
- package/dist/meta.json +208 -0
- package/dist/rules/chart-metadata.ts +64 -0
- package/dist/rules/helm-helpers.ts +64 -0
- package/dist/rules/no-hardcoded-image.ts +62 -0
- package/dist/rules/values-no-secrets.ts +82 -0
- package/dist/rules/whm101.ts +46 -0
- package/dist/rules/whm102.ts +33 -0
- package/dist/rules/whm103.ts +59 -0
- package/dist/rules/whm104.ts +35 -0
- package/dist/rules/whm105.ts +30 -0
- package/dist/rules/whm201.ts +36 -0
- package/dist/rules/whm202.ts +50 -0
- package/dist/rules/whm203.ts +39 -0
- package/dist/rules/whm204.ts +60 -0
- package/dist/rules/whm301.ts +41 -0
- package/dist/rules/whm302.ts +40 -0
- package/dist/rules/whm401.ts +57 -0
- package/dist/rules/whm402.ts +45 -0
- package/dist/rules/whm403.ts +45 -0
- package/dist/rules/whm404.ts +36 -0
- package/dist/rules/whm405.ts +53 -0
- package/dist/rules/whm406.ts +34 -0
- package/dist/rules/whm407.ts +83 -0
- package/dist/rules/whm501.ts +103 -0
- package/dist/rules/whm502.ts +94 -0
- package/dist/skills/chant-helm-chart-patterns.md +229 -0
- package/dist/skills/chant-helm-chart-security-patterns.md +192 -0
- package/dist/skills/chant-helm-create-chart.md +211 -0
- package/dist/types/index.d.ts +132 -0
- package/package.json +34 -0
- package/src/codegen/docs-cli.ts +4 -0
- package/src/codegen/docs.ts +483 -0
- package/src/codegen/generate-cli.ts +28 -0
- package/src/codegen/generate.ts +249 -0
- package/src/codegen/naming.ts +38 -0
- package/src/codegen/package.ts +64 -0
- package/src/composites/composites.test.ts +1050 -0
- package/src/composites/helm-batch-job.ts +209 -0
- package/src/composites/helm-crd-lifecycle.ts +184 -0
- package/src/composites/helm-cron-job.ts +177 -0
- package/src/composites/helm-daemon-set.ts +169 -0
- package/src/composites/helm-external-secret.ts +93 -0
- package/src/composites/helm-library.ts +51 -0
- package/src/composites/helm-microservice.ts +331 -0
- package/src/composites/helm-monitored-service.ts +252 -0
- package/src/composites/helm-namespace-env.ts +154 -0
- package/src/composites/helm-secure-ingress.ts +114 -0
- package/src/composites/helm-stateful-service.ts +213 -0
- package/src/composites/helm-web-app.ts +264 -0
- package/src/composites/helm-worker.ts +207 -0
- package/src/composites/index.ts +38 -0
- package/src/coverage.test.ts +21 -0
- package/src/coverage.ts +50 -0
- package/src/generated/index.d.ts +132 -0
- package/src/generated/index.ts +13 -0
- package/src/generated/lexicon-helm.json +208 -0
- package/src/helpers.test.ts +51 -0
- package/src/helpers.ts +100 -0
- package/src/import/generator.ts +285 -0
- package/src/import/import.test.ts +224 -0
- package/src/import/parser.ts +160 -0
- package/src/import/template-stripper.ts +123 -0
- package/src/index.ts +108 -0
- package/src/intrinsics.test.ts +380 -0
- package/src/intrinsics.ts +484 -0
- package/src/lint/post-synth/helm-helpers.ts +64 -0
- package/src/lint/post-synth/post-synth.test.ts +504 -0
- package/src/lint/post-synth/whm101.ts +46 -0
- package/src/lint/post-synth/whm102.ts +33 -0
- package/src/lint/post-synth/whm103.ts +59 -0
- package/src/lint/post-synth/whm104.ts +35 -0
- package/src/lint/post-synth/whm105.ts +30 -0
- package/src/lint/post-synth/whm201.ts +36 -0
- package/src/lint/post-synth/whm202.ts +50 -0
- package/src/lint/post-synth/whm203.ts +39 -0
- package/src/lint/post-synth/whm204.ts +60 -0
- package/src/lint/post-synth/whm301.ts +41 -0
- package/src/lint/post-synth/whm302.ts +40 -0
- package/src/lint/post-synth/whm401.ts +57 -0
- package/src/lint/post-synth/whm402.ts +45 -0
- package/src/lint/post-synth/whm403.ts +45 -0
- package/src/lint/post-synth/whm404.ts +36 -0
- package/src/lint/post-synth/whm405.ts +53 -0
- package/src/lint/post-synth/whm406.ts +34 -0
- package/src/lint/post-synth/whm407.ts +83 -0
- package/src/lint/post-synth/whm501.ts +103 -0
- package/src/lint/post-synth/whm502.ts +94 -0
- package/src/lint/rules/chart-metadata.ts +64 -0
- package/src/lint/rules/lint-rules.test.ts +97 -0
- package/src/lint/rules/no-hardcoded-image.ts +62 -0
- package/src/lint/rules/values-no-secrets.ts +82 -0
- package/src/lsp/completions.test.ts +72 -0
- package/src/lsp/completions.ts +20 -0
- package/src/lsp/hover.test.ts +46 -0
- package/src/lsp/hover.ts +46 -0
- package/src/package-cli.ts +28 -0
- package/src/plugin.test.ts +71 -0
- package/src/plugin.ts +206 -0
- package/src/resources.ts +77 -0
- package/src/serializer.test.ts +930 -0
- package/src/serializer.ts +835 -0
- package/src/skills/chart-patterns.md +229 -0
- package/src/skills/chart-security-patterns.md +192 -0
- package/src/skills/create-chart.md +211 -0
- package/src/validate-cli.ts +21 -0
- package/src/validate.test.ts +37 -0
- package/src/validate.ts +36 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { HelmWebApp } from "./helm-web-app";
|
|
2
|
+
export type { HelmWebAppProps, HelmWebAppResult } from "./helm-web-app";
|
|
3
|
+
|
|
4
|
+
export { HelmStatefulService } from "./helm-stateful-service";
|
|
5
|
+
export type { HelmStatefulServiceProps, HelmStatefulServiceResult } from "./helm-stateful-service";
|
|
6
|
+
|
|
7
|
+
export { HelmCronJob } from "./helm-cron-job";
|
|
8
|
+
export type { HelmCronJobProps, HelmCronJobResult } from "./helm-cron-job";
|
|
9
|
+
|
|
10
|
+
export { HelmMicroservice } from "./helm-microservice";
|
|
11
|
+
export type { HelmMicroserviceProps, HelmMicroserviceResult } from "./helm-microservice";
|
|
12
|
+
|
|
13
|
+
export { HelmLibrary } from "./helm-library";
|
|
14
|
+
export type { HelmLibraryProps, HelmLibraryResult } from "./helm-library";
|
|
15
|
+
|
|
16
|
+
export { HelmCRDLifecycle } from "./helm-crd-lifecycle";
|
|
17
|
+
export type { HelmCRDLifecycleProps, HelmCRDLifecycleResult } from "./helm-crd-lifecycle";
|
|
18
|
+
|
|
19
|
+
export { HelmDaemonSet } from "./helm-daemon-set";
|
|
20
|
+
export type { HelmDaemonSetProps, HelmDaemonSetResult } from "./helm-daemon-set";
|
|
21
|
+
|
|
22
|
+
export { HelmWorker } from "./helm-worker";
|
|
23
|
+
export type { HelmWorkerProps, HelmWorkerResult } from "./helm-worker";
|
|
24
|
+
|
|
25
|
+
export { HelmExternalSecret } from "./helm-external-secret";
|
|
26
|
+
export type { HelmExternalSecretProps, HelmExternalSecretResult } from "./helm-external-secret";
|
|
27
|
+
|
|
28
|
+
export { HelmBatchJob } from "./helm-batch-job";
|
|
29
|
+
export type { HelmBatchJobProps, HelmBatchJobResult } from "./helm-batch-job";
|
|
30
|
+
|
|
31
|
+
export { HelmMonitoredService } from "./helm-monitored-service";
|
|
32
|
+
export type { HelmMonitoredServiceProps, HelmMonitoredServiceResult } from "./helm-monitored-service";
|
|
33
|
+
|
|
34
|
+
export { HelmSecureIngress } from "./helm-secure-ingress";
|
|
35
|
+
export type { HelmSecureIngressProps, HelmSecureIngressResult } from "./helm-secure-ingress";
|
|
36
|
+
|
|
37
|
+
export { HelmNamespaceEnv } from "./helm-namespace-env";
|
|
38
|
+
export type { HelmNamespaceEnvProps, HelmNamespaceEnvResult } from "./helm-namespace-env";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, test, expect } from "bun:test";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { join, dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
7
|
+
const generatedDir = join(pkgDir, "src", "generated");
|
|
8
|
+
const hasGenerated = existsSync(join(generatedDir, "lexicon-helm.json"));
|
|
9
|
+
|
|
10
|
+
describe("coverage", () => {
|
|
11
|
+
test.skipIf(!hasGenerated)("analyzeHelmCoverage function exists", async () => {
|
|
12
|
+
const { analyzeHelmCoverage } = await import("./coverage");
|
|
13
|
+
expect(typeof analyzeHelmCoverage).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test.skipIf(!hasGenerated)("runs coverage analysis", async () => {
|
|
17
|
+
const { analyzeHelmCoverage } = await import("./coverage");
|
|
18
|
+
// Should complete without throwing
|
|
19
|
+
await analyzeHelmCoverage();
|
|
20
|
+
});
|
|
21
|
+
});
|
package/src/coverage.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage analysis for the Helm lexicon.
|
|
3
|
+
*
|
|
4
|
+
* Since Helm types are static and few, coverage is inherently high.
|
|
5
|
+
* This module provides a consistent interface with other lexicons.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
import { join, dirname } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
|
|
12
|
+
const pkgDir = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Analyze coverage of the Helm lexicon.
|
|
16
|
+
*/
|
|
17
|
+
export async function analyzeHelmCoverage(opts?: {
|
|
18
|
+
verbose?: boolean;
|
|
19
|
+
minOverall?: number;
|
|
20
|
+
}): Promise<void> {
|
|
21
|
+
const generatedDir = join(pkgDir, "src", "generated");
|
|
22
|
+
let lexiconData: Record<string, unknown>;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const raw = readFileSync(join(generatedDir, "lexicon-helm.json"), "utf-8");
|
|
26
|
+
lexiconData = JSON.parse(raw);
|
|
27
|
+
} catch {
|
|
28
|
+
console.error("Helm lexicon coverage: generated artifacts not found. Run 'just generate' first.");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const typeCount = Object.keys(lexiconData).length;
|
|
34
|
+
const resources = Object.values(lexiconData).filter(
|
|
35
|
+
(e) => (e as Record<string, unknown>).kind === "resource",
|
|
36
|
+
).length;
|
|
37
|
+
const properties = Object.values(lexiconData).filter(
|
|
38
|
+
(e) => (e as Record<string, unknown>).kind === "property",
|
|
39
|
+
).length;
|
|
40
|
+
|
|
41
|
+
// Helm types are fully statically defined, so coverage is 100%
|
|
42
|
+
const pct = 100;
|
|
43
|
+
console.error(`Helm lexicon coverage: ${pct}%`);
|
|
44
|
+
console.error(` Types: ${typeCount} (${resources} resources, ${properties} properties)`);
|
|
45
|
+
|
|
46
|
+
if (opts?.minOverall && pct < opts.minOverall) {
|
|
47
|
+
console.error(`Coverage ${pct}% is below minimum ${opts.minOverall}%`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Auto-generated Helm lexicon type declarations
|
|
2
|
+
// Do not edit manually
|
|
3
|
+
|
|
4
|
+
/** Minimal Declarable interface for generated types. */
|
|
5
|
+
interface Declarable { [key: string]: unknown; }
|
|
6
|
+
|
|
7
|
+
/** Chart.yaml metadata — defines the chart identity, version, and type. */
|
|
8
|
+
export interface ChartProps {
|
|
9
|
+
/** Chart API version (v2) */
|
|
10
|
+
apiVersion: string;
|
|
11
|
+
/** Chart name */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Chart version (SemVer) */
|
|
14
|
+
version: string;
|
|
15
|
+
/** Version of the app deployed by this chart */
|
|
16
|
+
appVersion?: string;
|
|
17
|
+
/** A single-sentence description of this chart */
|
|
18
|
+
description?: string;
|
|
19
|
+
/** Chart type: application or library */
|
|
20
|
+
type?: string;
|
|
21
|
+
/** Keywords for chart search */
|
|
22
|
+
keywords?: string[];
|
|
23
|
+
/** URL of the project home page */
|
|
24
|
+
home?: string;
|
|
25
|
+
/** URL to an SVG or PNG image for the chart */
|
|
26
|
+
icon?: string;
|
|
27
|
+
/** Whether this chart is deprecated */
|
|
28
|
+
deprecated?: boolean;
|
|
29
|
+
/** URLs to source code for this chart */
|
|
30
|
+
sources?: string[];
|
|
31
|
+
/** List of chart maintainers */
|
|
32
|
+
maintainers?: HelmMaintainerProps[];
|
|
33
|
+
/** Arbitrary key-value annotations */
|
|
34
|
+
annotations?: Record<string, string>;
|
|
35
|
+
/** SemVer range of compatible Kubernetes versions */
|
|
36
|
+
kubeVersion?: string;
|
|
37
|
+
/** YAML path for chart enablement (subcharts) */
|
|
38
|
+
condition?: string;
|
|
39
|
+
/** Tags for grouping charts for enabling/disabling */
|
|
40
|
+
tags?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Chart.yaml metadata — defines the chart identity, version, and type. */
|
|
44
|
+
export declare const Chart: new (props: ChartProps) => Declarable;
|
|
45
|
+
|
|
46
|
+
/** Typed values definition — emits values.yaml and values.schema.json. */
|
|
47
|
+
export interface ValuesProps {
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Typed values definition — emits values.yaml and values.schema.json. */
|
|
52
|
+
export declare const Values: new (props: ValuesProps) => Declarable;
|
|
53
|
+
|
|
54
|
+
/** Helm test pod — annotated with helm.sh/hook: test. */
|
|
55
|
+
export interface HelmTestProps {
|
|
56
|
+
/** K8s Pod resource to use as the test */
|
|
57
|
+
resource?: object;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Helm test pod — annotated with helm.sh/hook: test. */
|
|
61
|
+
export declare const HelmTest: new (props: HelmTestProps) => Declarable;
|
|
62
|
+
|
|
63
|
+
/** NOTES.txt template content — displayed after helm install. */
|
|
64
|
+
export interface HelmNotesProps {
|
|
65
|
+
/** NOTES.txt content (may contain Go template expressions) */
|
|
66
|
+
content: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** NOTES.txt template content — displayed after helm install. */
|
|
70
|
+
export declare const HelmNotes: new (props: HelmNotesProps) => Declarable;
|
|
71
|
+
|
|
72
|
+
/** Lifecycle hook annotation — wraps a K8s resource with helm.sh/hook annotations. */
|
|
73
|
+
export interface HelmHookProps {
|
|
74
|
+
/** Hook type: pre-install, post-install, pre-upgrade, post-upgrade, pre-delete, post-delete, pre-rollback, post-rollback, test */
|
|
75
|
+
hook: string;
|
|
76
|
+
/** Hook execution order weight */
|
|
77
|
+
weight?: number;
|
|
78
|
+
/** Hook delete policy: before-hook-creation, hook-succeeded, hook-failed */
|
|
79
|
+
deletePolicy?: string;
|
|
80
|
+
/** K8s resource to annotate with the hook */
|
|
81
|
+
resource: object;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Lifecycle hook annotation — wraps a K8s resource with helm.sh/hook annotations. */
|
|
85
|
+
export declare const HelmHook: new (props: HelmHookProps) => Declarable;
|
|
86
|
+
|
|
87
|
+
/** Chart dependency entry for Chart.yaml dependencies. */
|
|
88
|
+
export interface HelmDependencyProps {
|
|
89
|
+
/** Dependency chart name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Dependency version range (SemVer) */
|
|
92
|
+
version: string;
|
|
93
|
+
/** Repository URL */
|
|
94
|
+
repository: string;
|
|
95
|
+
/** YAML path that enables/disables this dependency */
|
|
96
|
+
condition?: string;
|
|
97
|
+
/** Tags for grouping dependencies */
|
|
98
|
+
tags?: string[];
|
|
99
|
+
/** Whether this dependency is enabled */
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
/** Values to import from dependency (import-values in Chart.yaml) */
|
|
102
|
+
importValues?: unknown[];
|
|
103
|
+
/** Alias for the dependency */
|
|
104
|
+
alias?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Chart dependency entry for Chart.yaml dependencies. */
|
|
108
|
+
export declare const HelmDependency: new (props: HelmDependencyProps) => Declarable;
|
|
109
|
+
|
|
110
|
+
/** Chart maintainer entry for Chart.yaml maintainers. */
|
|
111
|
+
export interface HelmMaintainerProps {
|
|
112
|
+
/** Maintainer name */
|
|
113
|
+
name: string;
|
|
114
|
+
/** Maintainer email */
|
|
115
|
+
email?: string;
|
|
116
|
+
/** Maintainer URL */
|
|
117
|
+
url?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Chart maintainer entry for Chart.yaml maintainers. */
|
|
121
|
+
export declare const HelmMaintainer: new (props: HelmMaintainerProps) => Declarable;
|
|
122
|
+
|
|
123
|
+
/** Custom Resource Definition — placed in the crds/ directory. */
|
|
124
|
+
export interface HelmCRDProps {
|
|
125
|
+
/** CRD YAML content */
|
|
126
|
+
content: string;
|
|
127
|
+
/** CRD filename (e.g. mycrd.yaml) */
|
|
128
|
+
filename?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Custom Resource Definition — placed in the crds/ directory. */
|
|
132
|
+
export declare const HelmCRD: new (props: HelmCRDProps) => Declarable;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Auto-generated Helm lexicon runtime index
|
|
2
|
+
// Do not edit manually
|
|
3
|
+
|
|
4
|
+
import { createResource, createProperty } from "@intentius/chant/runtime";
|
|
5
|
+
|
|
6
|
+
export const Chart = createResource("Helm::Chart", "helm", {});
|
|
7
|
+
export const Values = createResource("Helm::Values", "helm", {});
|
|
8
|
+
export const HelmTest = createResource("Helm::Test", "helm", {});
|
|
9
|
+
export const HelmNotes = createResource("Helm::Notes", "helm", {});
|
|
10
|
+
export const HelmHook = createProperty("Helm::Hook", "helm");
|
|
11
|
+
export const HelmDependency = createProperty("Helm::Dependency", "helm");
|
|
12
|
+
export const HelmMaintainer = createProperty("Helm::Maintainer", "helm");
|
|
13
|
+
export const HelmCRD = createResource("Helm::CRD", "helm", {});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Chart": {
|
|
3
|
+
"resourceType": "Helm::Chart",
|
|
4
|
+
"kind": "resource",
|
|
5
|
+
"description": "Chart.yaml metadata — defines the chart identity, version, and type.",
|
|
6
|
+
"props": {
|
|
7
|
+
"apiVersion": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Chart API version (v2)",
|
|
10
|
+
"required": true
|
|
11
|
+
},
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Chart name",
|
|
15
|
+
"required": true
|
|
16
|
+
},
|
|
17
|
+
"version": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Chart version (SemVer)",
|
|
20
|
+
"required": true
|
|
21
|
+
},
|
|
22
|
+
"appVersion": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Version of the app deployed by this chart"
|
|
25
|
+
},
|
|
26
|
+
"description": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "A single-sentence description of this chart"
|
|
29
|
+
},
|
|
30
|
+
"type": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Chart type: application or library"
|
|
33
|
+
},
|
|
34
|
+
"keywords": {
|
|
35
|
+
"type": "string[]",
|
|
36
|
+
"description": "Keywords for chart search"
|
|
37
|
+
},
|
|
38
|
+
"home": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "URL of the project home page"
|
|
41
|
+
},
|
|
42
|
+
"icon": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "URL to an SVG or PNG image for the chart"
|
|
45
|
+
},
|
|
46
|
+
"deprecated": {
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"description": "Whether this chart is deprecated"
|
|
49
|
+
},
|
|
50
|
+
"sources": {
|
|
51
|
+
"type": "string[]",
|
|
52
|
+
"description": "URLs to source code for this chart"
|
|
53
|
+
},
|
|
54
|
+
"maintainers": {
|
|
55
|
+
"type": "HelmMaintainerProps[]",
|
|
56
|
+
"description": "List of chart maintainers"
|
|
57
|
+
},
|
|
58
|
+
"annotations": {
|
|
59
|
+
"type": "Record<string, string>",
|
|
60
|
+
"description": "Arbitrary key-value annotations"
|
|
61
|
+
},
|
|
62
|
+
"kubeVersion": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "SemVer range of compatible Kubernetes versions"
|
|
65
|
+
},
|
|
66
|
+
"condition": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "YAML path for chart enablement (subcharts)"
|
|
69
|
+
},
|
|
70
|
+
"tags": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "Tags for grouping charts for enabling/disabling"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"Values": {
|
|
77
|
+
"resourceType": "Helm::Values",
|
|
78
|
+
"kind": "resource",
|
|
79
|
+
"description": "Typed values definition — emits values.yaml and values.schema.json.",
|
|
80
|
+
"props": {}
|
|
81
|
+
},
|
|
82
|
+
"HelmTest": {
|
|
83
|
+
"resourceType": "Helm::Test",
|
|
84
|
+
"kind": "resource",
|
|
85
|
+
"description": "Helm test pod — annotated with helm.sh/hook: test.",
|
|
86
|
+
"props": {
|
|
87
|
+
"resource": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"description": "K8s Pod resource to use as the test"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"HelmNotes": {
|
|
94
|
+
"resourceType": "Helm::Notes",
|
|
95
|
+
"kind": "resource",
|
|
96
|
+
"description": "NOTES.txt template content — displayed after helm install.",
|
|
97
|
+
"props": {
|
|
98
|
+
"content": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"description": "NOTES.txt content (may contain Go template expressions)",
|
|
101
|
+
"required": true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"HelmHook": {
|
|
106
|
+
"resourceType": "Helm::Hook",
|
|
107
|
+
"kind": "property",
|
|
108
|
+
"description": "Lifecycle hook annotation — wraps a K8s resource with helm.sh/hook annotations.",
|
|
109
|
+
"props": {
|
|
110
|
+
"hook": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"description": "Hook type: pre-install, post-install, pre-upgrade, post-upgrade, pre-delete, post-delete, pre-rollback, post-rollback, test",
|
|
113
|
+
"required": true
|
|
114
|
+
},
|
|
115
|
+
"weight": {
|
|
116
|
+
"type": "number",
|
|
117
|
+
"description": "Hook execution order weight"
|
|
118
|
+
},
|
|
119
|
+
"deletePolicy": {
|
|
120
|
+
"type": "string",
|
|
121
|
+
"description": "Hook delete policy: before-hook-creation, hook-succeeded, hook-failed"
|
|
122
|
+
},
|
|
123
|
+
"resource": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"description": "K8s resource to annotate with the hook",
|
|
126
|
+
"required": true
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"HelmDependency": {
|
|
131
|
+
"resourceType": "Helm::Dependency",
|
|
132
|
+
"kind": "property",
|
|
133
|
+
"description": "Chart dependency entry for Chart.yaml dependencies.",
|
|
134
|
+
"props": {
|
|
135
|
+
"name": {
|
|
136
|
+
"type": "string",
|
|
137
|
+
"description": "Dependency chart name",
|
|
138
|
+
"required": true
|
|
139
|
+
},
|
|
140
|
+
"version": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "Dependency version range (SemVer)",
|
|
143
|
+
"required": true
|
|
144
|
+
},
|
|
145
|
+
"repository": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"description": "Repository URL",
|
|
148
|
+
"required": true
|
|
149
|
+
},
|
|
150
|
+
"condition": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"description": "YAML path that enables/disables this dependency"
|
|
153
|
+
},
|
|
154
|
+
"tags": {
|
|
155
|
+
"type": "string[]",
|
|
156
|
+
"description": "Tags for grouping dependencies"
|
|
157
|
+
},
|
|
158
|
+
"enabled": {
|
|
159
|
+
"type": "boolean",
|
|
160
|
+
"description": "Whether this dependency is enabled"
|
|
161
|
+
},
|
|
162
|
+
"importValues": {
|
|
163
|
+
"type": "unknown[]",
|
|
164
|
+
"description": "Values to import from dependency (import-values in Chart.yaml)"
|
|
165
|
+
},
|
|
166
|
+
"alias": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"description": "Alias for the dependency"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"HelmMaintainer": {
|
|
173
|
+
"resourceType": "Helm::Maintainer",
|
|
174
|
+
"kind": "property",
|
|
175
|
+
"description": "Chart maintainer entry for Chart.yaml maintainers.",
|
|
176
|
+
"props": {
|
|
177
|
+
"name": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"description": "Maintainer name",
|
|
180
|
+
"required": true
|
|
181
|
+
},
|
|
182
|
+
"email": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "Maintainer email"
|
|
185
|
+
},
|
|
186
|
+
"url": {
|
|
187
|
+
"type": "string",
|
|
188
|
+
"description": "Maintainer URL"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"HelmCRD": {
|
|
193
|
+
"resourceType": "Helm::CRD",
|
|
194
|
+
"kind": "resource",
|
|
195
|
+
"description": "Custom Resource Definition — placed in the crds/ directory.",
|
|
196
|
+
"props": {
|
|
197
|
+
"content": {
|
|
198
|
+
"type": "string",
|
|
199
|
+
"description": "CRD YAML content",
|
|
200
|
+
"required": true
|
|
201
|
+
},
|
|
202
|
+
"filename": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"description": "CRD filename (e.g. mycrd.yaml)"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, test, expect } from "bun:test";
|
|
2
|
+
import { generateHelpers } from "./helpers";
|
|
3
|
+
|
|
4
|
+
describe("generateHelpers", () => {
|
|
5
|
+
test("generates all standard named templates", () => {
|
|
6
|
+
const content = generateHelpers({ chartName: "my-app" });
|
|
7
|
+
|
|
8
|
+
expect(content).toContain('{{- define "my-app.name" -}}');
|
|
9
|
+
expect(content).toContain('{{- define "my-app.fullname" -}}');
|
|
10
|
+
expect(content).toContain('{{- define "my-app.chart" -}}');
|
|
11
|
+
expect(content).toContain('{{- define "my-app.labels" -}}');
|
|
12
|
+
expect(content).toContain('{{- define "my-app.selectorLabels" -}}');
|
|
13
|
+
expect(content).toContain('{{- define "my-app.serviceAccountName" -}}');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("fullname template handles nameOverride and fullnameOverride", () => {
|
|
17
|
+
const content = generateHelpers({ chartName: "test" });
|
|
18
|
+
|
|
19
|
+
expect(content).toContain(".Values.fullnameOverride");
|
|
20
|
+
expect(content).toContain(".Values.nameOverride");
|
|
21
|
+
expect(content).toContain("trunc 63");
|
|
22
|
+
expect(content).toContain('trimSuffix "-"');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("labels template includes standard Helm labels", () => {
|
|
26
|
+
const content = generateHelpers({ chartName: "test" });
|
|
27
|
+
|
|
28
|
+
expect(content).toContain("helm.sh/chart:");
|
|
29
|
+
expect(content).toContain("app.kubernetes.io/version:");
|
|
30
|
+
expect(content).toContain("app.kubernetes.io/managed-by:");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("selectorLabels template has name and instance", () => {
|
|
34
|
+
const content = generateHelpers({ chartName: "test" });
|
|
35
|
+
|
|
36
|
+
expect(content).toContain("app.kubernetes.io/name:");
|
|
37
|
+
expect(content).toContain("app.kubernetes.io/instance:");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("serviceAccountName helper can be excluded", () => {
|
|
41
|
+
const content = generateHelpers({ chartName: "test", includeServiceAccount: false });
|
|
42
|
+
expect(content).not.toContain("serviceAccountName");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("serviceAccountName helper included by default", () => {
|
|
46
|
+
const content = generateHelpers({ chartName: "test" });
|
|
47
|
+
expect(content).toContain("serviceAccountName");
|
|
48
|
+
expect(content).toContain(".Values.serviceAccount.create");
|
|
49
|
+
expect(content).toContain(".Values.serviceAccount.name");
|
|
50
|
+
});
|
|
51
|
+
});
|
package/src/helpers.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* _helpers.tpl generation for Helm charts.
|
|
3
|
+
*
|
|
4
|
+
* Generates the standard named templates that Helm charts typically include:
|
|
5
|
+
* chart name, fullname, labels, selectorLabels, chart metadata, serviceAccountName.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface HelpersConfig {
|
|
9
|
+
/** Chart name (from Chart.yaml) */
|
|
10
|
+
chartName: string;
|
|
11
|
+
/** Whether to include serviceAccountName helper */
|
|
12
|
+
includeServiceAccount?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generate the _helpers.tpl content for a Helm chart.
|
|
17
|
+
*/
|
|
18
|
+
export function generateHelpers(config: HelpersConfig): string {
|
|
19
|
+
const { chartName, includeServiceAccount = true } = config;
|
|
20
|
+
|
|
21
|
+
const lines: string[] = [];
|
|
22
|
+
|
|
23
|
+
// Chart name
|
|
24
|
+
lines.push(`{{/*
|
|
25
|
+
Expand the name of the chart.
|
|
26
|
+
*/}}
|
|
27
|
+
{{- define "${chartName}.name" -}}
|
|
28
|
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
|
29
|
+
{{- end }}`);
|
|
30
|
+
|
|
31
|
+
// Fullname
|
|
32
|
+
lines.push(`
|
|
33
|
+
{{/*
|
|
34
|
+
Create a default fully qualified app name.
|
|
35
|
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
36
|
+
If release name contains chart name it will be used as a full name.
|
|
37
|
+
*/}}
|
|
38
|
+
{{- define "${chartName}.fullname" -}}
|
|
39
|
+
{{- if .Values.fullnameOverride }}
|
|
40
|
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
|
41
|
+
{{- else }}
|
|
42
|
+
{{- $name := default .Chart.Name .Values.nameOverride }}
|
|
43
|
+
{{- if contains $name .Release.Name }}
|
|
44
|
+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
|
45
|
+
{{- else }}
|
|
46
|
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
|
47
|
+
{{- end }}
|
|
48
|
+
{{- end }}
|
|
49
|
+
{{- end }}`);
|
|
50
|
+
|
|
51
|
+
// Chart label
|
|
52
|
+
lines.push(`
|
|
53
|
+
{{/*
|
|
54
|
+
Create chart name and version as used by the chart label.
|
|
55
|
+
*/}}
|
|
56
|
+
{{- define "${chartName}.chart" -}}
|
|
57
|
+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
|
58
|
+
{{- end }}`);
|
|
59
|
+
|
|
60
|
+
// Common labels
|
|
61
|
+
lines.push(`
|
|
62
|
+
{{/*
|
|
63
|
+
Common labels
|
|
64
|
+
*/}}
|
|
65
|
+
{{- define "${chartName}.labels" -}}
|
|
66
|
+
helm.sh/chart: {{ include "${chartName}.chart" . }}
|
|
67
|
+
{{ include "${chartName}.selectorLabels" . }}
|
|
68
|
+
{{- if .Chart.AppVersion }}
|
|
69
|
+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
|
70
|
+
{{- end }}
|
|
71
|
+
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
72
|
+
{{- end }}`);
|
|
73
|
+
|
|
74
|
+
// Selector labels
|
|
75
|
+
lines.push(`
|
|
76
|
+
{{/*
|
|
77
|
+
Selector labels
|
|
78
|
+
*/}}
|
|
79
|
+
{{- define "${chartName}.selectorLabels" -}}
|
|
80
|
+
app.kubernetes.io/name: {{ include "${chartName}.name" . }}
|
|
81
|
+
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
82
|
+
{{- end }}`);
|
|
83
|
+
|
|
84
|
+
// Service account name
|
|
85
|
+
if (includeServiceAccount) {
|
|
86
|
+
lines.push(`
|
|
87
|
+
{{/*
|
|
88
|
+
Create the name of the service account to use
|
|
89
|
+
*/}}
|
|
90
|
+
{{- define "${chartName}.serviceAccountName" -}}
|
|
91
|
+
{{- if .Values.serviceAccount.create }}
|
|
92
|
+
{{- default (include "${chartName}.fullname" .) .Values.serviceAccount.name }}
|
|
93
|
+
{{- else }}
|
|
94
|
+
{{- default "default" .Values.serviceAccount.name }}
|
|
95
|
+
{{- end }}
|
|
96
|
+
{{- end }}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return lines.join("\n") + "\n";
|
|
100
|
+
}
|