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
|
@@ -1,33 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Helm template control structure helpers
|
|
3
|
+
* Provides type-safe, composable helpers for Helm template constructs
|
|
4
|
+
* @since 2.14.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base interface for all Helm constructs
|
|
8
|
+
* Used by the serializer to detect and handle Helm template structures
|
|
9
|
+
*/
|
|
1
10
|
export interface HelmConstruct {
|
|
2
11
|
__helmConstruct: true;
|
|
3
12
|
type: 'if' | 'range' | 'with' | 'include' | 'define' | 'var' | 'block' | 'comment' | 'fragment' | 'fieldConditional';
|
|
4
13
|
data: unknown;
|
|
5
14
|
options?: HelmWhitespaceOptions;
|
|
6
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Helm fragment (composite of multiple contents).
|
|
18
|
+
* Useful for combining multiple constructs (e.g. multiple if blocks) into a single field value.
|
|
19
|
+
* @param contents List of Helm content to combine
|
|
20
|
+
* @returns HelmConstruct of type 'fragment'
|
|
21
|
+
*/
|
|
7
22
|
export declare function helmFragment(...contents: HelmContent[]): HelmConstruct;
|
|
23
|
+
/**
|
|
24
|
+
* Represents a Helm template expression marker.
|
|
25
|
+
* Prevents quoting of Helm expressions (legacy concept, now handled via scalar types).
|
|
26
|
+
* @since 2.9.2
|
|
27
|
+
*/
|
|
8
28
|
export interface HelmExpression {
|
|
9
29
|
__helmExpression: true;
|
|
10
30
|
value: string;
|
|
11
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a Helm expression marker.
|
|
34
|
+
* @param value Helm template expression string.
|
|
35
|
+
* @returns Helm expression marker object.
|
|
36
|
+
* @since 2.9.2
|
|
37
|
+
*/
|
|
12
38
|
export declare function createHelmExpression(value: string): HelmExpression;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a value is a Helm expression marker.
|
|
41
|
+
* @param value Value to check.
|
|
42
|
+
* @returns True if value is a Helm expression marker.
|
|
43
|
+
* @since 2.9.2
|
|
44
|
+
*/
|
|
13
45
|
export declare function isHelmExpression(value: unknown): value is HelmExpression;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Helm range (iteration) block.
|
|
48
|
+
*
|
|
49
|
+
* @param vars - Variable(s) to bind (e.g., 'item', '$key, $value', '$index, $item')
|
|
50
|
+
* @param collection - Helm expression for the collection to iterate (e.g., '.Values.items')
|
|
51
|
+
* @param content - Content to repeat for each iteration
|
|
52
|
+
* @param options - Whitespace control options
|
|
53
|
+
* @returns HelmConstruct of type 'range'
|
|
54
|
+
*
|
|
55
|
+
* helmRange('$key, $value', '.Values.secrets', {
|
|
56
|
+
* [helmVar('$key')]: helmVar('$value')]
|
|
57
|
+
* })
|
|
58
|
+
*/
|
|
14
59
|
export declare function helmRange(vars: string, collection: string, content: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a Helm with block (scope/context switching).
|
|
62
|
+
*
|
|
63
|
+
* @param scope - Helm expression for the scope to switch to (e.g., '.Values.database')
|
|
64
|
+
* @param content - Content to execute with the new scope (where '.' refers to the scope)
|
|
65
|
+
* @param options - Whitespace control options
|
|
66
|
+
* @returns HelmConstruct of type 'with'
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Simplify nested object access
|
|
70
|
+
* helmWith('.Values.database', {
|
|
71
|
+
* host: helm('{{ .host }}'),
|
|
72
|
+
* port: helm('{{ .port }}'),
|
|
73
|
+
* username: helm('{{ .username }}')
|
|
74
|
+
* })
|
|
75
|
+
*/
|
|
15
76
|
export declare function helmWith(scope: string, content: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a Helm include statement (template inclusion).
|
|
79
|
+
*
|
|
80
|
+
* @param templateName - Name of the template to include (e.g., 'myapp.labels')
|
|
81
|
+
* @param scope - Scope to pass to the template (usually '.')
|
|
82
|
+
* @param pipe - Optional pipe operations (e.g., 'nindent 4', 'quote')
|
|
83
|
+
* @param options - Whitespace control options
|
|
84
|
+
* @returns HelmConstruct of type 'include'
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* helmInclude('myapp.labels', '.', { pipe: 'nindent 4' })
|
|
88
|
+
* // Output: {{ include "myapp.labels" . | nindent 4 }}
|
|
89
|
+
*/
|
|
16
90
|
export declare function helmInclude(templateName: string, scope?: string, options?: {
|
|
17
91
|
pipe?: string;
|
|
18
92
|
} & HelmWhitespaceOptions): HelmConstruct;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a Helm define block (template definition).
|
|
95
|
+
*
|
|
96
|
+
* @param name - Name of the template
|
|
97
|
+
* @param content - Template content
|
|
98
|
+
* @param options - Whitespace control options
|
|
99
|
+
* @returns HelmConstruct of type 'define'
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* helmDefine('myapp.labels', {
|
|
103
|
+
* 'app.kubernetes.io/name': helm('{{ .Chart.Name }}'),
|
|
104
|
+
* 'app.kubernetes.io/instance': helm('{{ .Release.Name }}')
|
|
105
|
+
* })
|
|
106
|
+
*/
|
|
19
107
|
export declare function helmDefine(name: string, content: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a Helm variable assignment.
|
|
110
|
+
*
|
|
111
|
+
* @param name - Variable name (with $ prefix)
|
|
112
|
+
* @param value - Value to assign
|
|
113
|
+
* @param options - Whitespace control options
|
|
114
|
+
* @returns HelmConstruct of type 'var'
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* helmVar('$fullName', 'include "myapp.fullname" .')
|
|
118
|
+
* // Output: {{ $fullName := include "myapp.fullname" . }}
|
|
119
|
+
*/
|
|
20
120
|
export declare function helmVar(name: string, value: string, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
121
|
+
/**
|
|
122
|
+
* Creates a Helm block (named template block).
|
|
123
|
+
*
|
|
124
|
+
* @param name - Block name
|
|
125
|
+
* @param content - Block content
|
|
126
|
+
* @param options - Whitespace control options
|
|
127
|
+
* @returns HelmConstruct of type 'block'
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* helmBlock('myapp.config', { key: 'value' })
|
|
131
|
+
*/
|
|
21
132
|
export declare function helmBlock(name: string, content: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a Helm comment block.
|
|
135
|
+
*
|
|
136
|
+
* @param text - Comment text
|
|
137
|
+
* @returns HelmConstruct of type 'comment'
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* helmComment('This is a template comment')
|
|
141
|
+
* // Output: (curly-brace-slash-star) This is a template comment (star-slash-curly-brace)
|
|
142
|
+
*/
|
|
22
143
|
export declare function helmComment(text: string): HelmConstruct;
|
|
23
144
|
export type HelmContent = string | number | boolean | null | undefined | HelmConstruct | HelmExpression | {
|
|
24
145
|
[key: string]: HelmContent;
|
|
25
146
|
} | HelmContent[];
|
|
147
|
+
/**
|
|
148
|
+
* Options for whitespace control in Helm templates
|
|
149
|
+
*/
|
|
26
150
|
export interface HelmWhitespaceOptions {
|
|
151
|
+
/** Trim whitespace to the left of the construct ({{-) */
|
|
27
152
|
trimLeft?: boolean;
|
|
153
|
+
/** Trim whitespace to the right of the construct (-}}) */
|
|
28
154
|
trimRight?: boolean;
|
|
155
|
+
/** Render as inline (no newlines) */
|
|
29
156
|
inline?: boolean;
|
|
30
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Conditional rendering helper (if/else)
|
|
160
|
+
*
|
|
161
|
+
* @param condition - Helm template condition expression (e.g., '.Values.enabled')
|
|
162
|
+
* @param thenContent - Content to render if condition is true
|
|
163
|
+
* @param elseContent - Optional content to render if condition is false
|
|
164
|
+
* @param options - Whitespace control options
|
|
165
|
+
* @returns HelmConstruct representing the if/else block
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Simple if
|
|
169
|
+
* helmIf('.Values.enabled', { replicas: 3 })
|
|
170
|
+
* // Output: {{- if .Values.enabled }}
|
|
171
|
+
* // replicas: 3
|
|
172
|
+
* // {{- end }}
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // If-else
|
|
176
|
+
* helmIf('.Values.production',
|
|
177
|
+
* { replicas: 5 },
|
|
178
|
+
* { replicas: 1 }
|
|
179
|
+
* )
|
|
180
|
+
* // Output: {{- if .Values.production }}
|
|
181
|
+
* // replicas: 5
|
|
182
|
+
* // {{- else }}
|
|
183
|
+
* // replicas: 1
|
|
184
|
+
* // {{- end }}
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* // Nested with range
|
|
188
|
+
* helmIf('.Values.enabled', [
|
|
189
|
+
* helmRange('$item', '.Values.items', {
|
|
190
|
+
* name: '{{ $item.name }}',
|
|
191
|
+
* value: '{{ $item.value }}'
|
|
192
|
+
* })
|
|
193
|
+
* ])
|
|
194
|
+
*
|
|
195
|
+
* @since 2.14.0
|
|
196
|
+
*/
|
|
31
197
|
export declare function helmIf(condition: string, thenContent: HelmContent, elseContent?: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
198
|
+
/**
|
|
199
|
+
* Creates a simple Helm if block without else (field-level conditional).
|
|
200
|
+
* This is specifically designed for conditionally including entire fields.
|
|
201
|
+
* When used as a field value, it wraps the field (key + value) in the conditional.
|
|
202
|
+
*
|
|
203
|
+
* @param condition - Helm template condition expression (e.g., '.Values.enabled')
|
|
204
|
+
* @param thenContent - Content to render if condition is true
|
|
205
|
+
* @param options - Whitespace control options
|
|
206
|
+
* @returns HelmConstruct representing the if block that wraps the field
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // Conditionally include replicas field
|
|
210
|
+
* {
|
|
211
|
+
* spec: {
|
|
212
|
+
* replicas: helmIfSimple('not .Values.autoscaling.enabled', helm('{{ .Values.replicaCount }}'))
|
|
213
|
+
* }
|
|
214
|
+
* }
|
|
215
|
+
* // Output:
|
|
216
|
+
* // spec:
|
|
217
|
+
* // {{- if not .Values.autoscaling.enabled }}
|
|
218
|
+
* // replicas: {{ .Values.replicaCount }}
|
|
219
|
+
* // {{- end }}
|
|
220
|
+
*
|
|
221
|
+
* @since 2.14.0
|
|
222
|
+
*/
|
|
32
223
|
export declare function helmIfSimple(condition: string, thenContent: HelmContent, options?: HelmWhitespaceOptions): HelmConstruct;
|
|
224
|
+
/**
|
|
225
|
+
* Check if a value is a HelmConstruct
|
|
226
|
+
*/
|
|
33
227
|
export declare function isHelmConstruct(value: unknown): value is HelmConstruct;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Helm template control structure helpers
|
|
3
|
+
* Provides type-safe, composable helpers for Helm template constructs
|
|
4
|
+
* @since 2.14.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Helm fragment (composite of multiple contents).
|
|
8
|
+
* Useful for combining multiple constructs (e.g. multiple if blocks) into a single field value.
|
|
9
|
+
* @param contents List of Helm content to combine
|
|
10
|
+
* @returns HelmConstruct of type 'fragment'
|
|
11
|
+
*/
|
|
1
12
|
export function helmFragment(...contents) {
|
|
2
13
|
return {
|
|
3
14
|
__helmConstruct: true,
|
|
@@ -5,18 +16,43 @@ export function helmFragment(...contents) {
|
|
|
5
16
|
data: contents,
|
|
6
17
|
};
|
|
7
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a Helm expression marker.
|
|
21
|
+
* @param value Helm template expression string.
|
|
22
|
+
* @returns Helm expression marker object.
|
|
23
|
+
* @since 2.9.2
|
|
24
|
+
*/
|
|
8
25
|
export function createHelmExpression(value) {
|
|
9
26
|
return {
|
|
10
27
|
__helmExpression: true,
|
|
11
28
|
value,
|
|
12
29
|
};
|
|
13
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a value is a Helm expression marker.
|
|
33
|
+
* @param value Value to check.
|
|
34
|
+
* @returns True if value is a Helm expression marker.
|
|
35
|
+
* @since 2.9.2
|
|
36
|
+
*/
|
|
14
37
|
export function isHelmExpression(value) {
|
|
15
38
|
return (typeof value === 'object' &&
|
|
16
39
|
value !== null &&
|
|
17
40
|
'__helmExpression' in value &&
|
|
18
41
|
value.__helmExpression === true);
|
|
19
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Helm range (iteration) block.
|
|
45
|
+
*
|
|
46
|
+
* @param vars - Variable(s) to bind (e.g., 'item', '$key, $value', '$index, $item')
|
|
47
|
+
* @param collection - Helm expression for the collection to iterate (e.g., '.Values.items')
|
|
48
|
+
* @param content - Content to repeat for each iteration
|
|
49
|
+
* @param options - Whitespace control options
|
|
50
|
+
* @returns HelmConstruct of type 'range'
|
|
51
|
+
*
|
|
52
|
+
* helmRange('$key, $value', '.Values.secrets', {
|
|
53
|
+
* [helmVar('$key')]: helmVar('$value')]
|
|
54
|
+
* })
|
|
55
|
+
*/
|
|
20
56
|
export function helmRange(vars, collection, content, options) {
|
|
21
57
|
return {
|
|
22
58
|
__helmConstruct: true,
|
|
@@ -29,6 +65,22 @@ export function helmRange(vars, collection, content, options) {
|
|
|
29
65
|
...(options ? { options } : {}),
|
|
30
66
|
};
|
|
31
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a Helm with block (scope/context switching).
|
|
70
|
+
*
|
|
71
|
+
* @param scope - Helm expression for the scope to switch to (e.g., '.Values.database')
|
|
72
|
+
* @param content - Content to execute with the new scope (where '.' refers to the scope)
|
|
73
|
+
* @param options - Whitespace control options
|
|
74
|
+
* @returns HelmConstruct of type 'with'
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Simplify nested object access
|
|
78
|
+
* helmWith('.Values.database', {
|
|
79
|
+
* host: helm('{{ .host }}'),
|
|
80
|
+
* port: helm('{{ .port }}'),
|
|
81
|
+
* username: helm('{{ .username }}')
|
|
82
|
+
* })
|
|
83
|
+
*/
|
|
32
84
|
export function helmWith(scope, content, options) {
|
|
33
85
|
return {
|
|
34
86
|
__helmConstruct: true,
|
|
@@ -40,6 +92,19 @@ export function helmWith(scope, content, options) {
|
|
|
40
92
|
...(options ? { options } : {}),
|
|
41
93
|
};
|
|
42
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates a Helm include statement (template inclusion).
|
|
97
|
+
*
|
|
98
|
+
* @param templateName - Name of the template to include (e.g., 'myapp.labels')
|
|
99
|
+
* @param scope - Scope to pass to the template (usually '.')
|
|
100
|
+
* @param pipe - Optional pipe operations (e.g., 'nindent 4', 'quote')
|
|
101
|
+
* @param options - Whitespace control options
|
|
102
|
+
* @returns HelmConstruct of type 'include'
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* helmInclude('myapp.labels', '.', { pipe: 'nindent 4' })
|
|
106
|
+
* // Output: {{ include "myapp.labels" . | nindent 4 }}
|
|
107
|
+
*/
|
|
43
108
|
export function helmInclude(templateName, scope = '.', options) {
|
|
44
109
|
return {
|
|
45
110
|
__helmConstruct: true,
|
|
@@ -52,6 +117,20 @@ export function helmInclude(templateName, scope = '.', options) {
|
|
|
52
117
|
...(options ? { options } : {}),
|
|
53
118
|
};
|
|
54
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Creates a Helm define block (template definition).
|
|
122
|
+
*
|
|
123
|
+
* @param name - Name of the template
|
|
124
|
+
* @param content - Template content
|
|
125
|
+
* @param options - Whitespace control options
|
|
126
|
+
* @returns HelmConstruct of type 'define'
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* helmDefine('myapp.labels', {
|
|
130
|
+
* 'app.kubernetes.io/name': helm('{{ .Chart.Name }}'),
|
|
131
|
+
* 'app.kubernetes.io/instance': helm('{{ .Release.Name }}')
|
|
132
|
+
* })
|
|
133
|
+
*/
|
|
55
134
|
export function helmDefine(name, content, options) {
|
|
56
135
|
return {
|
|
57
136
|
__helmConstruct: true,
|
|
@@ -63,6 +142,18 @@ export function helmDefine(name, content, options) {
|
|
|
63
142
|
...(options ? { options } : {}),
|
|
64
143
|
};
|
|
65
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Creates a Helm variable assignment.
|
|
147
|
+
*
|
|
148
|
+
* @param name - Variable name (with $ prefix)
|
|
149
|
+
* @param value - Value to assign
|
|
150
|
+
* @param options - Whitespace control options
|
|
151
|
+
* @returns HelmConstruct of type 'var'
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* helmVar('$fullName', 'include "myapp.fullname" .')
|
|
155
|
+
* // Output: {{ $fullName := include "myapp.fullname" . }}
|
|
156
|
+
*/
|
|
66
157
|
export function helmVar(name, value, options) {
|
|
67
158
|
return {
|
|
68
159
|
__helmConstruct: true,
|
|
@@ -74,6 +165,17 @@ export function helmVar(name, value, options) {
|
|
|
74
165
|
...(options ? { options } : {}),
|
|
75
166
|
};
|
|
76
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Creates a Helm block (named template block).
|
|
170
|
+
*
|
|
171
|
+
* @param name - Block name
|
|
172
|
+
* @param content - Block content
|
|
173
|
+
* @param options - Whitespace control options
|
|
174
|
+
* @returns HelmConstruct of type 'block'
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* helmBlock('myapp.config', { key: 'value' })
|
|
178
|
+
*/
|
|
77
179
|
export function helmBlock(name, content, options) {
|
|
78
180
|
return {
|
|
79
181
|
__helmConstruct: true,
|
|
@@ -85,6 +187,16 @@ export function helmBlock(name, content, options) {
|
|
|
85
187
|
...(options ? { options } : {}),
|
|
86
188
|
};
|
|
87
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Creates a Helm comment block.
|
|
192
|
+
*
|
|
193
|
+
* @param text - Comment text
|
|
194
|
+
* @returns HelmConstruct of type 'comment'
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* helmComment('This is a template comment')
|
|
198
|
+
* // Output: (curly-brace-slash-star) This is a template comment (star-slash-curly-brace)
|
|
199
|
+
*/
|
|
88
200
|
export function helmComment(text) {
|
|
89
201
|
return {
|
|
90
202
|
__helmConstruct: true,
|
|
@@ -92,6 +204,45 @@ export function helmComment(text) {
|
|
|
92
204
|
data: { text },
|
|
93
205
|
};
|
|
94
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Conditional rendering helper (if/else)
|
|
209
|
+
*
|
|
210
|
+
* @param condition - Helm template condition expression (e.g., '.Values.enabled')
|
|
211
|
+
* @param thenContent - Content to render if condition is true
|
|
212
|
+
* @param elseContent - Optional content to render if condition is false
|
|
213
|
+
* @param options - Whitespace control options
|
|
214
|
+
* @returns HelmConstruct representing the if/else block
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* // Simple if
|
|
218
|
+
* helmIf('.Values.enabled', { replicas: 3 })
|
|
219
|
+
* // Output: {{- if .Values.enabled }}
|
|
220
|
+
* // replicas: 3
|
|
221
|
+
* // {{- end }}
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* // If-else
|
|
225
|
+
* helmIf('.Values.production',
|
|
226
|
+
* { replicas: 5 },
|
|
227
|
+
* { replicas: 1 }
|
|
228
|
+
* )
|
|
229
|
+
* // Output: {{- if .Values.production }}
|
|
230
|
+
* // replicas: 5
|
|
231
|
+
* // {{- else }}
|
|
232
|
+
* // replicas: 1
|
|
233
|
+
* // {{- end }}
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* // Nested with range
|
|
237
|
+
* helmIf('.Values.enabled', [
|
|
238
|
+
* helmRange('$item', '.Values.items', {
|
|
239
|
+
* name: '{{ $item.name }}',
|
|
240
|
+
* value: '{{ $item.value }}'
|
|
241
|
+
* })
|
|
242
|
+
* ])
|
|
243
|
+
*
|
|
244
|
+
* @since 2.14.0
|
|
245
|
+
*/
|
|
95
246
|
export function helmIf(condition, thenContent, elseContent, options) {
|
|
96
247
|
return {
|
|
97
248
|
__helmConstruct: true,
|
|
@@ -104,6 +255,31 @@ export function helmIf(condition, thenContent, elseContent, options) {
|
|
|
104
255
|
...(options ? { options } : {}),
|
|
105
256
|
};
|
|
106
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Creates a simple Helm if block without else (field-level conditional).
|
|
260
|
+
* This is specifically designed for conditionally including entire fields.
|
|
261
|
+
* When used as a field value, it wraps the field (key + value) in the conditional.
|
|
262
|
+
*
|
|
263
|
+
* @param condition - Helm template condition expression (e.g., '.Values.enabled')
|
|
264
|
+
* @param thenContent - Content to render if condition is true
|
|
265
|
+
* @param options - Whitespace control options
|
|
266
|
+
* @returns HelmConstruct representing the if block that wraps the field
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* // Conditionally include replicas field
|
|
270
|
+
* {
|
|
271
|
+
* spec: {
|
|
272
|
+
* replicas: helmIfSimple('not .Values.autoscaling.enabled', helm('{{ .Values.replicaCount }}'))
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* // Output:
|
|
276
|
+
* // spec:
|
|
277
|
+
* // {{- if not .Values.autoscaling.enabled }}
|
|
278
|
+
* // replicas: {{ .Values.replicaCount }}
|
|
279
|
+
* // {{- end }}
|
|
280
|
+
*
|
|
281
|
+
* @since 2.14.0
|
|
282
|
+
*/
|
|
107
283
|
export function helmIfSimple(condition, thenContent, options) {
|
|
108
284
|
return {
|
|
109
285
|
__helmConstruct: true,
|
|
@@ -111,11 +287,15 @@ export function helmIfSimple(condition, thenContent, options) {
|
|
|
111
287
|
data: {
|
|
112
288
|
condition,
|
|
113
289
|
then: thenContent,
|
|
290
|
+
// Explicitly set else to undefined to mark this as a field-level conditional
|
|
114
291
|
else: undefined,
|
|
115
292
|
},
|
|
116
293
|
...(options ? { options } : {}),
|
|
117
294
|
};
|
|
118
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Check if a value is a HelmConstruct
|
|
298
|
+
*/
|
|
119
299
|
export function isHelmConstruct(value) {
|
|
120
300
|
return (typeof value === 'object' &&
|
|
121
301
|
value !== null &&
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Environment and configuration management helpers for Helm templates
|
|
3
|
+
* @since 2.11.0
|
|
4
|
+
*/
|
|
1
5
|
import type { HelperDefinition } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Environment and configuration management helpers
|
|
8
|
+
*
|
|
9
|
+
* These helpers provide robust environment variable handling, configuration merging,
|
|
10
|
+
* and environment-specific logic for Helm templates. They support common CI/CD patterns
|
|
11
|
+
* and configuration management best practices.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.11.0
|
|
14
|
+
*/
|
|
2
15
|
export declare const ENV_HELPERS: HelperDefinition[];
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Environment and configuration management helpers for Helm templates
|
|
3
|
+
* @since 2.11.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Environment and configuration management helpers
|
|
7
|
+
*
|
|
8
|
+
* These helpers provide robust environment variable handling, configuration merging,
|
|
9
|
+
* and environment-specific logic for Helm templates. They support common CI/CD patterns
|
|
10
|
+
* and configuration management best practices.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.11.0
|
|
13
|
+
*/
|
|
1
14
|
export const ENV_HELPERS = [
|
|
2
15
|
{
|
|
3
16
|
name: 'env.required',
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GitOps and CI/CD helpers for Helm templates
|
|
3
|
+
* @since 2.11.0
|
|
4
|
+
*/
|
|
1
5
|
import type { HelperDefinition } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* GitOps and CI/CD helpers
|
|
8
|
+
*
|
|
9
|
+
* These helpers provide integration with modern GitOps workflows and CI/CD systems.
|
|
10
|
+
* They support Git metadata, build information, image tagging strategies, and
|
|
11
|
+
* deployment annotations for traceability and auditability.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.11.0
|
|
14
|
+
*/
|
|
2
15
|
export declare const GITOPS_HELPERS: HelperDefinition[];
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GitOps and CI/CD helpers for Helm templates
|
|
3
|
+
* @since 2.11.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* GitOps and CI/CD helpers
|
|
7
|
+
*
|
|
8
|
+
* These helpers provide integration with modern GitOps workflows and CI/CD systems.
|
|
9
|
+
* They support Git metadata, build information, image tagging strategies, and
|
|
10
|
+
* deployment annotations for traceability and auditability.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.11.0
|
|
13
|
+
*/
|
|
1
14
|
export const GITOPS_HELPERS = [
|
|
2
15
|
{
|
|
3
16
|
name: 'git.commitSha',
|
|
@@ -1,19 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main index file for Helm helpers with organized exports and helper management functions
|
|
3
|
+
* @since 2.11.0
|
|
4
|
+
*/
|
|
1
5
|
export type { HelperDefinition, HelperCategory, CloudProvider, HelperOptions } from './types.js';
|
|
2
6
|
export { ENV_HELPERS } from './envHelpers.js';
|
|
3
7
|
export { GITOPS_HELPERS } from './gitopsHelpers.js';
|
|
4
8
|
export { OBSERVABILITY_HELPERS } from './observabilityHelpers.js';
|
|
5
9
|
export { VALIDATION_HELPERS } from './validationHelpers.js';
|
|
6
10
|
import type { HelperDefinition, HelperCategory, HelperOptions } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Performance-optimized helper lookup with O(1) time complexity
|
|
13
|
+
* @param category - Helper category to retrieve
|
|
14
|
+
* @returns Array of helper definitions for the specified category
|
|
15
|
+
* @throws {Error} If category is unknown
|
|
16
|
+
* @since 2.11.0
|
|
17
|
+
*/
|
|
7
18
|
export declare function getNewHelpersByCategory(category: HelperCategory): HelperDefinition[];
|
|
19
|
+
/**
|
|
20
|
+
* Get all available new helper categories
|
|
21
|
+
* @returns Array of available helper categories
|
|
22
|
+
* @since 2.11.0
|
|
23
|
+
*/
|
|
8
24
|
export declare function getAvailableHelperCategories(): HelperCategory[];
|
|
25
|
+
/**
|
|
26
|
+
* Get helpers for multiple categories
|
|
27
|
+
* @param categories - Array of categories to retrieve
|
|
28
|
+
* @returns Combined array of helper definitions
|
|
29
|
+
* @since 2.11.0
|
|
30
|
+
*/
|
|
9
31
|
export declare function getHelpersByCategories(categories: HelperCategory[]): HelperDefinition[];
|
|
32
|
+
/**
|
|
33
|
+
* Get helpers based on options configuration
|
|
34
|
+
* @param options - Configuration options for helper inclusion
|
|
35
|
+
* @returns Array of helper definitions based on options
|
|
36
|
+
* @since 2.11.0
|
|
37
|
+
*/
|
|
10
38
|
export declare function getHelpersByOptions(options: HelperOptions): HelperDefinition[];
|
|
39
|
+
/**
|
|
40
|
+
* Converts helper definitions to Helm template format
|
|
41
|
+
* @param helpers - Array of helper definitions
|
|
42
|
+
* @returns Formatted Helm template string
|
|
43
|
+
* @since 2.11.0
|
|
44
|
+
*/
|
|
11
45
|
export declare function formatNewHelpers(helpers: HelperDefinition[]): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generates complete _helpers.tpl content with new helpers
|
|
48
|
+
* @param options - Configuration options for helper inclusion
|
|
49
|
+
* @param customHelpers - Additional custom helpers
|
|
50
|
+
* @returns Complete helpers template content
|
|
51
|
+
* @since 2.11.0
|
|
52
|
+
*/
|
|
12
53
|
export declare function generateNewHelpersTemplate(options?: HelperOptions, customHelpers?: HelperDefinition[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* Cached helper compilation for better performance
|
|
56
|
+
* @param options - Configuration options for helper inclusion
|
|
57
|
+
* @param customHelpers - Additional custom helpers
|
|
58
|
+
* @returns Complete helpers template content from cache or newly generated
|
|
59
|
+
* @since 2.11.0
|
|
60
|
+
*/
|
|
13
61
|
export declare function getCachedNewHelpersTemplate(options?: HelperOptions, customHelpers?: HelperDefinition[]): string;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a custom helper definition
|
|
64
|
+
* @param name - Helper name
|
|
65
|
+
* @param template - Helper template content
|
|
66
|
+
* @returns Helper definition object
|
|
67
|
+
* @since 2.11.0
|
|
68
|
+
*/
|
|
14
69
|
export declare function createNewHelper(name: string, template: string): HelperDefinition;
|
|
70
|
+
/**
|
|
71
|
+
* Validates helper names for Helm compatibility
|
|
72
|
+
* @param helpers - Array of helper definitions to validate
|
|
73
|
+
* @throws {Error} If any helper has an invalid name
|
|
74
|
+
* @since 2.11.0
|
|
75
|
+
*/
|
|
15
76
|
export declare function validateHelperNames(helpers: HelperDefinition[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Filters helpers by name pattern
|
|
79
|
+
* @param helpers - Array of helper definitions to filter
|
|
80
|
+
* @param pattern - RegExp pattern to match against helper names
|
|
81
|
+
* @returns Filtered array of helper definitions
|
|
82
|
+
* @since 2.11.0
|
|
83
|
+
*/
|
|
16
84
|
export declare function filterHelpersByPattern(helpers: HelperDefinition[], pattern: RegExp): HelperDefinition[];
|
|
85
|
+
/**
|
|
86
|
+
* Gets helper statistics for analysis
|
|
87
|
+
* @param helpers - Array of helper definitions to analyze
|
|
88
|
+
* @returns Statistics about the helpers
|
|
89
|
+
* @since 2.11.0
|
|
90
|
+
*/
|
|
17
91
|
export declare function getHelperStatistics(helpers: HelperDefinition[]): {
|
|
18
92
|
totalHelpers: number;
|
|
19
93
|
categoryCounts: Record<string, number>;
|