timonel 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +43 -809
- package/SECURITY.md +55 -20
- package/dist/cli.js +29 -31
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/HelmChartWriter.d.ts +185 -16
- package/dist/lib/HelmChartWriter.d.ts.map +1 -1
- package/dist/lib/HelmChartWriter.js +239 -45
- package/dist/lib/HelmChartWriter.js.map +1 -1
- package/dist/lib/Rutter.d.ts +1738 -104
- package/dist/lib/Rutter.d.ts.map +1 -1
- package/dist/lib/Rutter.js +1087 -9
- package/dist/lib/Rutter.js.map +1 -1
- package/dist/lib/UmbrellaRutter.d.ts.map +1 -1
- package/dist/lib/UmbrellaRutter.js +28 -22
- package/dist/lib/UmbrellaRutter.js.map +1 -1
- package/dist/lib/helm.d.ts +200 -12
- package/dist/lib/helm.d.ts.map +1 -1
- package/dist/lib/helm.js +234 -13
- package/dist/lib/helm.js.map +1 -1
- package/dist/lib/security.d.ts +52 -0
- package/dist/lib/security.d.ts.map +1 -0
- package/dist/lib/security.js +117 -0
- package/dist/lib/security.js.map +1 -0
- package/package.json +1 -1
package/dist/lib/helm.d.ts
CHANGED
|
@@ -1,32 +1,220 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helpers to embed Helm template expressions while staying type-safe in
|
|
2
|
+
* @fileoverview Helpers to embed Helm template expressions while staying type-safe in TypeScript.
|
|
3
3
|
* We treat Helm placeholders as opaque strings that will be preserved in YAML.
|
|
4
|
+
* @since 0.1.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 0.1.0
|
|
4
26
|
*/
|
|
5
|
-
/** Create a .Values reference like {{ .Values.key }} */
|
|
6
27
|
export declare function valuesRef(path: string): string;
|
|
7
|
-
/**
|
|
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 0.1.0
|
|
49
|
+
*/
|
|
8
50
|
export declare function requiredValuesRef(path: string, message?: string): string;
|
|
9
|
-
/**
|
|
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 0.1.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
|
+
*/
|
|
10
69
|
export declare const helm: {
|
|
70
|
+
/** Release name: {{ .Release.Name }} */
|
|
11
71
|
releaseName: string;
|
|
72
|
+
/** Chart name: {{ .Chart.Name }} */
|
|
12
73
|
chartName: string;
|
|
74
|
+
/** Chart version: {{ .Chart.Version }} */
|
|
13
75
|
chartVersion: string;
|
|
76
|
+
/** Release namespace: {{ .Release.Namespace }} */
|
|
14
77
|
namespace: string;
|
|
15
78
|
};
|
|
16
|
-
/**
|
|
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 0.1.0
|
|
98
|
+
*/
|
|
17
99
|
export declare function quote(expr: string): string;
|
|
18
|
-
/**
|
|
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 0.1.0
|
|
117
|
+
*/
|
|
19
118
|
export declare function indent(n: number, expr: string): string;
|
|
20
|
-
/**
|
|
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 0.1.0
|
|
133
|
+
*/
|
|
21
134
|
export declare function template(name: string, context?: string): string;
|
|
22
|
-
/**
|
|
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 0.1.0
|
|
151
|
+
*/
|
|
23
152
|
export declare function include(name: string, context?: string): string;
|
|
24
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Creates a numeric reference from .Values with int cast
|
|
155
|
+
*
|
|
156
|
+
* Generates a Helm template expression that casts the value to integer,
|
|
157
|
+
* truncating any decimal places.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} path - Path to the value using dot notation
|
|
160
|
+
* @returns {string} Helm template expression with int cast
|
|
161
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const replicas = numberRef('deployment.replicas');
|
|
166
|
+
* // Returns: '{{ .Values.deployment.replicas | int }}'
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @since 0.1.0
|
|
170
|
+
*/
|
|
25
171
|
export declare function numberRef(path: string): string;
|
|
26
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Creates a boolean reference from .Values with toBool cast
|
|
174
|
+
*
|
|
175
|
+
* @param {string} path - Path to the value using dot notation
|
|
176
|
+
* @returns {string} Helm template expression with toBool cast
|
|
177
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const enabled = boolRef('feature.enabled');
|
|
182
|
+
* // Returns: '{{ .Values.feature.enabled | toBool }}'
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @since 0.1.0
|
|
186
|
+
*/
|
|
27
187
|
export declare function boolRef(path: string): string;
|
|
28
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* Creates a string reference from .Values with toString cast
|
|
190
|
+
*
|
|
191
|
+
* @param {string} path - Path to the value using dot notation
|
|
192
|
+
* @returns {string} Helm template expression with toString cast
|
|
193
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const version = stringRef('app.version');
|
|
198
|
+
* // Returns: '{{ .Values.app.version | toString }}'
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @since 0.1.0
|
|
202
|
+
*/
|
|
29
203
|
export declare function stringRef(path: string): string;
|
|
30
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* Creates a float reference from .Values with float64 cast
|
|
206
|
+
*
|
|
207
|
+
* @param {string} path - Path to the value using dot notation
|
|
208
|
+
* @returns {string} Helm template expression with float64 cast
|
|
209
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const ratio = floatRef('scaling.ratio');
|
|
214
|
+
* // Returns: '{{ .Values.scaling.ratio | float64 }}'
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @since 0.1.0
|
|
218
|
+
*/
|
|
31
219
|
export declare function floatRef(path: string): string;
|
|
32
220
|
//# sourceMappingURL=helm.d.ts.map
|
package/dist/lib/helm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"helm.d.ts","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAQxE;AAeD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI;IACf,wCAAwC;;IAExC,oCAAoC;;IAEpC,0CAA0C;;IAE1C,kDAAkD;;CAEnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7C"}
|
package/dist/lib/helm.js
CHANGED
|
@@ -1,24 +1,127 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helpers to embed Helm template expressions while staying type-safe in
|
|
2
|
+
* @fileoverview Helpers to embed Helm template expressions while staying type-safe in TypeScript.
|
|
3
3
|
* We treat Helm placeholders as opaque strings that will be preserved in YAML.
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
import { SecurityUtils } from './security.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a reference to a value in .Values of Helm
|
|
9
|
+
*
|
|
10
|
+
* Generates a Helm template expression that references a value
|
|
11
|
+
* in the chart's values.yaml file using dot notation.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} path - Path to the value using dot notation (e.g., 'image.tag')
|
|
14
|
+
* @returns {string} Helm template expression (e.g., '{{ .Values.image.tag }}')
|
|
15
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const imageTag = valuesRef('image.tag');
|
|
20
|
+
* // Returns: '{{ .Values.image.tag }}'
|
|
21
|
+
*
|
|
22
|
+
* const replicas = valuesRef('deployment.replicas');
|
|
23
|
+
* // Returns: '{{ .Values.deployment.replicas }}'
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 0.1.0
|
|
4
27
|
*/
|
|
5
|
-
/** Create a .Values reference like {{ .Values.key }} */
|
|
6
28
|
export function valuesRef(path) {
|
|
29
|
+
if (!isValidHelmPath(path)) {
|
|
30
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
31
|
+
}
|
|
7
32
|
return `{{ .Values.${path} }}`;
|
|
8
33
|
}
|
|
9
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Creates a required reference to a value in .Values of Helm
|
|
36
|
+
*
|
|
37
|
+
* Similar to valuesRef, but uses Helm's 'required' function to
|
|
38
|
+
* ensure the value is present, failing chart rendering if not provided.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} path - Path to the value using dot notation
|
|
41
|
+
* @param {string} [message] - Custom error message if value is missing
|
|
42
|
+
* @returns {string} Helm template expression with required validation
|
|
43
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const dbPassword = requiredValuesRef('database.password', 'Database password is required');
|
|
48
|
+
* // Returns: '{{ required "Database password is required" .Values.database.password }}'
|
|
49
|
+
*
|
|
50
|
+
* const apiKey = requiredValuesRef('api.key');
|
|
51
|
+
* // Returns: '{{ required "api.key is required" .Values.api.key }}'
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @since 0.1.0
|
|
55
|
+
*/
|
|
10
56
|
export function requiredValuesRef(path, message) {
|
|
57
|
+
if (!isValidHelmPath(path)) {
|
|
58
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
59
|
+
}
|
|
11
60
|
const msg = message ?? `${path} is required`;
|
|
12
|
-
|
|
61
|
+
// Escape quotes and backslashes in message to prevent template injection
|
|
62
|
+
const escapedMsg = msg.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
63
|
+
return `{{ required "${escapedMsg}" .Values.${path} }}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates Helm template path syntax with enhanced security
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
* @param {string} path - Path to validate
|
|
70
|
+
* @returns {boolean} True if path is valid for Helm templates
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
*/
|
|
73
|
+
function isValidHelmPath(path) {
|
|
74
|
+
// Use centralized validation from SecurityUtils
|
|
75
|
+
return SecurityUtils.isValidHelmTemplatePath(path);
|
|
13
76
|
}
|
|
14
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Built-in Helm references for release and chart metadata
|
|
79
|
+
*
|
|
80
|
+
* Object containing the most common references to Helm's built-in
|
|
81
|
+
* variables for release and chart information.
|
|
82
|
+
*
|
|
83
|
+
* @namespace helm
|
|
84
|
+
* @since 0.1.0
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const deploymentName = `${helm.releaseName}-deployment`;
|
|
89
|
+
* // Uses: '{{ .Release.Name }}-deployment'
|
|
90
|
+
*
|
|
91
|
+
* const version = helm.chartVersion;
|
|
92
|
+
* // Uses: '{{ .Chart.Version }}'
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
15
95
|
export const helm = {
|
|
96
|
+
/** Release name: {{ .Release.Name }} */
|
|
16
97
|
releaseName: '{{ .Release.Name }}',
|
|
98
|
+
/** Chart name: {{ .Chart.Name }} */
|
|
17
99
|
chartName: '{{ .Chart.Name }}',
|
|
100
|
+
/** Chart version: {{ .Chart.Version }} */
|
|
18
101
|
chartVersion: '{{ .Chart.Version }}',
|
|
102
|
+
/** Release namespace: {{ .Release.Namespace }} */
|
|
19
103
|
namespace: '{{ .Release.Namespace }}',
|
|
20
104
|
};
|
|
21
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Quotes a Helm template expression for safe YAML embedding
|
|
107
|
+
*
|
|
108
|
+
* Ensures Helm template expressions are properly quoted to avoid
|
|
109
|
+
* YAML parsing issues when the expression contains special characters.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} expr - Helm template expression to quote
|
|
112
|
+
* @returns {string} Quoted expression if it's a Helm template, otherwise unchanged
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const quoted = quote('{{ .Values.image.tag }}');
|
|
117
|
+
* // Returns: "'{{ .Values.image.tag }}'"
|
|
118
|
+
*
|
|
119
|
+
* const normal = quote('nginx:1.21');
|
|
120
|
+
* // Returns: "nginx:1.21"
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @since 0.1.0
|
|
124
|
+
*/
|
|
22
125
|
export function quote(expr) {
|
|
23
126
|
// ensure Helm templates are quoted to avoid YAML parsing issues
|
|
24
127
|
if (expr.startsWith('{{') && expr.endsWith('}}')) {
|
|
@@ -26,7 +129,24 @@ export function quote(expr) {
|
|
|
26
129
|
}
|
|
27
130
|
return expr;
|
|
28
131
|
}
|
|
29
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Indents text by specified number of spaces
|
|
134
|
+
*
|
|
135
|
+
* Helper function that matches Helm's indent function behavior,
|
|
136
|
+
* adding the specified number of spaces to each non-empty line.
|
|
137
|
+
*
|
|
138
|
+
* @param {number} n - Number of spaces to indent
|
|
139
|
+
* @param {string} expr - Text to indent
|
|
140
|
+
* @returns {string} Indented text
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const indented = indent(4, 'line1\nline2');
|
|
145
|
+
* // Returns: " line1\n line2"
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @since 0.1.0
|
|
149
|
+
*/
|
|
30
150
|
export function indent(n, expr) {
|
|
31
151
|
const spaces = ' '.repeat(n);
|
|
32
152
|
return expr
|
|
@@ -34,28 +154,129 @@ export function indent(n, expr) {
|
|
|
34
154
|
.map((l) => (l.trim().length ? spaces + l : l))
|
|
35
155
|
.join('\n');
|
|
36
156
|
}
|
|
37
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Inserts a call to a named Helm template using template function
|
|
159
|
+
*
|
|
160
|
+
* @param {string} name - Name of the template to call
|
|
161
|
+
* @param {string} [context='.'] - Context to pass to the template
|
|
162
|
+
* @returns {string} Helm template expression
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const tmpl = template('myapp.labels');
|
|
167
|
+
* // Returns: '{{ template "myapp.labels" . }}'
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @since 0.1.0
|
|
171
|
+
*/
|
|
38
172
|
export function template(name, context = '.') {
|
|
39
173
|
return `{{ template "${name}" ${context} }}`;
|
|
40
174
|
}
|
|
41
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Inserts a call to a named Helm template using include function
|
|
177
|
+
*
|
|
178
|
+
* Preferred over template() as include allows piping and better error handling.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} name - Name of the template to include
|
|
181
|
+
* @param {string} [context='.'] - Context to pass to the template
|
|
182
|
+
* @returns {string} Helm template expression
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* const tmpl = include('myapp.labels');
|
|
187
|
+
* // Returns: '{{ include "myapp.labels" . }}'
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @since 0.1.0
|
|
191
|
+
*/
|
|
42
192
|
export function include(name, context = '.') {
|
|
43
193
|
return `{{ include "${name}" ${context} }}`;
|
|
44
194
|
}
|
|
45
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* Creates a numeric reference from .Values with int cast
|
|
197
|
+
*
|
|
198
|
+
* Generates a Helm template expression that casts the value to integer,
|
|
199
|
+
* truncating any decimal places.
|
|
200
|
+
*
|
|
201
|
+
* @param {string} path - Path to the value using dot notation
|
|
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 0.1.0
|
|
212
|
+
*/
|
|
46
213
|
export function numberRef(path) {
|
|
214
|
+
if (!isValidHelmPath(path)) {
|
|
215
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
216
|
+
}
|
|
47
217
|
return `{{ .Values.${path} | int }}`;
|
|
48
218
|
}
|
|
49
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Creates a boolean reference from .Values with toBool cast
|
|
221
|
+
*
|
|
222
|
+
* @param {string} path - Path to the value using dot notation
|
|
223
|
+
* @returns {string} Helm template expression with toBool cast
|
|
224
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const enabled = boolRef('feature.enabled');
|
|
229
|
+
* // Returns: '{{ .Values.feature.enabled | toBool }}'
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @since 0.1.0
|
|
233
|
+
*/
|
|
50
234
|
export function boolRef(path) {
|
|
235
|
+
if (!isValidHelmPath(path)) {
|
|
236
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
237
|
+
}
|
|
51
238
|
return `{{ .Values.${path} | toBool }}`;
|
|
52
239
|
}
|
|
53
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Creates a string reference from .Values with toString cast
|
|
242
|
+
*
|
|
243
|
+
* @param {string} path - Path to the value using dot notation
|
|
244
|
+
* @returns {string} Helm template expression with toString cast
|
|
245
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const version = stringRef('app.version');
|
|
250
|
+
* // Returns: '{{ .Values.app.version | toString }}'
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @since 0.1.0
|
|
254
|
+
*/
|
|
54
255
|
export function stringRef(path) {
|
|
256
|
+
if (!isValidHelmPath(path)) {
|
|
257
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
258
|
+
}
|
|
55
259
|
return `{{ .Values.${path} | toString }}`;
|
|
56
260
|
}
|
|
57
|
-
/**
|
|
261
|
+
/**
|
|
262
|
+
* Creates a float reference from .Values with float64 cast
|
|
263
|
+
*
|
|
264
|
+
* @param {string} path - Path to the value using dot notation
|
|
265
|
+
* @returns {string} Helm template expression with float64 cast
|
|
266
|
+
* @throws {Error} If the path is not valid for Helm templates
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* const ratio = floatRef('scaling.ratio');
|
|
271
|
+
* // Returns: '{{ .Values.scaling.ratio | float64 }}'
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* @since 0.1.0
|
|
275
|
+
*/
|
|
58
276
|
export function floatRef(path) {
|
|
277
|
+
if (!isValidHelmPath(path)) {
|
|
278
|
+
throw new Error(`Invalid Helm template path: ${path}`);
|
|
279
|
+
}
|
|
59
280
|
return `{{ .Values.${path} | float64 }}`;
|
|
60
281
|
}
|
|
61
282
|
//# sourceMappingURL=helm.js.map
|
package/dist/lib/helm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"helm.js","sourceRoot":"","sources":["../../src/lib/helm.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security utilities for input validation and sanitization
|
|
3
|
+
* Focused on CLI tool security concerns: path traversal, injection prevention
|
|
4
|
+
*/
|
|
5
|
+
export declare class SecurityUtils {
|
|
6
|
+
/**
|
|
7
|
+
* Validates and sanitizes file paths to prevent path traversal attacks
|
|
8
|
+
* @param inputPath - The path to validate
|
|
9
|
+
* @param allowedBasePath - The base path that the input should be within
|
|
10
|
+
* @returns Sanitized path if valid
|
|
11
|
+
* @throws Error if path is invalid or contains traversal sequences
|
|
12
|
+
*/
|
|
13
|
+
static validatePath(inputPath: string, allowedBasePath: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Sanitizes log messages to prevent log injection attacks
|
|
16
|
+
* @param message - The message to sanitize
|
|
17
|
+
* @returns Sanitized message with control characters removed
|
|
18
|
+
*/
|
|
19
|
+
static sanitizeLogMessage(message: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Sanitizes environment names to prevent path traversal (CWE-22)
|
|
22
|
+
* @param env - Environment name to sanitize
|
|
23
|
+
* @returns Sanitized environment name
|
|
24
|
+
* @throws Error if environment name is invalid
|
|
25
|
+
*/
|
|
26
|
+
static sanitizeEnvironmentName(env: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Validates TypeScript file extensions for dynamic imports
|
|
29
|
+
* @param filePath - The file path to validate
|
|
30
|
+
* @returns True if the file has a valid TypeScript extension
|
|
31
|
+
*/
|
|
32
|
+
static isValidTypeScriptFile(filePath: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Validates Helm template path syntax
|
|
35
|
+
* @param templatePath - The template path to validate
|
|
36
|
+
* @returns True if the path is valid for Helm templates
|
|
37
|
+
*/
|
|
38
|
+
static isValidHelmTemplatePath(templatePath: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Validates chart names according to Helm conventions
|
|
41
|
+
* @param chartName - Chart name to validate
|
|
42
|
+
* @returns True if chart name follows Helm naming rules
|
|
43
|
+
*/
|
|
44
|
+
static isValidChartName(chartName: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Validates subchart names according to Helm conventions
|
|
47
|
+
* @param subchartName - Subchart name to validate
|
|
48
|
+
* @returns True if subchart name is valid
|
|
49
|
+
*/
|
|
50
|
+
static isValidSubchartName(subchartName: string): boolean;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/lib/security.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,aAAa;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;IA2BvE;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAgBlD;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAmBnD;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMvD;;;;OAIG;IACH,MAAM,CAAC,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAU7D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAWnD;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;CAG1D"}
|