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.
Files changed (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli.d.ts +0 -1
  3. package/dist/cli.js +274 -634
  4. package/dist/index.d.ts +4 -6
  5. package/dist/index.js +4 -7
  6. package/dist/lib/helm.d.ts +0 -472
  7. package/dist/lib/helm.js +0 -481
  8. package/dist/lib/helmChartWriter.d.ts +0 -178
  9. package/dist/lib/helmChartWriter.js +27 -180
  10. package/dist/lib/resources/baseResourceProvider.d.ts +0 -46
  11. package/dist/lib/resources/baseResourceProvider.js +1 -47
  12. package/dist/lib/resources/cloud/aws/awsResources.d.ts +0 -144
  13. package/dist/lib/resources/cloud/aws/awsResources.js +1 -163
  14. package/dist/lib/resources/cloud/aws/karpenterResources.d.ts +0 -132
  15. package/dist/lib/resources/cloud/aws/karpenterResources.js +0 -75
  16. package/dist/lib/rutter.d.ts +28 -340
  17. package/dist/lib/rutter.js +291 -371
  18. package/dist/lib/security.d.ts +0 -119
  19. package/dist/lib/security.js +4 -160
  20. package/dist/lib/templates/basic-chart.d.ts +19 -0
  21. package/dist/lib/templates/basic-chart.js +189 -0
  22. package/dist/lib/templates/subchart.d.ts +27 -0
  23. package/dist/lib/templates/subchart.js +224 -0
  24. package/dist/lib/templates/umbrella-chart.d.ts +13 -0
  25. package/dist/lib/templates/umbrella-chart.js +222 -0
  26. package/dist/lib/types.d.ts +20 -0
  27. package/dist/lib/types.js +1 -0
  28. package/dist/lib/umbrella.d.ts +0 -24
  29. package/dist/lib/umbrella.js +0 -24
  30. package/dist/lib/umbrellaRutter.d.ts +0 -71
  31. package/dist/lib/umbrellaRutter.js +2 -82
  32. package/dist/lib/utils/helmHelpers.d.ts +18 -41
  33. package/dist/lib/utils/helmHelpers.js +246 -35
  34. package/package.json +9 -7
  35. package/README.md +0 -74
  36. package/dist/cli.d.ts.map +0 -1
  37. package/dist/cli.js.map +0 -1
  38. package/dist/index.d.ts.map +0 -1
  39. package/dist/index.js.map +0 -1
  40. package/dist/lib/helm.d.ts.map +0 -1
  41. package/dist/lib/helm.js.map +0 -1
  42. package/dist/lib/helmChartWriter.d.ts.map +0 -1
  43. package/dist/lib/helmChartWriter.js.map +0 -1
  44. package/dist/lib/resources/baseResourceProvider.d.ts.map +0 -1
  45. package/dist/lib/resources/baseResourceProvider.js.map +0 -1
  46. package/dist/lib/resources/cloud/aws/awsResources.d.ts.map +0 -1
  47. package/dist/lib/resources/cloud/aws/awsResources.js.map +0 -1
  48. package/dist/lib/resources/cloud/aws/karpenterResources.d.ts.map +0 -1
  49. package/dist/lib/resources/cloud/aws/karpenterResources.js.map +0 -1
  50. package/dist/lib/rutter.d.ts.map +0 -1
  51. package/dist/lib/rutter.js.map +0 -1
  52. package/dist/lib/security.d.ts.map +0 -1
  53. package/dist/lib/security.js.map +0 -1
  54. package/dist/lib/umbrella.d.ts.map +0 -1
  55. package/dist/lib/umbrella.js.map +0 -1
  56. package/dist/lib/umbrellaRutter.d.ts.map +0 -1
  57. package/dist/lib/umbrellaRutter.js.map +0 -1
  58. package/dist/lib/utils/helmHelpers.d.ts.map +0 -1
  59. package/dist/lib/utils/helmHelpers.js.map +0 -1
package/dist/lib/helm.js CHANGED
@@ -1,152 +1,33 @@
1
- /**
2
- * @fileoverview Helpers to embed Helm template expressions while staying type-safe in TypeScript.
3
- * We treat Helm placeholders as opaque strings that will be preserved in YAML.
4
- * @since 0.1.0
5
- */
6
1
  import { SecurityUtils } from './security.js';
7
- /**
8
- * Creates a reference to a value in .Values of Helm
9
- *
10
- * Generates a Helm template expression that references a value
11
- * in the chart's values.yaml file using dot notation.
12
- *
13
- * @param {string} path - Path to the value using dot notation (e.g., 'image.tag')
14
- * @returns {string} Helm template expression (e.g., '{{ .Values.image.tag }}')
15
- * @throws {Error} If the path is not valid for Helm templates
16
- *
17
- * @example
18
- * ```typescript
19
- * const imageTag = valuesRef('image.tag');
20
- * // Returns: '{{ .Values.image.tag }}'
21
- *
22
- * const replicas = valuesRef('deployment.replicas');
23
- * // Returns: '{{ .Values.deployment.replicas }}'
24
- * ```
25
- *
26
- * @since 0.1.0
27
- */
28
2
  export function valuesRef(path) {
29
3
  if (!isValidHelmPath(path)) {
30
4
  throw new Error(`Invalid Helm template path: ${path}`);
31
5
  }
32
6
  return `{{ .Values.${path} }}`;
33
7
  }
34
- /**
35
- * Creates a required reference to a value in .Values of Helm
36
- *
37
- * Similar to valuesRef, but uses Helm's 'required' function to
38
- * ensure the value is present, failing chart rendering if not provided.
39
- *
40
- * @param {string} path - Path to the value using dot notation
41
- * @param {string} [message] - Custom error message if value is missing
42
- * @returns {string} Helm template expression with required validation
43
- * @throws {Error} If the path is not valid for Helm templates
44
- *
45
- * @example
46
- * ```typescript
47
- * const dbPassword = requiredValuesRef('database.password', 'Database password is required');
48
- * // Returns: '{{ required "Database password is required" .Values.database.password }}'
49
- *
50
- * const apiKey = requiredValuesRef('api.key');
51
- * // Returns: '{{ required "api.key is required" .Values.api.key }}'
52
- * ```
53
- *
54
- * @since 0.1.0
55
- */
56
8
  export function requiredValuesRef(path, message) {
57
9
  if (!isValidHelmPath(path)) {
58
10
  throw new Error(`Invalid Helm template path: ${path}`);
59
11
  }
60
12
  const msg = message ?? `${path} is required`;
61
- // Escape quotes and backslashes in message to prevent template injection
62
13
  const escapedMsg = msg.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
63
14
  return `{{ required "${escapedMsg}" .Values.${path} }}`;
64
15
  }
65
- /**
66
- * Validates Helm template path syntax with enhanced security
67
- *
68
- * @private
69
- * @param {string} path - Path to validate
70
- * @returns {boolean} True if path is valid for Helm templates
71
- * @since 0.1.0
72
- */
73
16
  function isValidHelmPath(path) {
74
- // Use centralized validation from SecurityUtils
75
17
  return SecurityUtils.isValidHelmTemplatePath(path);
76
18
  }
77
- /**
78
- * Built-in Helm references for release and chart metadata
79
- *
80
- * Object containing the most common references to Helm's built-in
81
- * variables for release and chart information.
82
- *
83
- * @namespace helm
84
- * @since 0.1.0
85
- *
86
- * @example
87
- * ```typescript
88
- * const deploymentName = `${helm.releaseName}-deployment`;
89
- * // Uses: '{{ .Release.Name }}-deployment'
90
- *
91
- * const version = helm.chartVersion;
92
- * // Uses: '{{ .Chart.Version }}'
93
- * ```
94
- */
95
19
  export const helm = {
96
- /** Release name: {{ .Release.Name }} */
97
20
  releaseName: '{{ .Release.Name }}',
98
- /** Chart name: {{ .Chart.Name }} */
99
21
  chartName: '{{ .Chart.Name }}',
100
- /** Chart version: {{ .Chart.Version }} */
101
22
  chartVersion: '{{ .Chart.Version }}',
102
- /** Release namespace: {{ .Release.Namespace }} */
103
23
  namespace: '{{ .Release.Namespace }}',
104
24
  };
105
- /**
106
- * Quotes a Helm template expression for safe YAML embedding
107
- *
108
- * Ensures Helm template expressions are properly quoted to avoid
109
- * YAML parsing issues when the expression contains special characters.
110
- *
111
- * @param {string} expr - Helm template expression to quote
112
- * @returns {string} Quoted expression if it's a Helm template, otherwise unchanged
113
- *
114
- * @example
115
- * ```typescript
116
- * const quoted = quote('{{ .Values.image.tag }}');
117
- * // Returns: "'{{ .Values.image.tag }}'"
118
- *
119
- * const normal = quote('nginx:1.21');
120
- * // Returns: "nginx:1.21"
121
- * ```
122
- *
123
- * @since 0.1.0
124
- */
125
25
  export function quote(expr) {
126
- // ensure Helm templates are quoted to avoid YAML parsing issues
127
26
  if (expr.startsWith('{{') && expr.endsWith('}}')) {
128
27
  return `'${expr}'`;
129
28
  }
130
29
  return expr;
131
30
  }
132
- /**
133
- * Indents text by specified number of spaces
134
- *
135
- * Helper function that matches Helm's indent function behavior,
136
- * adding the specified number of spaces to each non-empty line.
137
- *
138
- * @param {number} n - Number of spaces to indent
139
- * @param {string} expr - Text to indent
140
- * @returns {string} Indented text
141
- *
142
- * @example
143
- * ```typescript
144
- * const indented = indent(4, 'line1\nline2');
145
- * // Returns: " line1\n line2"
146
- * ```
147
- *
148
- * @since 0.1.0
149
- */
150
31
  export function indent(n, expr) {
151
32
  const spaces = ' '.repeat(n);
152
33
  return expr
@@ -154,59 +35,17 @@ export function indent(n, expr) {
154
35
  .map((l) => (l.trim().length ? spaces + l : l))
155
36
  .join('\n');
156
37
  }
157
- /**
158
- * Inserts a call to a named Helm template using template function
159
- *
160
- * @param {string} name - Name of the template to call
161
- * @param {string} [context='.'] - Context to pass to the template
162
- * @returns {string} Helm template expression
163
- *
164
- * @example
165
- * ```typescript
166
- * const tmpl = template('myapp.labels');
167
- * // Returns: '{{ template "myapp.labels" . }}'
168
- * ```
169
- *
170
- * @since 0.1.0
171
- */
172
38
  export function template(name, context = '.') {
173
39
  return `{{ template "${name}" ${context} }}`;
174
40
  }
175
- /**
176
- * Inserts a call to a named Helm template using include function
177
- *
178
- * Preferred over template() as include allows piping and better error handling.
179
- *
180
- * @param {string} name - Name of the template to include
181
- * @param {string} [context='.'] - Context to pass to the template
182
- * @returns {string} Helm template expression
183
- *
184
- * @example
185
- * ```typescript
186
- * const tmpl = include('myapp.labels');
187
- * // Returns: '{{ include "myapp.labels" . }}'
188
- * ```
189
- *
190
- * @since 0.1.0
191
- */
192
41
  export function include(name, context = '.') {
193
42
  return `{{ include "${name}" ${context} }}`;
194
43
  }
195
- /**
196
- * Factory function to create typed Helm value references with reduced code duplication
197
- * @param path - The path to the value in the Helm values
198
- * @param type - The expected type of the value
199
- * @param options - Additional options for reference creation
200
- * @returns A string that can be used in Helm templates
201
- * @throws {Error} If the path is invalid
202
- * @since 1.1.0
203
- */
204
44
  export function createTypedRef(path, type, options = {}) {
205
45
  if (!isValidHelmPath(path)) {
206
46
  throw new Error(`Invalid Helm template path: ${path}`);
207
47
  }
208
48
  let template = `{{ .Values.${path}`;
209
- // Apply type casting based on type
210
49
  switch (type) {
211
50
  case 'number':
212
51
  template += ' | int';
@@ -221,119 +60,31 @@ export function createTypedRef(path, type, options = {}) {
221
60
  template += ' | float64';
222
61
  break;
223
62
  }
224
- // Handle default values following Helm best practices
225
63
  if (options.withDefault && options.defaultValue !== undefined) {
226
64
  const defaultVal = typeof options.defaultValue === 'string' && options.quote
227
65
  ? `"${options.defaultValue}"`
228
66
  : String(options.defaultValue);
229
67
  template += ` | default ${defaultVal}`;
230
68
  }
231
- // Handle string quoting for security
232
69
  if (type === 'string' && options.quote && !options.withDefault) {
233
70
  template += ' | quote';
234
71
  }
235
72
  template += ' }}';
236
73
  return template;
237
74
  }
238
- /**
239
- * Creates a numeric reference from .Values with int cast
240
- *
241
- * Generates a Helm template expression that casts the value to integer,
242
- * truncating any decimal places.
243
- *
244
- * @param {string} path - Path to the value using dot notation
245
- * @param {TypedRefOptions} [options] - Additional options for reference creation
246
- * @returns {string} Helm template expression with int cast
247
- * @throws {Error} If the path is not valid for Helm templates
248
- *
249
- * @example
250
- * ```typescript
251
- * const replicas = numberRef('deployment.replicas');
252
- * // Returns: '{{ .Values.deployment.replicas | int }}'
253
- * ```
254
- *
255
- * @since 0.1.0
256
- */
257
75
  export function numberRef(path, options) {
258
76
  return createTypedRef(path, 'number', options);
259
77
  }
260
- /**
261
- * Creates a boolean reference from .Values with toBool cast
262
- *
263
- * @param {string} path - Path to the value using dot notation
264
- * @param {TypedRefOptions} [options] - Additional options for reference creation
265
- * @returns {string} Helm template expression with toBool cast
266
- * @throws {Error} If the path is not valid for Helm templates
267
- *
268
- * @example
269
- * ```typescript
270
- * const enabled = boolRef('feature.enabled');
271
- * // Returns: '{{ .Values.feature.enabled | toBool }}'
272
- * ```
273
- *
274
- * @since 0.1.0
275
- */
276
78
  export function boolRef(path, options) {
277
79
  return createTypedRef(path, 'boolean', options);
278
80
  }
279
- /**
280
- * Creates a string reference from .Values with toString cast
281
- *
282
- * @param {string} path - Path to the value using dot notation
283
- * @param {TypedRefOptions} [options] - Additional options for reference creation
284
- * @returns {string} Helm template expression with toString cast
285
- * @throws {Error} If the path is not valid for Helm templates
286
- *
287
- * @example
288
- * ```typescript
289
- * const version = stringRef('app.version');
290
- * // Returns: '{{ .Values.app.version | toString }}'
291
- * ```
292
- *
293
- * @since 0.1.0
294
- */
295
81
  export function stringRef(path, options) {
296
82
  const defaultOptions = { quote: true, ...options };
297
83
  return createTypedRef(path, 'string', defaultOptions);
298
84
  }
299
- /**
300
- * Creates a float reference from .Values with float64 cast
301
- *
302
- * @param {string} path - Path to the value using dot notation
303
- * @param {TypedRefOptions} [options] - Additional options for reference creation
304
- * @returns {string} Helm template expression with float64 cast
305
- * @throws {Error} If the path is not valid for Helm templates
306
- *
307
- * @example
308
- * ```typescript
309
- * const ratio = floatRef('scaling.ratio');
310
- * // Returns: '{{ .Values.scaling.ratio | float64 }}'
311
- * ```
312
- *
313
- * @since 0.1.0
314
- */
315
85
  export function floatRef(path, options) {
316
86
  return createTypedRef(path, 'float', options);
317
87
  }
318
- /**
319
- * Creates a conditional reference to a value in .Values
320
- *
321
- * Generates a Helm template expression that conditionally renders
322
- * the value only if the condition is truthy.
323
- *
324
- * @param {string} path - Path to the value using dot notation
325
- * @param {string} condition - Path to the condition value
326
- * @returns {string} Helm template expression with conditional logic
327
- * @throws {Error} If the path or condition is not valid for Helm templates
328
- *
329
- * @example
330
- * ```typescript
331
- * const secretName = conditionalRef('database.secretName', 'database.enabled');
332
- * // Returns: '{{ if .Values.database.enabled }}{{ .Values.database.secretName }}{{ end }}'
333
- * ```
334
- *
335
- * @since 2.6.0
336
- */
337
88
  export function conditionalRef(path, condition) {
338
89
  if (!isValidHelmPath(path)) {
339
90
  throw new Error(`Invalid Helm template path: ${path}`);
@@ -343,165 +94,38 @@ export function conditionalRef(path, condition) {
343
94
  }
344
95
  return `{{ if .Values.${condition} }}{{ .Values.${path} }}{{ end }}`;
345
96
  }
346
- /**
347
- * Wraps a complete YAML manifest in a Helm conditional
348
- *
349
- * Generates a Helm template that conditionally renders an entire
350
- * Kubernetes manifest based on a values condition.
351
- *
352
- * @param {string} yamlContent - Complete YAML manifest content
353
- * @param {string} condition - Path to the condition value
354
- * @returns {string} YAML content wrapped in Helm conditional
355
- * @throws {Error} If the condition path is not valid for Helm templates
356
- *
357
- * @example
358
- * ```typescript
359
- * const namespaceYaml = `
360
- * apiVersion: v1
361
- * kind: Namespace
362
- * metadata:
363
- * name: my-namespace
364
- * `;
365
- * const conditionalNamespace = conditionalManifest(namespaceYaml, 'createNamespace');
366
- * // Returns: '{{ if .Values.createNamespace }}\napiVersion: v1\nkind: Namespace...{{ end }}'
367
- * ```
368
- *
369
- * @since 2.7.4
370
- */
371
97
  export function conditionalManifest(yamlContent, condition) {
372
98
  if (!isValidHelmPath(condition)) {
373
99
  throw new Error(`Invalid Helm template condition path: ${condition}`);
374
100
  }
375
- // Remove leading/trailing whitespace and ensure proper formatting
376
101
  const cleanYaml = yamlContent.trim();
377
102
  return `{{ if .Values.${condition} }}
378
103
  ${cleanYaml}
379
104
  {{ end }}`;
380
105
  }
381
- /**
382
- * Creates a reference to a value in .Values with a default fallback
383
- *
384
- * Generates a Helm template expression that uses the default filter
385
- * to provide a fallback value when the path is not set.
386
- *
387
- * @param {string} path - Path to the value using dot notation
388
- * @param {string} defaultValue - Default value to use if path is not set
389
- * @returns {string} Helm template expression with default fallback
390
- * @throws {Error} If the path is not valid for Helm templates
391
- *
392
- * @example
393
- * ```typescript
394
- * const image = defaultRef('image.tag', 'latest');
395
- * // Returns: '{{ .Values.image.tag | default "latest" }}'
396
- * ```
397
- *
398
- * @since 2.6.0
399
- */
400
106
  export function defaultRef(path, defaultValue) {
401
107
  if (!isValidHelmPath(path)) {
402
108
  throw new Error(`Invalid Helm template path: ${path}`);
403
109
  }
404
- // Escape quotes and backslashes in defaultValue to prevent template injection
405
110
  const escapedValue = defaultValue.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
406
111
  return `{{ .Values.${path} | default "${escapedValue}" }}`;
407
112
  }
408
- /**
409
- * Creates a base64-encoded reference to a value in .Values
410
- *
411
- * Generates a Helm template expression that encodes the value
412
- * using base64 encoding, useful for secrets and certificates.
413
- *
414
- * @param {string} path - Path to the value using dot notation
415
- * @returns {string} Helm template expression with base64 encoding
416
- * @throws {Error} If the path is not valid for Helm templates
417
- *
418
- * @example
419
- * ```typescript
420
- * const encodedSecret = base64Ref('secrets.apiKey');
421
- * // Returns: '{{ .Values.secrets.apiKey | b64enc }}'
422
- * ```
423
- *
424
- * @since 2.6.0
425
- */
426
113
  export function base64Ref(path) {
427
114
  if (!isValidHelmPath(path)) {
428
115
  throw new Error(`Invalid Helm template path: ${path}`);
429
116
  }
430
117
  return `{{ .Values.${path} | b64enc }}`;
431
118
  }
432
- /**
433
- * Creates a JSON-serialized reference to a value in .Values
434
- *
435
- * Generates a Helm template expression that serializes the value
436
- * to JSON format, useful for complex configuration objects.
437
- *
438
- * @param {string} path - Path to the value using dot notation
439
- * @returns {string} Helm template expression with JSON serialization
440
- * @throws {Error} If the path is not valid for Helm templates
441
- *
442
- * @example
443
- * ```typescript
444
- * const configJson = jsonRef('app.config');
445
- * // Returns: '{{ .Values.app.config | toJson }}'
446
- * ```
447
- *
448
- * @since 2.6.0
449
- */
450
119
  export function jsonRef(path) {
451
120
  if (!isValidHelmPath(path)) {
452
121
  throw new Error(`Invalid Helm template path: ${path}`);
453
122
  }
454
123
  return `{{ .Values.${path} | toJson }}`;
455
124
  }
456
- /**
457
- * Flow Control Functions for Helm Templates
458
- *
459
- * These functions provide programmatic access to Helm's flow control structures:
460
- * if/else, with, and range for conditional logic and iteration.
461
- *
462
- * @since 1.4.0
463
- */
464
- /**
465
- * Creates a conditional if block in Helm templates
466
- *
467
- * Generates Helm template expressions for conditional logic using if/else/end.
468
- * Supports complex conditions with comparison operators and pipeline expressions.
469
- *
470
- * @param {string} condition - The condition to evaluate (e.g., 'eq .Values.env "production"')
471
- * @param {string} content - Content to include when condition is true
472
- * @param {string} [elseContent] - Optional content for else block
473
- * @returns {string} Complete Helm if/else template block
474
- * @throws {Error} If condition contains potentially unsafe template expressions
475
- *
476
- * @example
477
- * ```typescript
478
- * const conditionalConfig = helmIf(
479
- * 'eq .Values.environment "production"',
480
- * 'replicas: 3\nresources:\n limits:\n memory: "1Gi"',
481
- * 'replicas: 1\nresources:\n limits:\n memory: "512Mi"'
482
- * );
483
- * // Returns:
484
- * // {{- if eq .Values.environment "production" }}
485
- * // replicas: 3
486
- * // resources:
487
- * // limits:
488
- * // memory: "1Gi"
489
- * // {{- else }}
490
- * // replicas: 1
491
- * // resources:
492
- * // limits:
493
- * // memory: "512Mi"
494
- * // {{- end }}
495
- * ```
496
- *
497
- * @since 2.8.0
498
- */
499
125
  export function helmIf(condition, content, elseContent) {
500
- // Validate condition for basic security
501
126
  if (!condition || condition.trim().length === 0) {
502
127
  throw new Error('Condition cannot be empty');
503
128
  }
504
- // Basic validation to prevent template injection
505
129
  if (condition.includes('{{') || condition.includes('}}')) {
506
130
  throw new Error('Condition should not contain template delimiters');
507
131
  }
@@ -512,44 +136,10 @@ export function helmIf(condition, content, elseContent) {
512
136
  result += `\n{{- end }}`;
513
137
  return result;
514
138
  }
515
- /**
516
- * Creates a with block for scoped template context
517
- *
518
- * Generates Helm template expressions using 'with' to change the template context.
519
- * Useful for accessing nested values without repeating the full path.
520
- *
521
- * @param {string} path - Path to set as new context (e.g., '.Values.database')
522
- * @param {string} content - Content to render within the new context
523
- * @param {string} [elseContent] - Optional content when path is empty/nil
524
- * @returns {string} Complete Helm with/else/end template block
525
- * @throws {Error} If path is not valid for Helm templates
526
- *
527
- * @example
528
- * ```typescript
529
- * const dbConfig = helmWith(
530
- * '.Values.database',
531
- * 'host: {{ .host }}\nport: {{ .port }}\nname: {{ .name }}',
532
- * 'host: "localhost"\nport: 5432\nname: "defaultdb"'
533
- * );
534
- * // Returns:
535
- * // {{- with .Values.database }}
536
- * // host: {{ .host }}
537
- * // port: {{ .port }}
538
- * // name: {{ .name }}
539
- * // {{- else }}
540
- * // host: "localhost"
541
- * // port: 5432
542
- * // name: "defaultdb"
543
- * // {{- end }}
544
- * ```
545
- *
546
- * @since 2.8.0
547
- */
548
139
  export function helmWith(path, content, elseContent) {
549
140
  if (!path || path.trim().length === 0) {
550
141
  throw new Error('Path cannot be empty');
551
142
  }
552
- // Validate path format
553
143
  if (!path.startsWith('.')) {
554
144
  throw new Error('Path must start with "." (e.g., ".Values.config")');
555
145
  }
@@ -560,48 +150,6 @@ export function helmWith(path, content, elseContent) {
560
150
  result += `\n{{- end }}`;
561
151
  return result;
562
152
  }
563
- /**
564
- * Creates a range loop for iterating over collections
565
- *
566
- * Generates Helm template expressions using 'range' to iterate over lists, maps, or other collections.
567
- * Supports both simple iteration and key-value iteration for maps.
568
- *
569
- * @param {string} collection - Collection to iterate over (e.g., '.Values.items')
570
- * @param {string} content - Content template for each iteration
571
- * @param {object} [options] - Configuration options for the range loop
572
- * @param {boolean} [options.keyValue=false] - Whether to iterate with key-value pairs
573
- * @param {string} [options.keyVar='$key'] - Variable name for keys in key-value iteration
574
- * @param {string} [options.valueVar='$value'] - Variable name for values in key-value iteration
575
- * @param {string} [options.indexVar='$index'] - Variable name for index in indexed iteration
576
- * @param {string} [options.itemVar='$item'] - Variable name for items in simple iteration
577
- * @returns {string} Complete Helm range/end template block
578
- * @throws {Error} If collection path is not valid
579
- *
580
- * @example
581
- * ```typescript
582
- * // Simple list iteration
583
- * const serviceList = helmRange(
584
- * '.Values.services',
585
- * '- name: {{ .name }}\n port: {{ .port }}'
586
- * );
587
- *
588
- * // Key-value map iteration
589
- * const envVars = helmRange(
590
- * '.Values.env',
591
- * '- name: {{ $key }}\n value: {{ $value | quote }}',
592
- * { keyValue: true }
593
- * );
594
- *
595
- * // Indexed iteration
596
- * const indexedItems = helmRange(
597
- * '.Values.items',
598
- * '{{ $index }}: {{ $item }}',
599
- * { indexVar: '$i', itemVar: '$val' }
600
- * );
601
- * ```
602
- *
603
- * @since 2.8.0
604
- */
605
153
  export function helmRange(collection, content, options = {}) {
606
154
  if (!collection || collection.trim().length === 0) {
607
155
  throw new Error('Collection cannot be empty');
@@ -622,33 +170,6 @@ export function helmRange(collection, content, options = {}) {
622
170
  }
623
171
  return `${rangeExpression}\n${content}\n{{- end }}`;
624
172
  }
625
- /**
626
- * Creates a complex conditional with multiple else-if branches
627
- *
628
- * Generates Helm template expressions for complex conditional logic with multiple branches.
629
- * Useful for handling multiple environment configurations or feature flags.
630
- *
631
- * @param {Array<{condition: string, content: string}>} branches - Array of condition-content pairs
632
- * @param {string} [defaultContent] - Default content when no conditions match
633
- * @returns {string} Complete Helm if/else-if/else/end template block
634
- * @throws {Error} If branches array is empty or contains invalid conditions
635
- *
636
- * @example
637
- * ```typescript
638
- * const envConfig = helmIfElseIf([
639
- * {
640
- * condition: 'eq .Values.environment "production"',
641
- * content: 'replicas: 5\nresources.limits.memory: "2Gi"'
642
- * },
643
- * {
644
- * condition: 'eq .Values.environment "staging"',
645
- * content: 'replicas: 2\nresources.limits.memory: "1Gi"'
646
- * }
647
- * ], 'replicas: 1\nresources.limits.memory: "512Mi"');
648
- * ```
649
- *
650
- * @since 2.8.0
651
- */
652
173
  export function helmIfElseIf(branches, defaultContent) {
653
174
  if (!branches || branches.length === 0) {
654
175
  throw new Error('At least one branch is required');
@@ -658,7 +179,6 @@ export function helmIfElseIf(branches, defaultContent) {
658
179
  if (!branch.condition || branch.condition.trim().length === 0) {
659
180
  throw new Error(`Branch ${index} condition cannot be empty`);
660
181
  }
661
- // Basic validation to prevent template injection
662
182
  if (branch.condition.includes('{{') || branch.condition.includes('}}')) {
663
183
  throw new Error(`Branch ${index} condition should not contain template delimiters`);
664
184
  }
@@ -671,4 +191,3 @@ export function helmIfElseIf(branches, defaultContent) {
671
191
  result += '{{- end }}';
672
192
  return result;
673
193
  }
674
- //# sourceMappingURL=helm.js.map