timonel 2.8.1 → 2.8.3
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/CHANGELOG.md +6 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +290 -226
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/lib/helm.d.ts +0 -472
- package/dist/lib/helm.js +0 -481
- package/dist/lib/helmChartWriter.d.ts +0 -178
- package/dist/lib/helmChartWriter.js +0 -180
- package/dist/lib/resources/baseResourceProvider.d.ts +0 -46
- package/dist/lib/resources/baseResourceProvider.js +1 -47
- package/dist/lib/resources/cloud/aws/awsResources.d.ts +0 -144
- package/dist/lib/resources/cloud/aws/awsResources.js +1 -163
- package/dist/lib/resources/cloud/aws/karpenterResources.d.ts +0 -132
- package/dist/lib/resources/cloud/aws/karpenterResources.js +0 -75
- package/dist/lib/rutter.d.ts +0 -324
- package/dist/lib/rutter.js +8 -352
- package/dist/lib/security.d.ts +0 -119
- package/dist/lib/security.js +4 -160
- package/dist/lib/umbrella.d.ts +0 -24
- package/dist/lib/umbrella.js +0 -24
- package/dist/lib/umbrellaRutter.d.ts +0 -71
- package/dist/lib/umbrellaRutter.js +2 -82
- package/dist/lib/utils/helmHelpers.d.ts +0 -39
- package/dist/lib/utils/helmHelpers.js +0 -32
- package/package.json +1 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/helm.d.ts.map +0 -1
- package/dist/lib/helm.js.map +0 -1
- package/dist/lib/helmChartWriter.d.ts.map +0 -1
- package/dist/lib/helmChartWriter.js.map +0 -1
- package/dist/lib/resources/baseResourceProvider.d.ts.map +0 -1
- package/dist/lib/resources/baseResourceProvider.js.map +0 -1
- package/dist/lib/resources/cloud/aws/awsResources.d.ts.map +0 -1
- package/dist/lib/resources/cloud/aws/awsResources.js.map +0 -1
- package/dist/lib/resources/cloud/aws/karpenterResources.d.ts.map +0 -1
- package/dist/lib/resources/cloud/aws/karpenterResources.js.map +0 -1
- package/dist/lib/rutter.d.ts.map +0 -1
- package/dist/lib/rutter.js.map +0 -1
- package/dist/lib/security.d.ts.map +0 -1
- package/dist/lib/security.js.map +0 -1
- package/dist/lib/umbrella.d.ts.map +0 -1
- package/dist/lib/umbrella.js.map +0 -1
- package/dist/lib/umbrellaRutter.d.ts.map +0 -1
- package/dist/lib/umbrellaRutter.js.map +0 -1
- package/dist/lib/utils/helmHelpers.d.ts.map +0 -1
- package/dist/lib/utils/helmHelpers.js.map +0 -1
|
@@ -1,44 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Helm chart writer for generating complete Helm chart structures
|
|
3
|
-
* @since 1.0.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Metadata for a Helm chart
|
|
7
|
-
*
|
|
8
|
-
* Contains all the information needed for Chart.yaml file generation
|
|
9
|
-
* following Helm chart specification.
|
|
10
|
-
*
|
|
11
|
-
* @interface HelmChartMeta
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
1
|
export interface HelmChartMeta {
|
|
15
|
-
/** Chart name */
|
|
16
2
|
name: string;
|
|
17
|
-
/** SemVer chart version */
|
|
18
3
|
version: string;
|
|
19
|
-
/** Chart description */
|
|
20
4
|
description?: string;
|
|
21
|
-
/** Underlying application version */
|
|
22
5
|
appVersion?: string;
|
|
23
|
-
/** Chart type */
|
|
24
6
|
type?: 'application' | 'library';
|
|
25
|
-
/** Kubernetes version constraint */
|
|
26
7
|
kubeVersion?: string;
|
|
27
|
-
/** Chart keywords for searchability */
|
|
28
8
|
keywords?: string[];
|
|
29
|
-
/** Chart home page URL */
|
|
30
9
|
home?: string;
|
|
31
|
-
/** Source code URLs */
|
|
32
10
|
sources?: string[];
|
|
33
|
-
/** Chart maintainers */
|
|
34
11
|
maintainers?: {
|
|
35
12
|
name: string;
|
|
36
13
|
email?: string;
|
|
37
14
|
url?: string;
|
|
38
15
|
}[];
|
|
39
|
-
/** Chart icon URL */
|
|
40
16
|
icon?: string;
|
|
41
|
-
/** Chart dependencies */
|
|
42
17
|
dependencies?: Array<{
|
|
43
18
|
name: string;
|
|
44
19
|
version: string;
|
|
@@ -49,190 +24,37 @@ export interface HelmChartMeta {
|
|
|
49
24
|
importValues?: unknown;
|
|
50
25
|
}>;
|
|
51
26
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Environment-specific values mapping
|
|
54
|
-
*
|
|
55
|
-
* @interface EnvValuesMap
|
|
56
|
-
* @since 1.0.0
|
|
57
|
-
*/
|
|
58
27
|
export interface EnvValuesMap {
|
|
59
28
|
[env: string]: Record<string, unknown>;
|
|
60
29
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Synthesized Kubernetes asset for Helm chart
|
|
63
|
-
*
|
|
64
|
-
* Represents a Kubernetes manifest that will be written to the chart's
|
|
65
|
-
* templates or crds directory.
|
|
66
|
-
*
|
|
67
|
-
* @interface SynthAsset
|
|
68
|
-
* @since 1.0.0
|
|
69
|
-
*/
|
|
70
30
|
export interface SynthAsset {
|
|
71
|
-
/** Filename or logical identifier */
|
|
72
31
|
id: string;
|
|
73
|
-
/** YAML content, may contain multiple documents separated by --- */
|
|
74
32
|
yaml: string;
|
|
75
|
-
/** Target directory inside chart */
|
|
76
33
|
target?: 'templates' | 'crds';
|
|
77
|
-
/** If true, don't split into multiple files even with multiple docs */
|
|
78
34
|
singleFile?: boolean;
|
|
79
35
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Options for writing a complete Helm chart
|
|
82
|
-
*
|
|
83
|
-
* @interface HelmChartWriteOptions
|
|
84
|
-
* @since 1.0.0
|
|
85
|
-
*/
|
|
86
36
|
export interface HelmChartWriteOptions {
|
|
87
|
-
/** Output directory path (e.g., dist/charts/my-chart) */
|
|
88
37
|
outDir: string;
|
|
89
|
-
/** Chart metadata */
|
|
90
38
|
meta: HelmChartMeta;
|
|
91
|
-
/** Default values for values.yaml */
|
|
92
39
|
defaultValues?: Record<string, unknown> | undefined;
|
|
93
|
-
/** Environment-specific values (e.g., { dev: {...}, prod: {...} }) */
|
|
94
40
|
envValues?: EnvValuesMap | undefined;
|
|
95
|
-
/** Kubernetes manifests to place under templates/ */
|
|
96
41
|
assets: SynthAsset[];
|
|
97
|
-
/** Helm helpers content for templates/_helpers.tpl */
|
|
98
42
|
helpersTpl?: string | HelperDefinition[];
|
|
99
|
-
/** NOTES.txt content under templates/ */
|
|
100
43
|
notesTpl?: string;
|
|
101
|
-
/** JSON schema for values validation */
|
|
102
44
|
valuesSchema?: Record<string, unknown>;
|
|
103
45
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Helm template helper definition
|
|
106
|
-
*
|
|
107
|
-
* @interface HelperDefinition
|
|
108
|
-
* @since 1.0.0
|
|
109
|
-
*/
|
|
110
46
|
export interface HelperDefinition {
|
|
111
|
-
/** Template name */
|
|
112
47
|
name: string;
|
|
113
|
-
/** Template body content */
|
|
114
48
|
body: string;
|
|
115
49
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Helm chart writer for generating complete chart structures
|
|
118
|
-
*
|
|
119
|
-
* This class provides static methods to generate a complete Helm chart
|
|
120
|
-
* including Chart.yaml, values.yaml, templates, and auxiliary files.
|
|
121
|
-
*
|
|
122
|
-
* @class HelmChartWriter
|
|
123
|
-
* @since 1.0.0
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* HelmChartWriter.write({
|
|
128
|
-
* outDir: './dist/my-chart',
|
|
129
|
-
* meta: { name: 'my-app', version: '1.0.0' },
|
|
130
|
-
* assets: []
|
|
131
|
-
* });
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
50
|
export declare class HelmChartWriter {
|
|
135
|
-
/**
|
|
136
|
-
* Writes a complete Helm chart to the specified directory
|
|
137
|
-
*
|
|
138
|
-
* Creates the full directory structure and writes all necessary files
|
|
139
|
-
* for a valid Helm chart including Chart.yaml, values files, templates,
|
|
140
|
-
* and auxiliary files.
|
|
141
|
-
*
|
|
142
|
-
* @param {HelmChartWriteOptions} opts - Chart configuration options
|
|
143
|
-
* @throws {Error} If output directory path is invalid
|
|
144
|
-
* @throws {Error} If chart metadata is invalid
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* HelmChartWriter.write({
|
|
149
|
-
* outDir: './charts/my-app',
|
|
150
|
-
* meta: {
|
|
151
|
-
* name: 'my-app',
|
|
152
|
-
* version: '1.0.0',
|
|
153
|
-
* description: 'My application'
|
|
154
|
-
* },
|
|
155
|
-
* defaultValues: { replicas: 3 },
|
|
156
|
-
* assets: []
|
|
157
|
-
* });
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @since 1.0.0
|
|
161
|
-
*/
|
|
162
51
|
static write(opts: HelmChartWriteOptions): void;
|
|
163
|
-
/**
|
|
164
|
-
* Creates the necessary directory structure for the chart
|
|
165
|
-
*
|
|
166
|
-
* @private
|
|
167
|
-
* @param {string} outDir - Output directory path
|
|
168
|
-
* @throws {Error} If directories cannot be created
|
|
169
|
-
* @since 1.0.0
|
|
170
|
-
*/
|
|
171
52
|
private static createDirectories;
|
|
172
|
-
/**
|
|
173
|
-
* Writes the Chart.yaml file with chart metadata
|
|
174
|
-
*
|
|
175
|
-
* @private
|
|
176
|
-
* @param {string} outDir - Output directory path
|
|
177
|
-
* @param {HelmChartMeta} meta - Chart metadata
|
|
178
|
-
* @throws {Error} If Chart.yaml cannot be written
|
|
179
|
-
* @since 1.0.0
|
|
180
|
-
*/
|
|
181
53
|
private static writeChartYaml;
|
|
182
|
-
/**
|
|
183
|
-
* Writes values.yaml and environment-specific values files
|
|
184
|
-
*
|
|
185
|
-
* @private
|
|
186
|
-
* @param {string} outDir - Output directory path
|
|
187
|
-
* @param {Record<string, unknown>} defaultValues - Default values
|
|
188
|
-
* @param {EnvValuesMap} envValues - Environment-specific values
|
|
189
|
-
* @throws {Error} If values files cannot be written
|
|
190
|
-
* @since 1.0.0
|
|
191
|
-
*/
|
|
192
54
|
private static writeValuesFiles;
|
|
193
|
-
/**
|
|
194
|
-
* Writes Kubernetes manifest assets to templates directory
|
|
195
|
-
*
|
|
196
|
-
* @private
|
|
197
|
-
* @param {string} outDir - Output directory path
|
|
198
|
-
* @param {SynthAsset[]} assets - Kubernetes manifests to write
|
|
199
|
-
* @since 1.0.0
|
|
200
|
-
*/
|
|
201
55
|
private static writeAssets;
|
|
202
|
-
/**
|
|
203
|
-
* Writes Helm template helpers to _helpers.tpl file
|
|
204
|
-
*
|
|
205
|
-
* @private
|
|
206
|
-
* @param {string} outDir - Output directory path
|
|
207
|
-
* @param {string | HelperDefinition[]} [helpersTpl] - Helpers content
|
|
208
|
-
* @since 1.0.0
|
|
209
|
-
*/
|
|
210
56
|
private static writeHelpers;
|
|
211
|
-
/**
|
|
212
|
-
* Writes NOTES.txt file for post-install instructions
|
|
213
|
-
*
|
|
214
|
-
* @private
|
|
215
|
-
* @param {string} outDir - Output directory path
|
|
216
|
-
* @param {string} [notesTpl] - Notes content
|
|
217
|
-
* @since 1.0.0
|
|
218
|
-
*/
|
|
219
57
|
private static writeNotes;
|
|
220
|
-
/**
|
|
221
|
-
* Writes values.schema.json for values validation
|
|
222
|
-
*
|
|
223
|
-
* @private
|
|
224
|
-
* @param {string} outDir - Output directory path
|
|
225
|
-
* @param {Record<string, unknown>} [valuesSchema] - JSON schema
|
|
226
|
-
* @since 1.0.0
|
|
227
|
-
*/
|
|
228
58
|
private static writeSchema;
|
|
229
|
-
/**
|
|
230
|
-
* Writes .helmignore file with common ignore patterns
|
|
231
|
-
*
|
|
232
|
-
* @private
|
|
233
|
-
* @param {string} outDir - Output directory path
|
|
234
|
-
* @since 1.0.0
|
|
235
|
-
*/
|
|
236
59
|
private static writeHelmIgnore;
|
|
237
60
|
}
|
|
238
|
-
//# sourceMappingURL=helmChartWriter.d.ts.map
|
|
@@ -1,64 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Helm chart writer for generating complete Helm chart structures
|
|
3
|
-
* @since 1.0.0
|
|
4
|
-
*/
|
|
5
1
|
import * as fs from 'fs';
|
|
6
2
|
import * as path from 'path';
|
|
7
3
|
import YAML from 'yaml';
|
|
8
4
|
import { SecurityUtils } from './security.js';
|
|
9
|
-
/**
|
|
10
|
-
* Helm chart writer for generating complete chart structures
|
|
11
|
-
*
|
|
12
|
-
* This class provides static methods to generate a complete Helm chart
|
|
13
|
-
* including Chart.yaml, values.yaml, templates, and auxiliary files.
|
|
14
|
-
*
|
|
15
|
-
* @class HelmChartWriter
|
|
16
|
-
* @since 1.0.0
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* HelmChartWriter.write({
|
|
21
|
-
* outDir: './dist/my-chart',
|
|
22
|
-
* meta: { name: 'my-app', version: '1.0.0' },
|
|
23
|
-
* assets: []
|
|
24
|
-
* });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
5
|
export class HelmChartWriter {
|
|
28
|
-
/**
|
|
29
|
-
* Writes a complete Helm chart to the specified directory
|
|
30
|
-
*
|
|
31
|
-
* Creates the full directory structure and writes all necessary files
|
|
32
|
-
* for a valid Helm chart including Chart.yaml, values files, templates,
|
|
33
|
-
* and auxiliary files.
|
|
34
|
-
*
|
|
35
|
-
* @param {HelmChartWriteOptions} opts - Chart configuration options
|
|
36
|
-
* @throws {Error} If output directory path is invalid
|
|
37
|
-
* @throws {Error} If chart metadata is invalid
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* HelmChartWriter.write({
|
|
42
|
-
* outDir: './charts/my-app',
|
|
43
|
-
* meta: {
|
|
44
|
-
* name: 'my-app',
|
|
45
|
-
* version: '1.0.0',
|
|
46
|
-
* description: 'My application'
|
|
47
|
-
* },
|
|
48
|
-
* defaultValues: { replicas: 3 },
|
|
49
|
-
* assets: []
|
|
50
|
-
* });
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @since 1.0.0
|
|
54
|
-
*/
|
|
55
6
|
static write(opts) {
|
|
56
7
|
const { outDir, meta, defaultValues = {}, envValues = {}, assets, helpersTpl, notesTpl, valuesSchema, } = opts;
|
|
57
|
-
// Validate output directory path
|
|
58
8
|
const validatedOutDir = SecurityUtils.validatePath(outDir, process.cwd());
|
|
59
|
-
// Create directory structure
|
|
60
9
|
this.createDirectories(validatedOutDir);
|
|
61
|
-
// Write chart files
|
|
62
10
|
this.writeChartYaml(validatedOutDir, meta);
|
|
63
11
|
this.writeValuesFiles(validatedOutDir, defaultValues, envValues);
|
|
64
12
|
this.writeAssets(validatedOutDir, assets);
|
|
@@ -67,28 +15,9 @@ export class HelmChartWriter {
|
|
|
67
15
|
this.writeSchema(validatedOutDir, valuesSchema);
|
|
68
16
|
this.writeHelmIgnore(validatedOutDir);
|
|
69
17
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Creates the necessary directory structure for the chart
|
|
72
|
-
*
|
|
73
|
-
* @private
|
|
74
|
-
* @param {string} outDir - Output directory path
|
|
75
|
-
* @throws {Error} If directories cannot be created
|
|
76
|
-
* @since 1.0.0
|
|
77
|
-
*/
|
|
78
18
|
static createDirectories(outDir) {
|
|
79
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
80
19
|
fs.mkdirSync(path.join(outDir, 'templates'), { recursive: true });
|
|
81
|
-
// Create crds directory only if needed later
|
|
82
20
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Writes the Chart.yaml file with chart metadata
|
|
85
|
-
*
|
|
86
|
-
* @private
|
|
87
|
-
* @param {string} outDir - Output directory path
|
|
88
|
-
* @param {HelmChartMeta} meta - Chart metadata
|
|
89
|
-
* @throws {Error} If Chart.yaml cannot be written
|
|
90
|
-
* @since 1.0.0
|
|
91
|
-
*/
|
|
92
21
|
static writeChartYaml(outDir, meta) {
|
|
93
22
|
const chartYaml = YAML.stringify({
|
|
94
23
|
apiVersion: 'v2',
|
|
@@ -105,48 +34,18 @@ export class HelmChartWriter {
|
|
|
105
34
|
icon: meta.icon,
|
|
106
35
|
dependencies: meta.dependencies,
|
|
107
36
|
});
|
|
108
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
109
37
|
fs.writeFileSync(path.join(outDir, 'Chart.yaml'), chartYaml);
|
|
110
38
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Writes values.yaml and environment-specific values files
|
|
113
|
-
*
|
|
114
|
-
* @private
|
|
115
|
-
* @param {string} outDir - Output directory path
|
|
116
|
-
* @param {Record<string, unknown>} defaultValues - Default values
|
|
117
|
-
* @param {EnvValuesMap} envValues - Environment-specific values
|
|
118
|
-
* @throws {Error} If values files cannot be written
|
|
119
|
-
* @since 1.0.0
|
|
120
|
-
*/
|
|
121
39
|
static writeValuesFiles(outDir, defaultValues, envValues) {
|
|
122
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
123
40
|
fs.writeFileSync(path.join(outDir, 'values.yaml'), YAML.stringify(defaultValues));
|
|
124
41
|
for (const [env, values] of Object.entries(envValues)) {
|
|
125
|
-
// Use centralized environment name sanitization
|
|
126
42
|
const sanitizedEnv = SecurityUtils.sanitizeEnvironmentName(env);
|
|
127
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
128
43
|
fs.writeFileSync(path.join(outDir, `values-${sanitizedEnv}.yaml`), YAML.stringify(values));
|
|
129
44
|
}
|
|
130
45
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Writes Kubernetes manifest assets to templates directory
|
|
133
|
-
*
|
|
134
|
-
* @private
|
|
135
|
-
* @param {string} outDir - Output directory path
|
|
136
|
-
* @param {SynthAsset[]} assets - Kubernetes manifests to write
|
|
137
|
-
* @since 1.0.0
|
|
138
|
-
*/
|
|
139
46
|
static writeAssets(outDir, assets) {
|
|
140
47
|
writeAssets(outDir, assets);
|
|
141
48
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Writes Helm template helpers to _helpers.tpl file
|
|
144
|
-
*
|
|
145
|
-
* @private
|
|
146
|
-
* @param {string} outDir - Output directory path
|
|
147
|
-
* @param {string | HelperDefinition[]} [helpersTpl] - Helpers content
|
|
148
|
-
* @since 1.0.0
|
|
149
|
-
*/
|
|
150
49
|
static writeHelpers(outDir, helpersTpl) {
|
|
151
50
|
if (!helpersTpl)
|
|
152
51
|
return;
|
|
@@ -159,47 +58,20 @@ export class HelmChartWriter {
|
|
|
159
58
|
.map((h) => [`{{- define "${h.name}" -}}`, h.body.trimEnd(), '{{- end }}', ''].join('\n'))
|
|
160
59
|
.join('\n');
|
|
161
60
|
}
|
|
162
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
163
61
|
fs.writeFileSync(path.join(outDir, 'templates', '_helpers.tpl'), content);
|
|
164
62
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Writes NOTES.txt file for post-install instructions
|
|
167
|
-
*
|
|
168
|
-
* @private
|
|
169
|
-
* @param {string} outDir - Output directory path
|
|
170
|
-
* @param {string} [notesTpl] - Notes content
|
|
171
|
-
* @since 1.0.0
|
|
172
|
-
*/
|
|
173
63
|
static writeNotes(outDir, notesTpl) {
|
|
174
64
|
if (!notesTpl)
|
|
175
65
|
return;
|
|
176
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
177
66
|
fs.writeFileSync(path.join(outDir, 'templates', 'NOTES.txt'), notesTpl.endsWith('\n') ? notesTpl : notesTpl + '\n');
|
|
178
67
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Writes values.schema.json for values validation
|
|
181
|
-
*
|
|
182
|
-
* @private
|
|
183
|
-
* @param {string} outDir - Output directory path
|
|
184
|
-
* @param {Record<string, unknown>} [valuesSchema] - JSON schema
|
|
185
|
-
* @since 1.0.0
|
|
186
|
-
*/
|
|
187
68
|
static writeSchema(outDir, valuesSchema) {
|
|
188
69
|
if (!valuesSchema)
|
|
189
70
|
return;
|
|
190
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
191
71
|
fs.writeFileSync(path.join(outDir, 'values.schema.json'), JSON.stringify(valuesSchema, null, 2) + '\n');
|
|
192
72
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Writes .helmignore file with common ignore patterns
|
|
195
|
-
*
|
|
196
|
-
* @private
|
|
197
|
-
* @param {string} outDir - Output directory path
|
|
198
|
-
* @since 1.0.0
|
|
199
|
-
*/
|
|
200
73
|
static writeHelmIgnore(outDir) {
|
|
201
74
|
const helmIgnorePath = path.join(outDir, '.helmignore');
|
|
202
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
203
75
|
if (!fs.existsSync(helmIgnorePath)) {
|
|
204
76
|
const helmIgnore = [
|
|
205
77
|
'# VCS',
|
|
@@ -223,37 +95,18 @@ export class HelmChartWriter {
|
|
|
223
95
|
'*.tgz',
|
|
224
96
|
'',
|
|
225
97
|
].join('\n');
|
|
226
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
227
98
|
fs.writeFileSync(helmIgnorePath, helmIgnore);
|
|
228
99
|
}
|
|
229
100
|
}
|
|
230
101
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Splits YAML string into individual documents
|
|
233
|
-
*
|
|
234
|
-
* @private
|
|
235
|
-
* @param {string} yamlStr - YAML string with potential document separators
|
|
236
|
-
* @returns {string[]} Array of individual YAML documents
|
|
237
|
-
* @since 1.0.0
|
|
238
|
-
*/
|
|
239
102
|
function splitDocs(yamlStr) {
|
|
240
103
|
return yamlStr
|
|
241
104
|
.split(/^---\s*$/m)
|
|
242
105
|
.map((p) => p.trim())
|
|
243
106
|
.filter((p) => p.length);
|
|
244
107
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Writes all synthesized assets to the chart directory
|
|
247
|
-
*
|
|
248
|
-
* @private
|
|
249
|
-
* @param {string} outDir - Output directory path
|
|
250
|
-
* @param {SynthAsset[]} assets - Assets to write
|
|
251
|
-
* @throws {Error} If asset ID contains invalid characters
|
|
252
|
-
* @since 1.0.0
|
|
253
|
-
*/
|
|
254
108
|
function writeAssets(outDir, assets) {
|
|
255
109
|
for (const asset of assets) {
|
|
256
|
-
// Sanitize asset ID to prevent path traversal
|
|
257
110
|
const sanitizedId = asset.id.replace(/[^a-zA-Z0-9-_]/g, '');
|
|
258
111
|
if (sanitizedId !== asset.id) {
|
|
259
112
|
throw new Error(`Invalid asset ID: ${SecurityUtils.sanitizeLogMessage(asset.id)}`);
|
|
@@ -267,52 +120,19 @@ function writeAssets(outDir, assets) {
|
|
|
267
120
|
}
|
|
268
121
|
}
|
|
269
122
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Gets the target directory for an asset
|
|
272
|
-
*
|
|
273
|
-
* @private
|
|
274
|
-
* @param {('templates' | 'crds')} [target] - Target directory type
|
|
275
|
-
* @returns {string} Directory name
|
|
276
|
-
* @since 1.0.0
|
|
277
|
-
*/
|
|
278
123
|
function getTargetDirectory(target) {
|
|
279
124
|
return target === 'crds' ? 'crds' : 'templates';
|
|
280
125
|
}
|
|
281
|
-
/**
|
|
282
|
-
* Writes a single asset file without document splitting
|
|
283
|
-
*
|
|
284
|
-
* @private
|
|
285
|
-
* @param {string} outDir - Output directory path
|
|
286
|
-
* @param {string} targetDir - Target subdirectory
|
|
287
|
-
* @param {string} assetId - Asset identifier
|
|
288
|
-
* @param {string} yaml - YAML content
|
|
289
|
-
* @since 1.0.0
|
|
290
|
-
*/
|
|
291
126
|
function writeSingleAssetFile(outDir, targetDir, assetId, yaml) {
|
|
292
127
|
const filename = `${assetId}.yaml`;
|
|
293
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
294
128
|
fs.mkdirSync(path.join(outDir, targetDir), { recursive: true });
|
|
295
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
296
129
|
fs.writeFileSync(path.join(outDir, targetDir, filename), yaml + '\n');
|
|
297
130
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Writes multiple asset files by splitting YAML documents
|
|
300
|
-
*
|
|
301
|
-
* @private
|
|
302
|
-
* @param {string} outDir - Output directory path
|
|
303
|
-
* @param {string} targetDir - Target subdirectory
|
|
304
|
-
* @param {string} assetId - Asset identifier
|
|
305
|
-
* @param {string} yaml - YAML content with potential multiple documents
|
|
306
|
-
* @since 1.0.0
|
|
307
|
-
*/
|
|
308
131
|
function writeMultipleAssetFiles(outDir, targetDir, assetId, yaml) {
|
|
309
132
|
const parts = splitDocs(yaml);
|
|
310
133
|
parts.forEach((doc, index) => {
|
|
311
134
|
const filename = `${assetId}${parts.length > 1 ? `-${index + 1}` : ''}.yaml`;
|
|
312
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
313
135
|
fs.mkdirSync(path.join(outDir, targetDir), { recursive: true });
|
|
314
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
315
136
|
fs.writeFileSync(path.join(outDir, targetDir, filename), doc + '\n');
|
|
316
137
|
});
|
|
317
138
|
}
|
|
318
|
-
//# sourceMappingURL=helmChartWriter.js.map
|
|
@@ -1,59 +1,13 @@
|
|
|
1
1
|
import { ApiObject } from 'cdk8s';
|
|
2
2
|
import type { Chart } from 'cdk8s';
|
|
3
|
-
/**
|
|
4
|
-
* Base interface for all resource providers
|
|
5
|
-
* Provides common functionality and ensures consistent patterns across providers
|
|
6
|
-
*
|
|
7
|
-
* @since 2.4.0
|
|
8
|
-
*/
|
|
9
3
|
export interface IResourceProvider {
|
|
10
|
-
/** Reference to the CDK8s chart */
|
|
11
4
|
readonly chart: Chart;
|
|
12
5
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Abstract base class for resource providers
|
|
15
|
-
* Implements common functionality and validation patterns
|
|
16
|
-
*
|
|
17
|
-
* @since 2.4.0
|
|
18
|
-
*/
|
|
19
6
|
export declare abstract class BaseResourceProvider implements IResourceProvider {
|
|
20
7
|
readonly chart: Chart;
|
|
21
8
|
constructor(chart: Chart);
|
|
22
|
-
/**
|
|
23
|
-
* Validates that a name follows Kubernetes naming conventions
|
|
24
|
-
* @param name - Resource name to validate
|
|
25
|
-
* @param resourceType - Type of resource for error messages
|
|
26
|
-
* @throws Error if name is invalid
|
|
27
|
-
*/
|
|
28
9
|
protected validateKubernetesName(name: string, resourceType: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Validates that labels follow Kubernetes conventions
|
|
31
|
-
* @param labels - Labels to validate
|
|
32
|
-
* @param resourceType - Type of resource for error messages
|
|
33
|
-
*/
|
|
34
10
|
protected validateLabels(labels: Record<string, string> | undefined, resourceType: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a standardized ApiObject with common metadata
|
|
37
|
-
* @param name - Resource name
|
|
38
|
-
* @param apiVersion - Kubernetes API version
|
|
39
|
-
* @param kind - Kubernetes resource kind
|
|
40
|
-
* @param spec - Resource specification
|
|
41
|
-
* @param labels - Optional labels
|
|
42
|
-
* @param annotations - Optional annotations
|
|
43
|
-
* @returns Created ApiObject
|
|
44
|
-
*/
|
|
45
11
|
protected createApiObject(name: string, apiVersion: string, kind: string, spec: Record<string, unknown>, labels?: Record<string, string>, annotations?: Record<string, string>): ApiObject;
|
|
46
|
-
/**
|
|
47
|
-
* Creates an ApiObject for resources that don't use spec wrapper (like StorageClass)
|
|
48
|
-
* @param name - Resource name
|
|
49
|
-
* @param apiVersion - API version
|
|
50
|
-
* @param kind - Resource kind
|
|
51
|
-
* @param fields - Root-level fields for the resource
|
|
52
|
-
* @param labels - Optional labels
|
|
53
|
-
* @param annotations - Optional annotations
|
|
54
|
-
* @returns Created ApiObject
|
|
55
|
-
* @since 2.5.0
|
|
56
|
-
*/
|
|
57
12
|
protected createRootLevelApiObject(name: string, apiVersion: string, kind: string, fields: Record<string, unknown>, labels?: Record<string, string>, annotations?: Record<string, string>): ApiObject;
|
|
58
13
|
}
|
|
59
|
-
//# sourceMappingURL=baseResourceProvider.d.ts.map
|
|
@@ -1,70 +1,36 @@
|
|
|
1
1
|
import { ApiObject } from 'cdk8s';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base class for resource providers
|
|
4
|
-
* Implements common functionality and validation patterns
|
|
5
|
-
*
|
|
6
|
-
* @since 2.4.0
|
|
7
|
-
*/
|
|
8
2
|
export class BaseResourceProvider {
|
|
9
3
|
constructor(chart) {
|
|
10
4
|
this.chart = chart;
|
|
11
5
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Validates that a name follows Kubernetes naming conventions
|
|
14
|
-
* @param name - Resource name to validate
|
|
15
|
-
* @param resourceType - Type of resource for error messages
|
|
16
|
-
* @throws Error if name is invalid
|
|
17
|
-
*/
|
|
18
6
|
validateKubernetesName(name, resourceType) {
|
|
19
7
|
if (!name || typeof name !== 'string') {
|
|
20
8
|
throw new Error(`${resourceType} name must be a non-empty string`);
|
|
21
9
|
}
|
|
22
|
-
// Kubernetes name validation (RFC 1123 subdomain)
|
|
23
|
-
// eslint-disable-next-line security/detect-unsafe-regex -- Simple character class regex is safe
|
|
24
10
|
const nameRegex = /^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/;
|
|
25
11
|
if (!nameRegex.test(name) || name.length > 63) {
|
|
26
12
|
throw new Error(`${resourceType} name '${name}' must be a valid Kubernetes name (lowercase alphanumeric and hyphens, max 63 chars)`);
|
|
27
13
|
}
|
|
28
14
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Validates that labels follow Kubernetes conventions
|
|
31
|
-
* @param labels - Labels to validate
|
|
32
|
-
* @param resourceType - Type of resource for error messages
|
|
33
|
-
*/
|
|
34
15
|
validateLabels(labels, resourceType) {
|
|
35
16
|
if (!labels)
|
|
36
17
|
return;
|
|
37
18
|
Object.entries(labels).forEach(([key, value]) => {
|
|
38
|
-
// Validate label key
|
|
39
19
|
if (key.length > 253) {
|
|
40
20
|
throw new Error(`${resourceType} label key '${key}' exceeds 253 characters`);
|
|
41
21
|
}
|
|
42
|
-
// Validate label value
|
|
43
22
|
if (value.length > 63) {
|
|
44
23
|
throw new Error(`${resourceType} label value '${value}' exceeds 63 characters`);
|
|
45
24
|
}
|
|
46
|
-
// Skip validation for Helm template values
|
|
47
25
|
if (value.includes('{{') && value.includes('}}')) {
|
|
48
26
|
return;
|
|
49
27
|
}
|
|
50
|
-
// Basic character validation
|
|
51
|
-
// eslint-disable-next-line security/detect-unsafe-regex -- Simple character class regex is safe
|
|
52
28
|
const labelRegex = /^[a-zA-Z0-9]([-a-zA-Z0-9_.]*[a-zA-Z0-9])?$/;
|
|
53
29
|
if (!labelRegex.test(value)) {
|
|
54
30
|
throw new Error(`${resourceType} label value '${value}' contains invalid characters`);
|
|
55
31
|
}
|
|
56
32
|
});
|
|
57
33
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Creates a standardized ApiObject with common metadata
|
|
60
|
-
* @param name - Resource name
|
|
61
|
-
* @param apiVersion - Kubernetes API version
|
|
62
|
-
* @param kind - Kubernetes resource kind
|
|
63
|
-
* @param spec - Resource specification
|
|
64
|
-
* @param labels - Optional labels
|
|
65
|
-
* @param annotations - Optional annotations
|
|
66
|
-
* @returns Created ApiObject
|
|
67
|
-
*/
|
|
68
34
|
createApiObject(name, apiVersion, kind, spec, labels, annotations) {
|
|
69
35
|
this.validateKubernetesName(name, kind);
|
|
70
36
|
this.validateLabels(labels, kind);
|
|
@@ -79,17 +45,6 @@ export class BaseResourceProvider {
|
|
|
79
45
|
spec,
|
|
80
46
|
});
|
|
81
47
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Creates an ApiObject for resources that don't use spec wrapper (like StorageClass)
|
|
84
|
-
* @param name - Resource name
|
|
85
|
-
* @param apiVersion - API version
|
|
86
|
-
* @param kind - Resource kind
|
|
87
|
-
* @param fields - Root-level fields for the resource
|
|
88
|
-
* @param labels - Optional labels
|
|
89
|
-
* @param annotations - Optional annotations
|
|
90
|
-
* @returns Created ApiObject
|
|
91
|
-
* @since 2.5.0
|
|
92
|
-
*/
|
|
93
48
|
createRootLevelApiObject(name, apiVersion, kind, fields, labels, annotations) {
|
|
94
49
|
this.validateKubernetesName(name, kind);
|
|
95
50
|
this.validateLabels(labels, kind);
|
|
@@ -101,8 +56,7 @@ export class BaseResourceProvider {
|
|
|
101
56
|
...(labels && Object.keys(labels).length > 0 ? { labels } : {}),
|
|
102
57
|
...(annotations && Object.keys(annotations).length > 0 ? { annotations } : {}),
|
|
103
58
|
},
|
|
104
|
-
...fields,
|
|
59
|
+
...fields,
|
|
105
60
|
});
|
|
106
61
|
}
|
|
107
62
|
}
|
|
108
|
-
//# sourceMappingURL=baseResourceProvider.js.map
|