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
@@ -1,27 +1,3 @@
1
- /**
2
- * @fileoverview Umbrella chart utilities for managing multiple subcharts as a single unit
3
- * @since 0.2.0
4
- */
5
1
  import type { UmbrellaRutter, UmbrellaRutterProps } from './umbrellaRutter.js';
6
- /**
7
- * Create an umbrella chart from multiple Rutter instances
8
- *
9
- * @param props - Umbrella chart configuration
10
- * @returns UmbrellaRutter instance for managing subcharts
11
- *
12
- * @example
13
- * ```typescript
14
- * const umbrella = createUmbrella({
15
- * meta: { name: 'my-umbrella', version: '1.0.0' },
16
- * subcharts: [
17
- * { name: 'frontend', rutter: frontendChart },
18
- * { name: 'backend', rutter: backendChart }
19
- * ]
20
- * });
21
- * ```
22
- *
23
- * @since 0.2.0
24
- */
25
2
  export declare function createUmbrella(props: UmbrellaRutterProps): UmbrellaRutter;
26
3
  export type { UmbrellaRutterProps, SubchartSpec } from './umbrellaRutter.js';
27
- //# sourceMappingURL=umbrella.d.ts.map
@@ -1,28 +1,4 @@
1
- /**
2
- * @fileoverview Umbrella chart utilities for managing multiple subcharts as a single unit
3
- * @since 0.2.0
4
- */
5
1
  import { UmbrellaRutter as UmbrellaRutterClass } from './umbrellaRutter.js';
6
- /**
7
- * Create an umbrella chart from multiple Rutter instances
8
- *
9
- * @param props - Umbrella chart configuration
10
- * @returns UmbrellaRutter instance for managing subcharts
11
- *
12
- * @example
13
- * ```typescript
14
- * const umbrella = createUmbrella({
15
- * meta: { name: 'my-umbrella', version: '1.0.0' },
16
- * subcharts: [
17
- * { name: 'frontend', rutter: frontendChart },
18
- * { name: 'backend', rutter: backendChart }
19
- * ]
20
- * });
21
- * ```
22
- *
23
- * @since 0.2.0
24
- */
25
2
  export function createUmbrella(props) {
26
3
  return new UmbrellaRutterClass(props);
27
4
  }
28
- //# sourceMappingURL=umbrella.js.map
@@ -1,97 +1,26 @@
1
- /**
2
- * @fileoverview UmbrellaRutter class for managing Helm umbrella charts with multiple subcharts
3
- * @since 0.2.0
4
- */
5
1
  import type { HelmChartMeta } from './helmChartWriter.js';
6
2
  import type { Rutter } from './rutter.js';
7
- /**
8
- * Configuration for a subchart within an umbrella chart
9
- *
10
- * @since 0.2.0
11
- */
12
3
  export interface SubchartSpec {
13
- /** Name of the subchart */
14
4
  name: string;
15
- /** Rutter instance that generates the subchart */
16
5
  rutter: Rutter;
17
- /** Version of the subchart (optional) */
18
6
  version?: string;
19
- /** Helm condition for enabling/disabling the subchart */
20
7
  condition?: string;
21
- /** Tags for grouping subcharts */
22
8
  tags?: string[];
23
- /** Repository URL for the subchart */
24
9
  repository?: string;
25
10
  }
26
- /**
27
- * Configuration properties for UmbrellaRutter
28
- *
29
- * @since 0.2.0
30
- */
31
11
  export interface UmbrellaRutterProps {
32
- /** Metadata for the umbrella chart */
33
12
  meta: HelmChartMeta;
34
- /** Array of subchart specifications */
35
13
  subcharts: SubchartSpec[];
36
- /** Default values for the umbrella chart */
37
14
  defaultValues?: Record<string, unknown>;
38
- /** Environment-specific values */
39
15
  envValues?: Record<string, Record<string, unknown>>;
40
16
  }
41
- /**
42
- * UmbrellaRutter manages multiple Rutter instances as subcharts
43
- * to create Helm umbrella charts with dependencies.
44
- *
45
- * @example
46
- * ```typescript
47
- * const umbrella = new UmbrellaRutter({
48
- * meta: { name: 'my-app', version: '1.0.0' },
49
- * subcharts: [
50
- * { name: 'frontend', rutter: frontendChart },
51
- * { name: 'backend', rutter: backendChart }
52
- * ]
53
- * });
54
- *
55
- * umbrella.write('./charts/my-app');
56
- * ```
57
- *
58
- * @since 0.2.0
59
- */
60
17
  export declare class UmbrellaRutter {
61
18
  private readonly props;
62
- /**
63
- * Creates a new UmbrellaRutter instance
64
- *
65
- * @param props - Configuration properties for the umbrella chart
66
- * @throws {Error} If chart metadata is invalid
67
- *
68
- * @since 0.2.0
69
- */
70
19
  constructor(props: UmbrellaRutterProps);
71
20
  private validateMetadata;
72
- /**
73
- * Write the umbrella chart with all subcharts to the output directory
74
- *
75
- * Creates the complete umbrella chart structure including:
76
- * - Parent Chart.yaml with dependencies
77
- * - Parent values.yaml with global and subchart values
78
- * - Individual subchart directories under charts/
79
- * - NOTES.txt template
80
- *
81
- * @param outDir - Output directory path for the umbrella chart
82
- * @throws {Error} If output directory path is invalid
83
- *
84
- * @example
85
- * ```typescript
86
- * umbrella.write('./dist/my-umbrella-chart');
87
- * ```
88
- *
89
- * @since 0.2.0
90
- */
91
21
  write(outDir: string): void;
92
22
  private writeParentChart;
93
23
  private writeParentValues;
94
24
  private deepMerge;
95
25
  private generateNotesTemplate;
96
26
  }
97
- //# sourceMappingURL=umbrellaRutter.d.ts.map
@@ -1,101 +1,35 @@
1
- /**
2
- * @fileoverview UmbrellaRutter class for managing Helm umbrella charts with multiple subcharts
3
- * @since 0.2.0
4
- */
5
1
  import { writeFileSync, mkdirSync } from 'fs';
6
2
  import { join } from 'path';
7
3
  import YAML from 'yaml';
8
4
  import { SecurityUtils } from './security.js';
9
- /**
10
- * UmbrellaRutter manages multiple Rutter instances as subcharts
11
- * to create Helm umbrella charts with dependencies.
12
- *
13
- * @example
14
- * ```typescript
15
- * const umbrella = new UmbrellaRutter({
16
- * meta: { name: 'my-app', version: '1.0.0' },
17
- * subcharts: [
18
- * { name: 'frontend', rutter: frontendChart },
19
- * { name: 'backend', rutter: backendChart }
20
- * ]
21
- * });
22
- *
23
- * umbrella.write('./charts/my-app');
24
- * ```
25
- *
26
- * @since 0.2.0
27
- */
28
5
  export class UmbrellaRutter {
29
- /**
30
- * Creates a new UmbrellaRutter instance
31
- *
32
- * @param props - Configuration properties for the umbrella chart
33
- * @throws {Error} If chart metadata is invalid
34
- *
35
- * @since 0.2.0
36
- */
37
6
  constructor(props) {
38
- // Validate chart metadata
39
7
  this.validateMetadata(props.meta);
40
8
  this.props = props;
41
9
  }
42
10
  validateMetadata(meta) {
43
- // Validate chart name follows Helm conventions
44
- // eslint-disable-next-line security/detect-unsafe-regex -- Safe regex for chart name validation
45
11
  if (!/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/.test(meta.name)) {
46
12
  throw new Error('Chart name must contain only lowercase letters, numbers, and dashes');
47
13
  }
48
- // Validate semantic versioning
49
- // eslint-disable-next-line security/detect-unsafe-regex -- Safe regex for semver validation
50
14
  if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(meta.version)) {
51
15
  throw new Error('Chart version must follow semantic versioning (e.g., 1.0.0)');
52
16
  }
53
17
  }
54
- /**
55
- * Write the umbrella chart with all subcharts to the output directory
56
- *
57
- * Creates the complete umbrella chart structure including:
58
- * - Parent Chart.yaml with dependencies
59
- * - Parent values.yaml with global and subchart values
60
- * - Individual subchart directories under charts/
61
- * - NOTES.txt template
62
- *
63
- * @param outDir - Output directory path for the umbrella chart
64
- * @throws {Error} If output directory path is invalid
65
- *
66
- * @example
67
- * ```typescript
68
- * umbrella.write('./dist/my-umbrella-chart');
69
- * ```
70
- *
71
- * @since 0.2.0
72
- */
73
18
  write(outDir) {
74
- // Validate output directory path
75
19
  const validatedOutDir = SecurityUtils.validatePath(outDir, process.cwd());
76
- // Create output directory structure
77
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
78
20
  mkdirSync(validatedOutDir, { recursive: true });
79
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
80
21
  mkdirSync(join(validatedOutDir, 'charts'), { recursive: true });
81
- // Write each subchart to charts/ directory
82
22
  for (const subchart of this.props.subcharts) {
83
- // Validate subchart name using centralized validation
84
23
  if (!SecurityUtils.isValidSubchartName(subchart.name)) {
85
24
  throw new Error(`Invalid subchart name: ${SecurityUtils.sanitizeLogMessage(subchart.name)}`);
86
25
  }
87
- const sanitizedName = subchart.name; // Already validated by SecurityUtils
26
+ const sanitizedName = subchart.name;
88
27
  const subchartDir = join(validatedOutDir, 'charts', sanitizedName);
89
28
  subchart.rutter.write(subchartDir);
90
29
  }
91
- // Generate parent Chart.yaml with dependencies
92
30
  this.writeParentChart(validatedOutDir);
93
- // Generate parent values.yaml
94
31
  this.writeParentValues(validatedOutDir);
95
- // Generate empty templates directory (umbrella charts typically don't have templates)
96
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
97
32
  mkdirSync(join(validatedOutDir, 'templates'), { recursive: true });
98
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
99
33
  writeFileSync(join(validatedOutDir, 'templates', 'NOTES.txt'), this.generateNotesTemplate());
100
34
  }
101
35
  writeParentChart(outDir) {
@@ -111,7 +45,6 @@ export class UmbrellaRutter {
111
45
  sources: this.props.meta.sources,
112
46
  maintainers: this.props.meta.maintainers,
113
47
  dependencies: this.props.subcharts.map((subchart) => {
114
- // Subchart name already validated in write() method
115
48
  return {
116
49
  name: subchart.name,
117
50
  version: subchart.version || '0.1.0',
@@ -121,17 +54,13 @@ export class UmbrellaRutter {
121
54
  };
122
55
  }),
123
56
  };
124
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
125
57
  writeFileSync(join(outDir, 'Chart.yaml'), YAML.stringify(chartYaml));
126
58
  }
127
59
  writeParentValues(outDir) {
128
60
  const values = {
129
- // Global values that can be shared across subcharts
130
61
  global: {},
131
- // Individual subchart values
132
62
  ...this.props.defaultValues,
133
63
  };
134
- // Add subchart-specific value sections
135
64
  for (const subchart of this.props.subcharts) {
136
65
  if (!(subchart.name in values)) {
137
66
  values[subchart.name] = {
@@ -139,15 +68,11 @@ export class UmbrellaRutter {
139
68
  };
140
69
  }
141
70
  }
142
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
143
71
  writeFileSync(join(outDir, 'values.yaml'), YAML.stringify(values));
144
- // Write environment-specific values files
145
72
  if (this.props.envValues) {
146
73
  for (const [env, envVals] of Object.entries(this.props.envValues)) {
147
- // Use centralized environment name sanitization
148
74
  const sanitizedEnv = SecurityUtils.sanitizeEnvironmentName(env);
149
75
  const envValues = this.deepMerge(values, envVals);
150
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool needs dynamic paths
151
76
  writeFileSync(join(outDir, `values-${sanitizedEnv}.yaml`), YAML.stringify(envValues));
152
77
  }
153
78
  }
@@ -156,13 +81,9 @@ export class UmbrellaRutter {
156
81
  const result = { ...target };
157
82
  for (const [key, value] of Object.entries(source)) {
158
83
  if (value && typeof value === 'object' && !Array.isArray(value)) {
159
- // eslint-disable-next-line security/detect-object-injection -- Safe object property access in deep merge
160
- result[key] = this.deepMerge(
161
- // eslint-disable-next-line security/detect-object-injection -- Safe object property access in deep merge
162
- result[key] || {}, value);
84
+ result[key] = this.deepMerge(result[key] || {}, value);
163
85
  }
164
86
  else {
165
- // eslint-disable-next-line security/detect-object-injection -- Safe object property access in deep merge
166
87
  result[key] = value;
167
88
  }
168
89
  }
@@ -184,4 +105,3 @@ ${this.props.subcharts.map((s) => ` - charts/${s.name}/README.md`).join('\n')}
184
105
  `;
185
106
  }
186
107
  }
187
- //# sourceMappingURL=umbrellaRutter.js.map
@@ -1,48 +1,25 @@
1
- /**
2
- * @fileoverview Helm chart helpers and templates
3
- * @since 2.5.0
4
- */
5
- /**
6
- * Helper definition for Helm templates
7
- * @interface HelperDefinition
8
- * @since 2.5.0
9
- */
10
1
  export interface HelperDefinition {
11
- /** Helper name (without quotes or hyphens) */
12
2
  name: string;
13
- /** Helper template content */
14
3
  template: string;
15
4
  }
16
- /**
17
- * Standard Helm chart helpers following best practices
18
- * @since 2.5.0
19
- */
20
5
  export declare const STANDARD_HELPERS: HelperDefinition[];
21
- /**
22
- * AWS-specific Helm helpers
23
- * @since 2.5.0
24
- */
6
+ export declare const FILE_ACCESS_HELPERS: HelperDefinition[];
7
+ export declare const TEMPLATE_FUNCTION_HELPERS: HelperDefinition[];
8
+ export declare const SPRIG_HELPERS: HelperDefinition[];
9
+ export declare const KUBERNETES_HELPERS: HelperDefinition[];
25
10
  export declare const AWS_HELPERS: HelperDefinition[];
26
- /**
27
- * Converts helper definitions to Helm template format
28
- * @param helpers - Array of helper definitions
29
- * @returns Formatted Helm template string
30
- * @since 2.5.0
31
- */
32
11
  export declare function formatHelpers(helpers: HelperDefinition[]): string;
33
- /**
34
- * Gets default helpers based on cloud provider
35
- * @param cloudProvider - Target cloud provider
36
- * @returns Combined standard and cloud-specific helpers
37
- * @since 2.5.0
38
- */
39
- export declare function getDefaultHelpers(cloudProvider?: 'aws'): HelperDefinition[];
40
- /**
41
- * Generates complete _helpers.tpl content
42
- * @param cloudProvider - Optional cloud provider for specific helpers
43
- * @param customHelpers - Additional custom helpers
44
- * @returns Complete helpers template content
45
- * @since 2.5.0
46
- */
47
- export declare function generateHelpersTemplate(cloudProvider?: 'aws', customHelpers?: HelperDefinition[]): string;
48
- //# sourceMappingURL=helmHelpers.d.ts.map
12
+ export declare function getDefaultHelpers(cloudProvider?: 'aws', options?: {
13
+ includeFileAccess?: boolean;
14
+ includeTemplateFunction?: boolean;
15
+ includeSprig?: boolean;
16
+ includeKubernetes?: boolean;
17
+ }): HelperDefinition[];
18
+ export declare function generateHelpersTemplate(cloudProvider?: 'aws', customHelpers?: HelperDefinition[], options?: {
19
+ includeFileAccess?: boolean;
20
+ includeTemplateFunction?: boolean;
21
+ includeSprig?: boolean;
22
+ includeKubernetes?: boolean;
23
+ }): string;
24
+ export declare function getHelpersByCategory(category: 'standard' | 'fileAccess' | 'templateFunction' | 'sprig' | 'kubernetes' | 'aws'): HelperDefinition[];
25
+ export declare function createHelper(name: string, template: string): HelperDefinition;
@@ -1,11 +1,3 @@
1
- /**
2
- * @fileoverview Helm chart helpers and templates
3
- * @since 2.5.0
4
- */
5
- /**
6
- * Standard Helm chart helpers following best practices
7
- * @since 2.5.0
8
- */
9
1
  export const STANDARD_HELPERS = [
10
2
  {
11
3
  name: 'chart.name',
@@ -43,10 +35,203 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}`,
43
35
  app.kubernetes.io/instance: {{ .Release.Name }}`,
44
36
  },
45
37
  ];
46
- /**
47
- * AWS-specific Helm helpers
48
- * @since 2.5.0
49
- */
38
+ export const FILE_ACCESS_HELPERS = [
39
+ {
40
+ name: 'files.configFromFile',
41
+ template: `{{- $path := . -}}
42
+ {{- if $.Files.Get $path -}}
43
+ {{- $.Files.Get $path | nindent 2 -}}
44
+ {{- else -}}
45
+ {{- fail (printf "File %s not found in chart" $path) -}}
46
+ {{- end -}}`,
47
+ },
48
+ {
49
+ name: 'files.configMapFromFiles',
50
+ template: `{{- $root := . -}}
51
+ {{- $pattern := .pattern -}}
52
+ {{- $files := .files | default ($root.Files.Glob $pattern) -}}
53
+ {{- range $path, $content := $files }}
54
+ {{ base $path }}: |
55
+ {{ $content | indent 4 }}
56
+ {{- end }}`,
57
+ },
58
+ {
59
+ name: 'files.secretFromFiles',
60
+ template: `{{- $root := . -}}
61
+ {{- $pattern := .pattern -}}
62
+ {{- $files := .files | default ($root.Files.Glob $pattern) -}}
63
+ {{- range $path, $content := $files }}
64
+ {{ base $path }}: {{ $content | b64enc }}
65
+ {{- end }}`,
66
+ },
67
+ {
68
+ name: 'files.exists',
69
+ template: `{{- $path := . -}}
70
+ {{- if $.Files.Get $path -}}
71
+ true
72
+ {{- else -}}
73
+ false
74
+ {{- end -}}`,
75
+ },
76
+ ];
77
+ export const TEMPLATE_FUNCTION_HELPERS = [
78
+ {
79
+ name: 'template.render',
80
+ template: `{{- $template := .template -}}
81
+ {{- $context := .context | default . -}}
82
+ {{- tpl $template $context -}}`,
83
+ },
84
+ {
85
+ name: 'template.renderWithValues',
86
+ template: `{{- $template := .template -}}
87
+ {{- $values := .values | default dict -}}
88
+ {{- $context := merge $values . -}}
89
+ {{- tpl $template $context -}}`,
90
+ },
91
+ {
92
+ name: 'validation.required',
93
+ template: `{{- $value := .value -}}
94
+ {{- $message := .message | default (printf "Value %s is required" .key) -}}
95
+ {{- required $message $value -}}`,
96
+ },
97
+ {
98
+ name: 'validation.requireAny',
99
+ template: `{{- $values := .values -}}
100
+ {{- $message := .message | default "At least one value is required" -}}
101
+ {{- $found := false -}}
102
+ {{- range $values -}}
103
+ {{- if . -}}
104
+ {{- $found = true -}}
105
+ {{- end -}}
106
+ {{- end -}}
107
+ {{- if not $found -}}
108
+ {{- fail $message -}}
109
+ {{- end -}}`,
110
+ },
111
+ ];
112
+ export const SPRIG_HELPERS = [
113
+ {
114
+ name: 'string.camelCase',
115
+ template: `{{- . | camelcase }}`,
116
+ },
117
+ {
118
+ name: 'string.kebabCase',
119
+ template: `{{- . | kebabcase }}`,
120
+ },
121
+ {
122
+ name: 'string.snakeCase',
123
+ template: `{{- . | snakecase }}`,
124
+ },
125
+ {
126
+ name: 'string.randomAlphaNum',
127
+ template: `{{- $length := . | default 8 -}}
128
+ {{- randAlphaNum $length }}`,
129
+ },
130
+ {
131
+ name: 'env.getOrDefault',
132
+ template: `{{- $key := .key -}}
133
+ {{- $default := .default | default "" -}}
134
+ {{- $default }}`,
135
+ },
136
+ {
137
+ name: 'list.compact',
138
+ template: `{{- $list := . -}}
139
+ {{- $result := list -}}
140
+ {{- range $list -}}
141
+ {{- if . -}}
142
+ {{- $result = append $result . -}}
143
+ {{- end -}}
144
+ {{- end -}}
145
+ {{- $result | toJson }}`,
146
+ },
147
+ {
148
+ name: 'dict.merge',
149
+ template: `{{- $base := .base | default dict -}}
150
+ {{- $override := .override | default dict -}}
151
+ {{- merge $override $base | toJson }}`,
152
+ },
153
+ {
154
+ name: 'date.now',
155
+ template: `{{- now | date "2006-01-02T15:04:05Z07:00" }}`,
156
+ },
157
+ {
158
+ name: 'date.format',
159
+ template: `{{- $format := .format | default "2006-01-02" -}}
160
+ {{- $date := .date | default now -}}
161
+ {{- $date | date $format }}`,
162
+ },
163
+ ];
164
+ export const KUBERNETES_HELPERS = [
165
+ {
166
+ name: 'k8s.imagePullPolicy',
167
+ template: `{{- $tag := .tag | default .Values.image.tag -}}
168
+ {{- if or (eq $tag "latest") (hasSuffix "-SNAPSHOT" $tag) -}}
169
+ Always
170
+ {{- else -}}
171
+ IfNotPresent
172
+ {{- end }}`,
173
+ },
174
+ {
175
+ name: 'k8s.resourceName',
176
+ template: `{{- $root := .root | default . -}}
177
+ {{- $name := .name | default (include "chart.fullname" $root) -}}
178
+ {{- $suffix := .suffix | default "" -}}
179
+ {{- if $suffix -}}
180
+ {{- printf "%s-%s" $name $suffix | trunc 63 | trimSuffix "-" -}}
181
+ {{- else -}}
182
+ {{- $name | trunc 63 | trimSuffix "-" -}}
183
+ {{- end }}`,
184
+ },
185
+ {
186
+ name: 'k8s.annotations',
187
+ template: `{{- $global := .Values.global.annotations | default dict -}}
188
+ {{- $local := .annotations | default dict -}}
189
+ {{- $merged := merge $local $global -}}
190
+ {{- if $merged -}}
191
+ {{- range $key, $value := $merged }}
192
+ {{ $key }}: {{ $value | quote }}
193
+ {{- end -}}
194
+ {{- end }}`,
195
+ },
196
+ {
197
+ name: 'k8s.labels',
198
+ template: `{{- $global := .Values.global.labels | default dict -}}
199
+ {{- $local := .labels | default dict -}}
200
+ {{- $standard := include "chart.labels" . | fromYaml -}}
201
+ {{- $merged := merge $local $global $standard -}}
202
+ {{- range $key, $value := $merged }}
203
+ {{ $key }}: {{ $value | quote }}
204
+ {{- end }}`,
205
+ },
206
+ {
207
+ name: 'k8s.probe',
208
+ template: `{{- $probe := . -}}
209
+ {{- if $probe.enabled | default true -}}
210
+ {{- if $probe.httpGet }}
211
+ httpGet:
212
+ path: {{ $probe.httpGet.path | default "/" }}
213
+ port: {{ $probe.httpGet.port | default "http" }}
214
+ {{- if $probe.httpGet.scheme }}
215
+ scheme: {{ $probe.httpGet.scheme }}
216
+ {{- end }}
217
+ {{- else if $probe.tcpSocket }}
218
+ tcpSocket:
219
+ port: {{ $probe.tcpSocket.port | default "http" }}
220
+ {{- else if $probe.exec }}
221
+ exec:
222
+ command:
223
+ {{- range $probe.exec.command }}
224
+ - {{ . | quote }}
225
+ {{- end }}
226
+ {{- end }}
227
+ initialDelaySeconds: {{ $probe.initialDelaySeconds | default 30 }}
228
+ periodSeconds: {{ $probe.periodSeconds | default 10 }}
229
+ timeoutSeconds: {{ $probe.timeoutSeconds | default 5 }}
230
+ successThreshold: {{ $probe.successThreshold | default 1 }}
231
+ failureThreshold: {{ $probe.failureThreshold | default 3 }}
232
+ {{- end }}`,
233
+ },
234
+ ];
50
235
  export const AWS_HELPERS = [
51
236
  {
52
237
  name: 'aws.region',
@@ -64,13 +249,20 @@ export const AWS_HELPERS = [
64
249
  name: 'aws.ecrRepository',
65
250
  template: `{{- printf "%s.dkr.ecr.%s.amazonaws.com/%s" (include "aws.accountId" .) (include "aws.region" .) .Values.aws.ecrRepositoryName }}`,
66
251
  },
252
+ {
253
+ name: 'aws.s3Bucket',
254
+ template: `{{- $region := include "aws.region" . -}}
255
+ {{- $accountId := include "aws.accountId" . -}}
256
+ {{- $bucketName := .bucketName | default (printf "%s-%s-%s" .Release.Name $region $accountId | lower) -}}
257
+ {{- $bucketName | trunc 63 | trimSuffix "-" }}`,
258
+ },
259
+ {
260
+ name: 'aws.secretsManagerSecret',
261
+ template: `{{- $region := include "aws.region" . -}}
262
+ {{- $secretName := .secretName | default (printf "%s/%s" .Release.Namespace .Release.Name) -}}
263
+ {{- printf "arn:aws:secretsmanager:%s:%s:secret:%s" $region (include "aws.accountId" .) $secretName }}`,
264
+ },
67
265
  ];
68
- /**
69
- * Converts helper definitions to Helm template format
70
- * @param helpers - Array of helper definitions
71
- * @returns Formatted Helm template string
72
- * @since 2.5.0
73
- */
74
266
  export function formatHelpers(helpers) {
75
267
  return helpers
76
268
  .map((helper) => `{{/*
@@ -81,31 +273,50 @@ ${helper.template}
81
273
  {{- end }}`)
82
274
  .join('\n\n');
83
275
  }
84
- /**
85
- * Gets default helpers based on cloud provider
86
- * @param cloudProvider - Target cloud provider
87
- * @returns Combined standard and cloud-specific helpers
88
- * @since 2.5.0
89
- */
90
- export function getDefaultHelpers(cloudProvider) {
276
+ export function getDefaultHelpers(cloudProvider, options) {
91
277
  const helpers = [...STANDARD_HELPERS];
278
+ if (options?.includeFileAccess !== false) {
279
+ helpers.push(...FILE_ACCESS_HELPERS);
280
+ }
281
+ if (options?.includeTemplateFunction !== false) {
282
+ helpers.push(...TEMPLATE_FUNCTION_HELPERS);
283
+ }
284
+ if (options?.includeSprig !== false) {
285
+ helpers.push(...SPRIG_HELPERS);
286
+ }
287
+ if (options?.includeKubernetes !== false) {
288
+ helpers.push(...KUBERNETES_HELPERS);
289
+ }
92
290
  if (cloudProvider === 'aws') {
93
291
  helpers.push(...AWS_HELPERS);
94
292
  }
95
293
  return helpers;
96
294
  }
97
- /**
98
- * Generates complete _helpers.tpl content
99
- * @param cloudProvider - Optional cloud provider for specific helpers
100
- * @param customHelpers - Additional custom helpers
101
- * @returns Complete helpers template content
102
- * @since 2.5.0
103
- */
104
- export function generateHelpersTemplate(cloudProvider, customHelpers) {
105
- const helpers = getDefaultHelpers(cloudProvider);
295
+ export function generateHelpersTemplate(cloudProvider, customHelpers, options) {
296
+ const helpers = getDefaultHelpers(cloudProvider, options);
106
297
  if (customHelpers) {
107
298
  helpers.push(...customHelpers);
108
299
  }
109
300
  return formatHelpers(helpers);
110
301
  }
111
- //# sourceMappingURL=helmHelpers.js.map
302
+ export function getHelpersByCategory(category) {
303
+ switch (category) {
304
+ case 'standard':
305
+ return [...STANDARD_HELPERS];
306
+ case 'fileAccess':
307
+ return [...FILE_ACCESS_HELPERS];
308
+ case 'templateFunction':
309
+ return [...TEMPLATE_FUNCTION_HELPERS];
310
+ case 'sprig':
311
+ return [...SPRIG_HELPERS];
312
+ case 'kubernetes':
313
+ return [...KUBERNETES_HELPERS];
314
+ case 'aws':
315
+ return [...AWS_HELPERS];
316
+ default:
317
+ return [];
318
+ }
319
+ }
320
+ export function createHelper(name, template) {
321
+ return { name, template };
322
+ }