timonel 2.8.1 → 2.9.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.
- package/CHANGELOG.md +12 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +274 -634
- package/dist/index.d.ts +4 -6
- package/dist/index.js +4 -7
- 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 +27 -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 +28 -340
- package/dist/lib/rutter.js +291 -371
- package/dist/lib/security.d.ts +0 -119
- package/dist/lib/security.js +4 -160
- package/dist/lib/templates/basic-chart.d.ts +19 -0
- package/dist/lib/templates/basic-chart.js +189 -0
- package/dist/lib/templates/subchart.d.ts +27 -0
- package/dist/lib/templates/subchart.js +224 -0
- package/dist/lib/templates/umbrella-chart.d.ts +13 -0
- package/dist/lib/templates/umbrella-chart.js +222 -0
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/types.js +1 -0
- 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 +18 -41
- package/dist/lib/utils/helmHelpers.js +246 -35
- package/package.json +9 -7
- package/README.md +0 -74
- 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,94 +1,29 @@
|
|
|
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
|
-
|
|
9
|
+
console.log('📝 Validated outDir:', validatedOutDir);
|
|
60
10
|
this.createDirectories(validatedOutDir);
|
|
61
|
-
|
|
11
|
+
console.log('📝 Directories created');
|
|
62
12
|
this.writeChartYaml(validatedOutDir, meta);
|
|
13
|
+
console.log('📝 Chart.yaml written');
|
|
63
14
|
this.writeValuesFiles(validatedOutDir, defaultValues, envValues);
|
|
15
|
+
console.log('📝 Values files written');
|
|
64
16
|
this.writeAssets(validatedOutDir, assets);
|
|
17
|
+
console.log('📝 Assets written');
|
|
65
18
|
this.writeHelpers(validatedOutDir, helpersTpl);
|
|
66
19
|
this.writeNotes(validatedOutDir, notesTpl);
|
|
67
20
|
this.writeSchema(validatedOutDir, valuesSchema);
|
|
68
21
|
this.writeHelmIgnore(validatedOutDir);
|
|
22
|
+
console.log('📝 HelmChartWriter.write completed');
|
|
69
23
|
}
|
|
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
24
|
static createDirectories(outDir) {
|
|
79
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
80
25
|
fs.mkdirSync(path.join(outDir, 'templates'), { recursive: true });
|
|
81
|
-
// Create crds directory only if needed later
|
|
82
26
|
}
|
|
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
27
|
static writeChartYaml(outDir, meta) {
|
|
93
28
|
const chartYaml = YAML.stringify({
|
|
94
29
|
apiVersion: 'v2',
|
|
@@ -105,48 +40,18 @@ export class HelmChartWriter {
|
|
|
105
40
|
icon: meta.icon,
|
|
106
41
|
dependencies: meta.dependencies,
|
|
107
42
|
});
|
|
108
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
109
43
|
fs.writeFileSync(path.join(outDir, 'Chart.yaml'), chartYaml);
|
|
110
44
|
}
|
|
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
45
|
static writeValuesFiles(outDir, defaultValues, envValues) {
|
|
122
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
123
46
|
fs.writeFileSync(path.join(outDir, 'values.yaml'), YAML.stringify(defaultValues));
|
|
124
47
|
for (const [env, values] of Object.entries(envValues)) {
|
|
125
|
-
// Use centralized environment name sanitization
|
|
126
48
|
const sanitizedEnv = SecurityUtils.sanitizeEnvironmentName(env);
|
|
127
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
128
49
|
fs.writeFileSync(path.join(outDir, `values-${sanitizedEnv}.yaml`), YAML.stringify(values));
|
|
129
50
|
}
|
|
130
51
|
}
|
|
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
52
|
static writeAssets(outDir, assets) {
|
|
140
53
|
writeAssets(outDir, assets);
|
|
141
54
|
}
|
|
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
55
|
static writeHelpers(outDir, helpersTpl) {
|
|
151
56
|
if (!helpersTpl)
|
|
152
57
|
return;
|
|
@@ -159,47 +64,20 @@ export class HelmChartWriter {
|
|
|
159
64
|
.map((h) => [`{{- define "${h.name}" -}}`, h.body.trimEnd(), '{{- end }}', ''].join('\n'))
|
|
160
65
|
.join('\n');
|
|
161
66
|
}
|
|
162
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
163
67
|
fs.writeFileSync(path.join(outDir, 'templates', '_helpers.tpl'), content);
|
|
164
68
|
}
|
|
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
69
|
static writeNotes(outDir, notesTpl) {
|
|
174
70
|
if (!notesTpl)
|
|
175
71
|
return;
|
|
176
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
177
72
|
fs.writeFileSync(path.join(outDir, 'templates', 'NOTES.txt'), notesTpl.endsWith('\n') ? notesTpl : notesTpl + '\n');
|
|
178
73
|
}
|
|
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
74
|
static writeSchema(outDir, valuesSchema) {
|
|
188
75
|
if (!valuesSchema)
|
|
189
76
|
return;
|
|
190
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
191
77
|
fs.writeFileSync(path.join(outDir, 'values.schema.json'), JSON.stringify(valuesSchema, null, 2) + '\n');
|
|
192
78
|
}
|
|
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
79
|
static writeHelmIgnore(outDir) {
|
|
201
80
|
const helmIgnorePath = path.join(outDir, '.helmignore');
|
|
202
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
203
81
|
if (!fs.existsSync(helmIgnorePath)) {
|
|
204
82
|
const helmIgnore = [
|
|
205
83
|
'# VCS',
|
|
@@ -223,42 +101,31 @@ export class HelmChartWriter {
|
|
|
223
101
|
'*.tgz',
|
|
224
102
|
'',
|
|
225
103
|
].join('\n');
|
|
226
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
227
104
|
fs.writeFileSync(helmIgnorePath, helmIgnore);
|
|
228
105
|
}
|
|
229
106
|
}
|
|
230
107
|
}
|
|
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
108
|
function splitDocs(yamlStr) {
|
|
240
109
|
return yamlStr
|
|
241
110
|
.split(/^---\s*$/m)
|
|
242
111
|
.map((p) => p.trim())
|
|
243
112
|
.filter((p) => p.length);
|
|
244
113
|
}
|
|
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
114
|
function writeAssets(outDir, assets) {
|
|
115
|
+
console.log('🔍 writeAssets called with', assets.length, 'assets');
|
|
255
116
|
for (const asset of assets) {
|
|
256
|
-
// Sanitize asset ID to prevent path traversal
|
|
257
117
|
const sanitizedId = asset.id.replace(/[^a-zA-Z0-9-_]/g, '');
|
|
258
118
|
if (sanitizedId !== asset.id) {
|
|
259
119
|
throw new Error(`Invalid asset ID: ${SecurityUtils.sanitizeLogMessage(asset.id)}`);
|
|
260
120
|
}
|
|
261
121
|
const targetDir = getTargetDirectory(asset.target);
|
|
122
|
+
console.log(`🔍 Processing asset: ${asset.id} -> ${sanitizedId}, singleFile: ${asset.singleFile}, target: ${asset.target}`);
|
|
123
|
+
if (asset.id === 'ingress') {
|
|
124
|
+
console.log('🔍 Ingress asset YAML preview:', asset.yaml.substring(0, 200));
|
|
125
|
+
if (asset.yaml.includes('number:')) {
|
|
126
|
+
console.log('🔍 Ingress contains number field:', asset.yaml.split('\n').filter((line) => line.includes('number:')));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
262
129
|
if (asset.singleFile) {
|
|
263
130
|
writeSingleAssetFile(outDir, targetDir, sanitizedId, asset.yaml);
|
|
264
131
|
}
|
|
@@ -267,52 +134,32 @@ function writeAssets(outDir, assets) {
|
|
|
267
134
|
}
|
|
268
135
|
}
|
|
269
136
|
}
|
|
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
137
|
function getTargetDirectory(target) {
|
|
279
138
|
return target === 'crds' ? 'crds' : 'templates';
|
|
280
139
|
}
|
|
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
140
|
function writeSingleAssetFile(outDir, targetDir, assetId, yaml) {
|
|
141
|
+
if (assetId === 'ingress' && yaml.includes('number:')) {
|
|
142
|
+
console.log('🔍 Writing ingress file with content:');
|
|
143
|
+
const numberLines = yaml.split('\n').filter((line) => line.includes('number:'));
|
|
144
|
+
console.log('Number lines:', numberLines);
|
|
145
|
+
}
|
|
292
146
|
const filename = `${assetId}.yaml`;
|
|
293
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Chart writer needs dynamic paths
|
|
294
147
|
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
148
|
fs.writeFileSync(path.join(outDir, targetDir, filename), yaml + '\n');
|
|
297
149
|
}
|
|
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
150
|
function writeMultipleAssetFiles(outDir, targetDir, assetId, yaml) {
|
|
151
|
+
if (assetId === 'ingress' && yaml.includes('number:')) {
|
|
152
|
+
console.log('🔍 Writing ingress file (multiple) with content:');
|
|
153
|
+
const numberLines = yaml.split('\n').filter((line) => line.includes('number:'));
|
|
154
|
+
console.log('Number lines:', numberLines);
|
|
155
|
+
}
|
|
309
156
|
const parts = splitDocs(yaml);
|
|
310
157
|
parts.forEach((doc, index) => {
|
|
311
158
|
const filename = `${assetId}${parts.length > 1 ? `-${index + 1}` : ''}.yaml`;
|
|
312
|
-
|
|
159
|
+
if (assetId === 'ingress' && doc.includes('number:')) {
|
|
160
|
+
console.log(`🔍 Writing document ${index + 1} for ingress:`, doc.split('\n').filter((line) => line.includes('number:')));
|
|
161
|
+
}
|
|
313
162
|
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
163
|
fs.writeFileSync(path.join(outDir, targetDir, filename), doc + '\n');
|
|
316
164
|
});
|
|
317
165
|
}
|
|
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
|