timonel 3.1.1 → 3.1.2
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 +7 -0
- package/README.md +323 -695
- package/dist/cli.js +275 -15
- package/dist/index.d.ts +5 -1
- package/dist/index.js +12 -0
- package/dist/lib/helm.d.ts +471 -0
- package/dist/lib/helm.js +483 -0
- package/dist/lib/helmChartWriter.d.ts +157 -0
- package/dist/lib/helmChartWriter.js +171 -1
- package/dist/lib/policy/configurationLoader.d.ts +132 -0
- package/dist/lib/policy/configurationLoader.js +132 -0
- package/dist/lib/policy/errorContextGenerator.d.ts +89 -0
- package/dist/lib/policy/errorContextGenerator.js +99 -2
- package/dist/lib/policy/errors.d.ts +35 -0
- package/dist/lib/policy/errors.js +36 -0
- package/dist/lib/policy/index.d.ts +9 -0
- package/dist/lib/policy/index.js +16 -0
- package/dist/lib/policy/parallelExecutor.d.ts +90 -0
- package/dist/lib/policy/parallelExecutor.js +86 -3
- package/dist/lib/policy/pluginLoader.d.ts +92 -0
- package/dist/lib/policy/pluginLoader.js +92 -1
- package/dist/lib/policy/pluginRegistry.d.ts +54 -0
- package/dist/lib/policy/pluginRegistry.js +56 -0
- package/dist/lib/policy/policyEngine.d.ts +137 -0
- package/dist/lib/policy/policyEngine.js +191 -5
- package/dist/lib/policy/resultAggregator.d.ts +46 -0
- package/dist/lib/policy/resultAggregator.js +69 -1
- package/dist/lib/policy/resultFormatter.d.ts +88 -0
- package/dist/lib/policy/resultFormatter.js +101 -0
- package/dist/lib/policy/types.d.ts +136 -0
- package/dist/lib/policy/types.js +8 -0
- package/dist/lib/policy/validationCache.d.ts +146 -0
- package/dist/lib/policy/validationCache.js +142 -6
- package/dist/lib/resources/baseResourceProvider.d.ts +45 -0
- package/dist/lib/resources/baseResourceProvider.js +48 -1
- package/dist/lib/resources/cloud/aws/awsResources.d.ts +192 -0
- package/dist/lib/resources/cloud/aws/awsResources.js +163 -1
- package/dist/lib/resources/cloud/aws/karpenterResources.d.ts +131 -0
- package/dist/lib/resources/cloud/aws/karpenterResources.js +77 -0
- package/dist/lib/rutter.d.ts +381 -3
- package/dist/lib/rutter.js +439 -28
- package/dist/lib/security.d.ts +123 -0
- package/dist/lib/security.js +162 -4
- package/dist/lib/templates/flexible-subchart.d.ts +52 -0
- package/dist/lib/templates/flexible-subchart.js +70 -0
- package/dist/lib/templates/umbrella-chart.d.ts +27 -0
- package/dist/lib/templates/umbrella-chart.js +89 -0
- package/dist/lib/types.d.ts +26 -0
- package/dist/lib/umbrella.d.ts +23 -0
- package/dist/lib/umbrella.js +23 -0
- package/dist/lib/umbrellaRutter.d.ts +75 -0
- package/dist/lib/umbrellaRutter.js +82 -2
- package/dist/lib/utils/envVarsLoader.d.ts +49 -0
- package/dist/lib/utils/envVarsLoader.js +53 -0
- package/dist/lib/utils/helmConstructSerializer.d.ts +17 -0
- package/dist/lib/utils/helmConstructSerializer.js +22 -0
- package/dist/lib/utils/helmControlStructures.d.ts +194 -0
- package/dist/lib/utils/helmControlStructures.js +180 -0
- package/dist/lib/utils/helmHelpers/envHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/envHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/gitopsHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/gitopsHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/index.d.ts +74 -0
- package/dist/lib/utils/helmHelpers/index.js +85 -1
- package/dist/lib/utils/helmHelpers/observabilityHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/observabilityHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers/types.d.ts +23 -0
- package/dist/lib/utils/helmHelpers/types.js +4 -0
- package/dist/lib/utils/helmHelpers/validationHelpers.d.ts +13 -0
- package/dist/lib/utils/helmHelpers/validationHelpers.js +13 -0
- package/dist/lib/utils/helmHelpers.d.ts +62 -0
- package/dist/lib/utils/helmHelpers.js +77 -0
- package/dist/lib/utils/helmYamlSerializer.d.ts +77 -0
- package/dist/lib/utils/helmYamlSerializer.js +398 -21
- package/dist/lib/utils/logger.d.ts +153 -0
- package/dist/lib/utils/logger.js +170 -2
- package/dist/lib/utils/valuesRef.d.ts +181 -50
- package/dist/lib/utils/valuesRef.js +168 -170
- package/dist/lib/validation/inputValidator.d.ts +45 -0
- package/dist/lib/validation/inputValidator.js +67 -2
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.js +3 -0
- package/package.json +31 -38
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for Timonel - TypeScript library for programmatic Helm chart generation
|
|
3
|
+
* @since 2.8.0+
|
|
4
|
+
*/
|
|
1
5
|
export * from './lib/helm.js';
|
|
2
6
|
export * from './lib/helmChartWriter.js';
|
|
3
7
|
export * from './lib/rutter.js';
|
|
@@ -18,4 +22,4 @@ export { UmbrellaRutter } from './lib/umbrellaRutter.js';
|
|
|
18
22
|
export { helmIf, helmIfSimple, helmRange, helmWith, helmInclude, helmDefine, helmVar, helmBlock, helmComment, helmFragment, createHelmExpression, isHelmConstruct, isHelmExpression, type HelmConstruct, type HelmExpression, type HelmContent, type HelmWhitespaceOptions, } from './lib/utils/helmControlStructures.js';
|
|
19
23
|
export { loadEnvVarsConfig, generateEnvVars, loadAndGenerateEnvVars, type EnvVarConfig, type LoadEnvVarsOptions, } from './lib/utils/envVarsLoader.js';
|
|
20
24
|
export { dumpHelmAwareYaml, validateHelmYaml, type HelmValidationError, type HelmValidationResult, } from './lib/utils/helmYamlSerializer.js';
|
|
21
|
-
export { valuesRef, isHelmValue, isHelmCondition, isHelmFieldConditional, isHelmRange, isHelmWith, serializeHelmValue, serializeHelmCondition, type HelmValue, type HelmCondition, type HelmFieldConditional, type HelmRange, type HelmWith, type HelmHelpers, } from './lib/utils/valuesRef.js';
|
|
25
|
+
export { valuesRef, isHelmValue, isHelmCondition, isHelmFieldConditional, isHelmRange, isHelmWith, serializeHelmValue, serializeHelmCondition, type HelmValue, type HelmValueRef, type ValuesRef, type HelmCondition, type HelmFieldConditional, type HelmRange, type HelmWith, type HelmHelpers, } from './lib/utils/valuesRef.js';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for Timonel - TypeScript library for programmatic Helm chart generation
|
|
3
|
+
* @since 2.8.0+
|
|
4
|
+
*/
|
|
1
5
|
export * from './lib/helm.js';
|
|
2
6
|
export * from './lib/helmChartWriter.js';
|
|
3
7
|
export * from './lib/rutter.js';
|
|
4
8
|
export * from './lib/security.js';
|
|
5
9
|
export * from './lib/umbrella.js';
|
|
10
|
+
// Policy Engine
|
|
6
11
|
export * from './lib/policy/index.js';
|
|
12
|
+
// Input Validation
|
|
7
13
|
export * from './lib/validation/inputValidator.js';
|
|
14
|
+
// Templates
|
|
8
15
|
export { FlexibleSubchart, createFlexibleSubchart } from './lib/templates/flexible-subchart.js';
|
|
9
16
|
export { UmbrellaChartTemplate as UmbrellaChart } from './lib/templates/umbrella-chart.js';
|
|
10
17
|
export { DEFAULT_TERMINATION_GRACE_PERIOD, isValidDisruptionBudget, isValidKubernetesDuration, KarpenterVersionUtils, } from './lib/resources/cloud/aws/karpenterResources.js';
|
|
18
|
+
// Helm Helpers
|
|
11
19
|
export { AWS_HELPERS, createHelper, FILE_ACCESS_HELPERS, formatHelpers, generateHelpersTemplate, getDefaultHelpers, getHelpersByCategory, KUBERNETES_HELPERS, SPRIG_HELPERS, STANDARD_HELPERS, TEMPLATE_FUNCTION_HELPERS, } from './lib/utils/helmHelpers.js';
|
|
20
|
+
// Logging Utilities
|
|
12
21
|
export { createLogger, logger, LogLevel, TimonelLogger, } from './lib/utils/logger.js';
|
|
13
22
|
export { UmbrellaRutter } from './lib/umbrellaRutter.js';
|
|
14
23
|
export { helmIf, helmIfSimple, helmRange, helmWith, helmInclude, helmDefine, helmVar, helmBlock, helmComment, helmFragment, createHelmExpression, isHelmConstruct, isHelmExpression, } from './lib/utils/helmControlStructures.js';
|
|
24
|
+
// Environment Variables Loader
|
|
15
25
|
export { loadEnvVarsConfig, generateEnvVars, loadAndGenerateEnvVars, } from './lib/utils/envVarsLoader.js';
|
|
26
|
+
// Helm YAML Serialization Utilities
|
|
16
27
|
export { dumpHelmAwareYaml, validateHelmYaml, } from './lib/utils/helmYamlSerializer.js';
|
|
28
|
+
// Type-safe Values Reference
|
|
17
29
|
export { valuesRef, isHelmValue, isHelmCondition, isHelmFieldConditional, isHelmRange, isHelmWith, serializeHelmValue, serializeHelmCondition, } from './lib/utils/valuesRef.js';
|
package/dist/lib/helm.d.ts
CHANGED
|
@@ -1,15 +1,159 @@
|
|
|
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 2.8.0+++
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Creates a reference to a value in .Values of Helm
|
|
8
|
+
*
|
|
9
|
+
* Generates a Helm template expression that references a value
|
|
10
|
+
* in the chart's values.yaml file using dot notation.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} path - Path to the value using dot notation (e.g., 'image.tag')
|
|
13
|
+
* @returns {string} Helm template expression (e.g., '{{ .Values.image.tag }}')
|
|
14
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const imageTag = valuesRef('image.tag');
|
|
19
|
+
* // Returns: '{{ .Values.image.tag }}'
|
|
20
|
+
*
|
|
21
|
+
* const replicas = valuesRef('deployment.replicas');
|
|
22
|
+
* // Returns: '{{ .Values.deployment.replicas }}'
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @since 2.8.0+
|
|
26
|
+
*/
|
|
1
27
|
export declare function valuesRef(path: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a required reference to a value in .Values of Helm
|
|
30
|
+
*
|
|
31
|
+
* Similar to valuesRef, but uses Helm's 'required' function to
|
|
32
|
+
* ensure the value is present, failing chart rendering if not provided.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} path - Path to the value using dot notation
|
|
35
|
+
* @param {string} [message] - Custom error message if value is missing
|
|
36
|
+
* @returns {string} Helm template expression with required validation
|
|
37
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const dbPassword = requiredValuesRef('database.password', 'Database password is required');
|
|
42
|
+
* // Returns: '{{ required "Database password is required" .Values.database.password }}'
|
|
43
|
+
*
|
|
44
|
+
* const apiKey = requiredValuesRef('api.key');
|
|
45
|
+
* // Returns: '{{ required "api.key is required" .Values.api.key }}'
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @since 2.8.0+
|
|
49
|
+
*/
|
|
2
50
|
export declare function requiredValuesRef(path: string, message?: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Built-in Helm references for release and chart metadata
|
|
53
|
+
*
|
|
54
|
+
* Object containing the most common references to Helm's built-in
|
|
55
|
+
* variables for release and chart information.
|
|
56
|
+
*
|
|
57
|
+
* @namespace helm
|
|
58
|
+
* @since 2.8.0+
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const deploymentName = `${helm.releaseName}-deployment`;
|
|
63
|
+
* // Uses: '{{ .Release.Name }}-deployment'
|
|
64
|
+
*
|
|
65
|
+
* const version = helm.chartVersion;
|
|
66
|
+
* // Uses: '{{ .Chart.Version }}'
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
3
69
|
export declare const helm: {
|
|
70
|
+
/** Release name: {{ .Release.Name }} */
|
|
4
71
|
releaseName: string;
|
|
72
|
+
/** Chart name: {{ .Chart.Name }} */
|
|
5
73
|
chartName: string;
|
|
74
|
+
/** Chart version: {{ .Chart.Version }} */
|
|
6
75
|
chartVersion: string;
|
|
76
|
+
/** Release namespace: {{ .Release.Namespace }} */
|
|
7
77
|
namespace: string;
|
|
8
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Quotes a Helm template expression for safe YAML embedding
|
|
81
|
+
*
|
|
82
|
+
* Ensures Helm template expressions are properly quoted to avoid
|
|
83
|
+
* YAML parsing issues when the expression contains special characters.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} expr - Helm template expression to quote
|
|
86
|
+
* @returns {string} Quoted expression if it's a Helm template, otherwise unchanged
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const quoted = quote('{{ .Values.image.tag }}');
|
|
91
|
+
* // Returns: "'{{ .Values.image.tag }}'"
|
|
92
|
+
*
|
|
93
|
+
* const normal = quote('nginx:1.21');
|
|
94
|
+
* // Returns: "nginx:1.21"
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @since 2.8.0+
|
|
98
|
+
*/
|
|
9
99
|
export declare function quote(expr: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Indents text by specified number of spaces
|
|
102
|
+
*
|
|
103
|
+
* Helper function that matches Helm's indent function behavior,
|
|
104
|
+
* adding the specified number of spaces to each non-empty line.
|
|
105
|
+
*
|
|
106
|
+
* @param {number} n - Number of spaces to indent
|
|
107
|
+
* @param {string} expr - Text to indent
|
|
108
|
+
* @returns {string} Indented text
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const indented = indent(4, 'line1\nline2');
|
|
113
|
+
* // Returns: " line1\n line2"
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @since 2.8.0+
|
|
117
|
+
*/
|
|
10
118
|
export declare function indent(n: number, expr: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Inserts a call to a named Helm template using template function
|
|
121
|
+
*
|
|
122
|
+
* @param {string} name - Name of the template to call
|
|
123
|
+
* @param {string} [context='.'] - Context to pass to the template
|
|
124
|
+
* @returns {string} Helm template expression
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const tmpl = template('myapp.labels');
|
|
129
|
+
* // Returns: '{{ template "myapp.labels" . }}'
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @since 2.8.0+
|
|
133
|
+
*/
|
|
11
134
|
export declare function template(name: string, context?: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Inserts a call to a named Helm template using include function
|
|
137
|
+
*
|
|
138
|
+
* Preferred over template() as include allows piping and better error handling.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} name - Name of the template to include
|
|
141
|
+
* @param {string} [context='.'] - Context to pass to the template
|
|
142
|
+
* @returns {string} Helm template expression
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const tmpl = include('myapp.labels');
|
|
147
|
+
* // Returns: '{{ include "myapp.labels" . }}'
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @since 2.8.0+
|
|
151
|
+
*/
|
|
12
152
|
export declare function include(name: string, context?: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* Branded types for better type safety in Helm template paths
|
|
155
|
+
* @since 2.8.0+
|
|
156
|
+
*/
|
|
13
157
|
export type HelmPath = string & {
|
|
14
158
|
readonly __brand: unique symbol;
|
|
15
159
|
};
|
|
@@ -25,23 +169,323 @@ export type StringPath = HelmPath & {
|
|
|
25
169
|
export type FloatPath = HelmPath & {
|
|
26
170
|
readonly __floatType: unique symbol;
|
|
27
171
|
};
|
|
172
|
+
/**
|
|
173
|
+
* Configuration options for typed reference creation
|
|
174
|
+
* @since 2.8.0+
|
|
175
|
+
*/
|
|
28
176
|
interface TypedRefOptions {
|
|
177
|
+
/** Whether to include default value handling */
|
|
29
178
|
withDefault?: boolean;
|
|
179
|
+
/** Default value to use if the path is not set */
|
|
30
180
|
defaultValue?: string | number | boolean;
|
|
181
|
+
/** Whether to quote string values */
|
|
31
182
|
quote?: boolean;
|
|
32
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Factory function to create typed Helm value references with reduced code duplication
|
|
186
|
+
* @param path - The path to the value in the Helm values
|
|
187
|
+
* @param type - The expected type of the value
|
|
188
|
+
* @param options - Additional options for reference creation
|
|
189
|
+
* @returns A string that can be used in Helm templates
|
|
190
|
+
* @throws {Error} If the path is invalid
|
|
191
|
+
* @since 2.8.0+
|
|
192
|
+
*/
|
|
33
193
|
export declare function createTypedRef(path: string, type: 'number' | 'boolean' | 'string' | 'float', options?: TypedRefOptions): string;
|
|
194
|
+
/**
|
|
195
|
+
* Creates a numeric reference from .Values with int cast
|
|
196
|
+
*
|
|
197
|
+
* Generates a Helm template expression that casts the value to integer,
|
|
198
|
+
* truncating any decimal places.
|
|
199
|
+
*
|
|
200
|
+
* @param {string} path - Path to the value using dot notation
|
|
201
|
+
* @param {TypedRefOptions} [options] - Additional options for reference creation
|
|
202
|
+
* @returns {string} Helm template expression with int cast
|
|
203
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* const replicas = numberRef('deployment.replicas');
|
|
208
|
+
* // Returns: '{{ .Values.deployment.replicas | int }}'
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @since 2.8.0+
|
|
212
|
+
*/
|
|
34
213
|
export declare function numberRef(path: string, options?: TypedRefOptions): string;
|
|
214
|
+
/**
|
|
215
|
+
* Creates a boolean reference from .Values with toBool cast
|
|
216
|
+
*
|
|
217
|
+
* @param {string} path - Path to the value using dot notation
|
|
218
|
+
* @param {TypedRefOptions} [options] - Additional options for reference creation
|
|
219
|
+
* @returns {string} Helm template expression with toBool cast
|
|
220
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const enabled = boolRef('feature.enabled');
|
|
225
|
+
* // Returns: '{{ .Values.feature.enabled | toBool }}'
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @since 2.8.0+
|
|
229
|
+
*/
|
|
35
230
|
export declare function boolRef(path: string, options?: TypedRefOptions): string;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a string reference from .Values with toString cast
|
|
233
|
+
*
|
|
234
|
+
* @param {string} path - Path to the value using dot notation
|
|
235
|
+
* @param {TypedRefOptions} [options] - Additional options for reference creation
|
|
236
|
+
* @returns {string} Helm template expression with toString cast
|
|
237
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* const version = stringRef('app.version');
|
|
242
|
+
* // Returns: '{{ .Values.app.version | toString }}'
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @since 2.8.0+
|
|
246
|
+
*/
|
|
36
247
|
export declare function stringRef(path: string, options?: TypedRefOptions): string;
|
|
248
|
+
/**
|
|
249
|
+
* Creates a float reference from .Values with float64 cast
|
|
250
|
+
*
|
|
251
|
+
* @param {string} path - Path to the value using dot notation
|
|
252
|
+
* @param {TypedRefOptions} [options] - Additional options for reference creation
|
|
253
|
+
* @returns {string} Helm template expression with float64 cast
|
|
254
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const ratio = floatRef('scaling.ratio');
|
|
259
|
+
* // Returns: '{{ .Values.scaling.ratio | float64 }}'
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @since 2.8.0+
|
|
263
|
+
*/
|
|
37
264
|
export declare function floatRef(path: string, options?: TypedRefOptions): string;
|
|
265
|
+
/**
|
|
266
|
+
* Creates a conditional reference to a value in .Values
|
|
267
|
+
*
|
|
268
|
+
* Generates a Helm template expression that conditionally renders
|
|
269
|
+
* the value only if the condition is truthy.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} path - Path to the value using dot notation
|
|
272
|
+
* @param {string} condition - Path to the condition value
|
|
273
|
+
* @returns {string} Helm template expression with conditional logic
|
|
274
|
+
* @throws {Error} If the path or condition is not valid for Helm templates
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const secretName = conditionalRef('database.secretName', 'database.enabled');
|
|
279
|
+
* // Returns: '{{ if .Values.database.enabled }}{{ .Values.database.secretName }}{{ end }}'
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @since 2.8.0+
|
|
283
|
+
*/
|
|
38
284
|
export declare function conditionalRef(path: string, condition: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* Wraps a complete YAML manifest in a Helm conditional
|
|
287
|
+
*
|
|
288
|
+
* Generates a Helm template that conditionally renders an entire
|
|
289
|
+
* Kubernetes manifest based on a values condition.
|
|
290
|
+
*
|
|
291
|
+
* @param {string} yamlContent - Complete YAML manifest content
|
|
292
|
+
* @param {string} condition - Path to the condition value
|
|
293
|
+
* @returns {string} YAML content wrapped in Helm conditional
|
|
294
|
+
* @throws {Error} If the condition path is not valid for Helm templates
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const namespaceYaml = `
|
|
299
|
+
* apiVersion: v1
|
|
300
|
+
* kind: Namespace
|
|
301
|
+
* metadata:
|
|
302
|
+
* name: my-namespace
|
|
303
|
+
* `;
|
|
304
|
+
* const conditionalNamespace = conditionalManifest(namespaceYaml, 'createNamespace');
|
|
305
|
+
* // Returns: '{{ if .Values.createNamespace }}\napiVersion: v1\nkind: Namespace...{{ end }}'
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @since 2.8.0+
|
|
309
|
+
*/
|
|
39
310
|
export declare function conditionalManifest(yamlContent: string, condition: string): string;
|
|
311
|
+
/**
|
|
312
|
+
* Creates a reference to a value in .Values with a default fallback
|
|
313
|
+
*
|
|
314
|
+
* Generates a Helm template expression that uses the default filter
|
|
315
|
+
* to provide a fallback value when the path is not set.
|
|
316
|
+
*
|
|
317
|
+
* @param {string} path - Path to the value using dot notation
|
|
318
|
+
* @param {string} defaultValue - Default value to use if path is not set
|
|
319
|
+
* @returns {string} Helm template expression with default fallback
|
|
320
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const image = defaultRef('image.tag', 'latest');
|
|
325
|
+
* // Returns: '{{ .Values.image.tag | default "latest" }}'
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* @since 2.8.0+
|
|
329
|
+
*/
|
|
40
330
|
export declare function defaultRef(path: string, defaultValue: string): string;
|
|
331
|
+
/**
|
|
332
|
+
* Creates a base64-encoded reference to a value in .Values
|
|
333
|
+
*
|
|
334
|
+
* Generates a Helm template expression that encodes the value
|
|
335
|
+
* using base64 encoding, useful for secrets and certificates.
|
|
336
|
+
*
|
|
337
|
+
* @param {string} path - Path to the value using dot notation
|
|
338
|
+
* @returns {string} Helm template expression with base64 encoding
|
|
339
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const encodedSecret = base64Ref('secrets.apiKey');
|
|
344
|
+
* // Returns: '{{ .Values.secrets.apiKey | b64enc }}'
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @since 2.8.0+
|
|
348
|
+
*/
|
|
41
349
|
export declare function base64Ref(path: string): string;
|
|
350
|
+
/**
|
|
351
|
+
* Creates a JSON-serialized reference to a value in .Values
|
|
352
|
+
*
|
|
353
|
+
* Generates a Helm template expression that serializes the value
|
|
354
|
+
* to JSON format, useful for complex configuration objects.
|
|
355
|
+
*
|
|
356
|
+
* @param {string} path - Path to the value using dot notation
|
|
357
|
+
* @returns {string} Helm template expression with JSON serialization
|
|
358
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const configJson = jsonRef('app.config');
|
|
363
|
+
* // Returns: '{{ .Values.app.config | toJson }}'
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @since 2.6.0
|
|
367
|
+
*/
|
|
42
368
|
export declare function jsonRef(path: string): string;
|
|
369
|
+
/**
|
|
370
|
+
* Flow Control Functions for Helm Templates
|
|
371
|
+
*
|
|
372
|
+
* These functions provide programmatic access to Helm's flow control structures:
|
|
373
|
+
* if/else, with, and range for conditional logic and iteration.
|
|
374
|
+
*
|
|
375
|
+
* @since 2.8.0+
|
|
376
|
+
*/
|
|
377
|
+
/**
|
|
378
|
+
* Creates a conditional if block in Helm templates
|
|
379
|
+
*
|
|
380
|
+
* Generates Helm template expressions for conditional logic using if/else/end.
|
|
381
|
+
* Supports complex conditions with comparison operators and pipeline expressions.
|
|
382
|
+
*
|
|
383
|
+
* @param {string} condition - The condition to evaluate (e.g., 'eq .Values.env "production"')
|
|
384
|
+
* @param {string} content - Content to include when condition is true
|
|
385
|
+
* @param {string} [elseContent] - Optional content for else block
|
|
386
|
+
* @returns {string} Complete Helm if/else template block
|
|
387
|
+
* @throws {Error} If condition contains potentially unsafe template expressions
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const conditionalConfig = helmIf(
|
|
392
|
+
* 'eq .Values.environment "production"',
|
|
393
|
+
* 'replicas: 3\nresources:\n limits:\n memory: "1Gi"',
|
|
394
|
+
* 'replicas: 1\nresources:\n limits:\n memory: "512Mi"'
|
|
395
|
+
* );
|
|
396
|
+
* // Returns:
|
|
397
|
+
* // {{- if eq .Values.environment "production" }}
|
|
398
|
+
* // replicas: 3
|
|
399
|
+
* // resources:
|
|
400
|
+
* // limits:
|
|
401
|
+
* // memory: "1Gi"
|
|
402
|
+
* // {{- else }}
|
|
403
|
+
* // replicas: 1
|
|
404
|
+
* // resources:
|
|
405
|
+
* // limits:
|
|
406
|
+
* // memory: "512Mi"
|
|
407
|
+
* // {{- end }}
|
|
408
|
+
* ```
|
|
409
|
+
*
|
|
410
|
+
* @since 2.8.0
|
|
411
|
+
*/
|
|
43
412
|
export declare function helmIf(condition: string, content: string, elseContent?: string): string;
|
|
413
|
+
/**
|
|
414
|
+
* Creates a with block for scoped template context
|
|
415
|
+
*
|
|
416
|
+
* Generates Helm template expressions using 'with' to change the template context.
|
|
417
|
+
* Useful for accessing nested values without repeating the full path.
|
|
418
|
+
*
|
|
419
|
+
* @param {string} path - Path to set as new context (e.g., '.Values.database')
|
|
420
|
+
* @param {string} content - Content to render within the new context
|
|
421
|
+
* @param {string} [elseContent] - Optional content when path is empty/nil
|
|
422
|
+
* @returns {string} Complete Helm with/else/end template block
|
|
423
|
+
* @throws {Error} If path is not valid for Helm templates
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```typescript
|
|
427
|
+
* const dbConfig = helmWith(
|
|
428
|
+
* '.Values.database',
|
|
429
|
+
* 'host: {{ .host }}\nport: {{ .port }}\nname: {{ .name }}',
|
|
430
|
+
* 'host: "localhost"\nport: 5432\nname: "defaultdb"'
|
|
431
|
+
* );
|
|
432
|
+
* // Returns:
|
|
433
|
+
* // {{- with .Values.database }}
|
|
434
|
+
* // host: {{ .host }}
|
|
435
|
+
* // port: {{ .port }}
|
|
436
|
+
* // name: {{ .name }}
|
|
437
|
+
* // {{- else }}
|
|
438
|
+
* // host: "localhost"
|
|
439
|
+
* // port: 5432
|
|
440
|
+
* // name: "defaultdb"
|
|
441
|
+
* // {{- end }}
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @since 2.8.0
|
|
445
|
+
*/
|
|
44
446
|
export declare function helmWith(path: string, content: string, elseContent?: string): string;
|
|
447
|
+
/**
|
|
448
|
+
* Creates a range loop for iterating over collections
|
|
449
|
+
*
|
|
450
|
+
* Generates Helm template expressions using 'range' to iterate over lists, maps, or other collections.
|
|
451
|
+
* Supports both simple iteration and key-value iteration for maps.
|
|
452
|
+
*
|
|
453
|
+
* @param {string} collection - Collection to iterate over (e.g., '.Values.items')
|
|
454
|
+
* @param {string} content - Content template for each iteration
|
|
455
|
+
* @param {object} [options] - Configuration options for the range loop
|
|
456
|
+
* @param {boolean} [options.keyValue=false] - Whether to iterate with key-value pairs
|
|
457
|
+
* @param {string} [options.keyVar='$key'] - Variable name for keys in key-value iteration
|
|
458
|
+
* @param {string} [options.valueVar='$value'] - Variable name for values in key-value iteration
|
|
459
|
+
* @param {string} [options.indexVar='$index'] - Variable name for index in indexed iteration
|
|
460
|
+
* @param {string} [options.itemVar='$item'] - Variable name for items in simple iteration
|
|
461
|
+
* @returns {string} Complete Helm range/end template block
|
|
462
|
+
* @throws {Error} If collection path is not valid
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```typescript
|
|
466
|
+
* // Simple list iteration
|
|
467
|
+
* const serviceList = helmRange(
|
|
468
|
+
* '.Values.services',
|
|
469
|
+
* '- name: {{ .name }}\n port: {{ .port }}'
|
|
470
|
+
* );
|
|
471
|
+
*
|
|
472
|
+
* // Key-value map iteration
|
|
473
|
+
* const envVars = helmRange(
|
|
474
|
+
* '.Values.env',
|
|
475
|
+
* '- name: {{ $key }}\n value: {{ $value | quote }}',
|
|
476
|
+
* { keyValue: true }
|
|
477
|
+
* );
|
|
478
|
+
*
|
|
479
|
+
* // Indexed iteration
|
|
480
|
+
* const indexedItems = helmRange(
|
|
481
|
+
* '.Values.items',
|
|
482
|
+
* '{{ $index }}: {{ $item }}',
|
|
483
|
+
* { indexVar: '$i', itemVar: '$val' }
|
|
484
|
+
* );
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* @since 2.8.0
|
|
488
|
+
*/
|
|
45
489
|
export declare function helmRange(collection: string, content: string, options?: {
|
|
46
490
|
keyValue?: boolean;
|
|
47
491
|
keyVar?: string;
|
|
@@ -49,6 +493,33 @@ export declare function helmRange(collection: string, content: string, options?:
|
|
|
49
493
|
indexVar?: string;
|
|
50
494
|
itemVar?: string;
|
|
51
495
|
}): string;
|
|
496
|
+
/**
|
|
497
|
+
* Creates a complex conditional with multiple else-if branches
|
|
498
|
+
*
|
|
499
|
+
* Generates Helm template expressions for complex conditional logic with multiple branches.
|
|
500
|
+
* Useful for handling multiple environment configurations or feature flags.
|
|
501
|
+
*
|
|
502
|
+
* @param {Array<{condition: string, content: string}>} branches - Array of condition-content pairs
|
|
503
|
+
* @param {string} [defaultContent] - Default content when no conditions match
|
|
504
|
+
* @returns {string} Complete Helm if/else-if/else/end template block
|
|
505
|
+
* @throws {Error} If branches array is empty or contains invalid conditions
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* const envConfig = helmIfElseIf([
|
|
510
|
+
* {
|
|
511
|
+
* condition: 'eq .Values.environment "production"',
|
|
512
|
+
* content: 'replicas: 5\nresources.limits.memory: "2Gi"'
|
|
513
|
+
* },
|
|
514
|
+
* {
|
|
515
|
+
* condition: 'eq .Values.environment "staging"',
|
|
516
|
+
* content: 'replicas: 2\nresources.limits.memory: "1Gi"'
|
|
517
|
+
* }
|
|
518
|
+
* ], 'replicas: 1\nresources.limits.memory: "512Mi"');
|
|
519
|
+
* ```
|
|
520
|
+
*
|
|
521
|
+
* @since 2.8.0
|
|
522
|
+
*/
|
|
52
523
|
export declare function helmIfElseIf(branches: Array<{
|
|
53
524
|
condition: string;
|
|
54
525
|
content: string;
|