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,102 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe Helm values reference system.
|
|
3
|
+
*
|
|
4
|
+
* ValuesRef exposes the shape of the caller-provided values interface while
|
|
5
|
+
* preserving a runtime proxy that renders Helm expressions.
|
|
6
|
+
*/
|
|
1
7
|
import { type HelmExpression } from './helmControlStructures.js';
|
|
2
8
|
declare const HELM_VALUE_SYMBOL: unique symbol;
|
|
9
|
+
type HelmScalar = string | number | boolean;
|
|
10
|
+
type ArrayElement<T> = T extends readonly (infer U)[] ? U : never;
|
|
11
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
12
|
+
type RuntimeReservedValueKey = 'toJSON' | 'toString' | 'valueOf';
|
|
13
|
+
type HelmValueReservedKey = Extract<keyof HelmValue<unknown>, string> | RuntimeReservedValueKey;
|
|
14
|
+
/**
|
|
15
|
+
* A Helm value reference with mapped properties that mirror the supplied
|
|
16
|
+
* TypeScript value shape. Keys reserved by the ValuesRef API remain accessible
|
|
17
|
+
* through the typed `at()` accessor.
|
|
18
|
+
*/
|
|
19
|
+
export type HelmValueRef<T> = HelmValue<T> & (T extends readonly unknown[] ? object : T extends object ? {
|
|
20
|
+
readonly [K in Exclude<StringKeyOf<T>, HelmValueReservedKey>]-?: HelmValueRef<T[K]>;
|
|
21
|
+
} : object);
|
|
22
|
+
/**
|
|
23
|
+
* Reference to a Helm value or scoped Helm expression.
|
|
24
|
+
*
|
|
25
|
+
* Instances are runtime proxies. The generic type preserves the shape of the referenced value
|
|
26
|
+
* while helper methods compose Helm/Sprig expressions.
|
|
27
|
+
*/
|
|
3
28
|
export interface HelmValue<T = unknown> {
|
|
29
|
+
/** Internal runtime marker used by Timonel serializers. */
|
|
4
30
|
[HELM_VALUE_SYMBOL]: true;
|
|
31
|
+
/** Internal Helm expression path represented by this proxy. */
|
|
5
32
|
__path: string;
|
|
33
|
+
/** Type-only marker; it is not populated at runtime. */
|
|
6
34
|
__type?: T;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Access a typed property whose name collides with a ValuesRef method or root helper.
|
|
37
|
+
* @param key - Property key from the current TypeScript values type
|
|
38
|
+
* @returns A typed proxy for the nested value
|
|
39
|
+
*/
|
|
40
|
+
at<K extends StringKeyOf<T>>(key: K): HelmValueRef<T[K]>;
|
|
41
|
+
/** Compare the value for equality. */
|
|
42
|
+
eq(value: HelmValueRef<unknown> | HelmScalar): HelmCondition;
|
|
43
|
+
/** Compare the value for inequality. */
|
|
44
|
+
ne(value: HelmValueRef<unknown> | HelmScalar): HelmCondition;
|
|
45
|
+
/** Compare whether the value is greater than another numeric value/reference. */
|
|
46
|
+
gt(value: HelmValueRef<unknown> | number): HelmCondition;
|
|
47
|
+
/** Compare whether the value is greater than or equal to another numeric value/reference. */
|
|
48
|
+
ge(value: HelmValueRef<unknown> | number): HelmCondition;
|
|
49
|
+
/** Compare whether the value is less than another numeric value/reference. */
|
|
50
|
+
lt(value: HelmValueRef<unknown> | number): HelmCondition;
|
|
51
|
+
/** Compare whether the value is less than or equal to another numeric value/reference. */
|
|
52
|
+
le(value: HelmValueRef<unknown> | number): HelmCondition;
|
|
53
|
+
/** Negate the truthiness of the referenced Helm value. */
|
|
13
54
|
not(): HelmCondition;
|
|
55
|
+
/** Combine the referenced value with another condition using Helm `and`. */
|
|
14
56
|
and(other: HelmCondition): HelmCondition;
|
|
57
|
+
/** Combine the referenced value with another condition using Helm `or`. */
|
|
15
58
|
or(other: HelmCondition): HelmCondition;
|
|
16
|
-
default
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
/** Apply Helm `default` while preserving the referenced value type. */
|
|
60
|
+
default(defaultValue: HelmValueRef<unknown> | HelmScalar): HelmValueRef<T>;
|
|
61
|
+
/** Pipe the value through `quote`. */
|
|
62
|
+
quote(): HelmValueRef<string>;
|
|
63
|
+
/** Pipe the value through `upper`. */
|
|
64
|
+
upper(): HelmValueRef<string>;
|
|
65
|
+
/** Pipe the value through `lower`. */
|
|
66
|
+
lower(): HelmValueRef<string>;
|
|
67
|
+
/** Pipe the value through `title`. */
|
|
68
|
+
title(): HelmValueRef<string>;
|
|
69
|
+
/** Pipe the value through `trim`. */
|
|
70
|
+
trim(): HelmValueRef<string>;
|
|
71
|
+
/** Remove a prefix with Sprig `trimPrefix`. */
|
|
72
|
+
trimPrefix(prefix: string): HelmValueRef<string>;
|
|
73
|
+
/** Remove a suffix with Sprig `trimSuffix`. */
|
|
74
|
+
trimSuffix(suffix: string): HelmValueRef<string>;
|
|
75
|
+
/** Replace string occurrences with Sprig `replace`. */
|
|
76
|
+
replace(old: string, newStr: string): HelmValueRef<string>;
|
|
77
|
+
/** Test whether the referenced string contains a substring. */
|
|
25
78
|
contains(substr: string): HelmCondition;
|
|
79
|
+
/** Test whether the referenced string starts with a prefix. */
|
|
26
80
|
hasPrefix(prefix: string): HelmCondition;
|
|
81
|
+
/** Test whether the referenced string ends with a suffix. */
|
|
27
82
|
hasSuffix(suffix: string): HelmCondition;
|
|
28
|
-
|
|
83
|
+
/** Truncate the referenced string to the requested length. */
|
|
84
|
+
trunc(length: number): HelmValueRef<string>;
|
|
85
|
+
/** Test the Helm runtime kind of the referenced value. */
|
|
29
86
|
kindIs(kind: 'string' | 'slice' | 'map' | 'bool' | 'int' | 'float'): HelmCondition;
|
|
87
|
+
/** Test whether the referenced map contains a key. */
|
|
30
88
|
hasKey(key: string): HelmCondition;
|
|
31
|
-
toYaml
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
89
|
+
/** Serialize the referenced value with Helm `toYaml`. */
|
|
90
|
+
toYaml(): HelmValueRef<string>;
|
|
91
|
+
/** Serialize the referenced value with Helm `toJson`. */
|
|
92
|
+
toJson(): HelmValueRef<string>;
|
|
93
|
+
/** Apply Helm/Sprig `nindent`. */
|
|
94
|
+
nindent(spaces: number): HelmValueRef<string>;
|
|
95
|
+
/** Apply Helm/Sprig `indent`. */
|
|
96
|
+
indent(spaces: number): HelmValueRef<string>;
|
|
97
|
+
/** Convert the proxy to Timonel's lower-level HelmExpression marker. */
|
|
35
98
|
toExpression(): HelmExpression;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Conditionally include a field value during Helm rendering.
|
|
101
|
+
* @param condition - Helm condition or value whose truthiness controls inclusion
|
|
102
|
+
* @param thenValue - Value emitted when the condition succeeds
|
|
103
|
+
*/
|
|
104
|
+
if<V>(condition: HelmCondition | HelmValueRef<unknown>, thenValue: V): HelmFieldConditional<V>;
|
|
105
|
+
/**
|
|
106
|
+
* Build a Helm ternary expression.
|
|
107
|
+
* @param condition - Condition selecting between the two values
|
|
108
|
+
* @param thenValue - Value returned when the condition is true
|
|
109
|
+
* @param elseValue - Value returned when the condition is false
|
|
110
|
+
*/
|
|
111
|
+
ifElse<V extends HelmValueRef<unknown> | HelmScalar>(condition: HelmCondition, thenValue: V, elseValue: V): HelmValueRef<V extends HelmValueRef<infer U> ? U : V>;
|
|
112
|
+
/**
|
|
113
|
+
* Create a typed Helm `range` block over an array value.
|
|
114
|
+
* @param callback - Callback receiving typed item and index proxies
|
|
115
|
+
*/
|
|
116
|
+
range<V>(callback: (item: HelmValueRef<ArrayElement<T>>, index: HelmValueRef<number>) => V): HelmRange<V, ArrayElement<T>>;
|
|
117
|
+
/**
|
|
118
|
+
* Create a Helm `with` block scoped to the referenced value.
|
|
119
|
+
* @param callback - Callback receiving a proxy rooted at Helm `.` within the block
|
|
120
|
+
*/
|
|
121
|
+
with<V>(callback: (ctx: HelmValueRef<T>) => V): HelmWith<V, T>;
|
|
40
122
|
}
|
|
123
|
+
/** Represents a composable Helm boolean condition. */
|
|
41
124
|
export interface HelmCondition {
|
|
125
|
+
/** Internal runtime marker used by Timonel serializers. */
|
|
42
126
|
[HELM_VALUE_SYMBOL]: true;
|
|
127
|
+
/** Raw Helm condition body without template delimiters. */
|
|
43
128
|
__condition: string;
|
|
129
|
+
/** Negate this condition. */
|
|
44
130
|
not(): HelmCondition;
|
|
131
|
+
/** Combine this condition with another using Helm `and`. */
|
|
45
132
|
and(other: HelmCondition): HelmCondition;
|
|
133
|
+
/** Combine this condition with another using Helm `or`. */
|
|
46
134
|
or(other: HelmCondition): HelmCondition;
|
|
135
|
+
/** Return the raw Helm condition body. */
|
|
47
136
|
toString(): string;
|
|
48
137
|
}
|
|
138
|
+
/** Represents a field-level conditional consumed by the Helm YAML serializer. */
|
|
49
139
|
export interface HelmFieldConditional<T> {
|
|
140
|
+
/** Runtime marker for serializer detection. */
|
|
50
141
|
__helmFieldConditional: true;
|
|
142
|
+
/** Condition controlling whether the field is emitted. */
|
|
51
143
|
condition: HelmCondition;
|
|
144
|
+
/** Field value emitted when the condition succeeds. */
|
|
52
145
|
thenValue: T;
|
|
146
|
+
/** Optional compatibility else value. */
|
|
53
147
|
elseValue?: T;
|
|
54
148
|
}
|
|
55
|
-
|
|
149
|
+
/** Represents a typed Helm `range` block. */
|
|
150
|
+
export interface HelmRange<T, TItem = unknown> {
|
|
151
|
+
/** Runtime marker for serializer detection. */
|
|
56
152
|
__helmRange: true;
|
|
57
|
-
|
|
58
|
-
|
|
153
|
+
/** Array value being iterated. */
|
|
154
|
+
source: HelmValueRef<readonly TItem[]>;
|
|
155
|
+
/** Callback used by the serializer with scoped item/index proxies. */
|
|
156
|
+
callback: (item: HelmValueRef<TItem>, index: HelmValueRef<number>) => T;
|
|
59
157
|
}
|
|
60
|
-
|
|
158
|
+
/** Represents a typed Helm `with` block. */
|
|
159
|
+
export interface HelmWith<T, TContext = unknown> {
|
|
160
|
+
/** Runtime marker for serializer detection. */
|
|
61
161
|
__helmWith: true;
|
|
62
|
-
|
|
63
|
-
|
|
162
|
+
/** Value that becomes the Helm `.` scope. */
|
|
163
|
+
source: HelmValueRef<TContext>;
|
|
164
|
+
/** Callback used by the serializer with a scoped context proxy. */
|
|
165
|
+
callback: (ctx: HelmValueRef<TContext>) => T;
|
|
64
166
|
}
|
|
167
|
+
/** Helper context for Helm built-ins exposed on the root `ValuesRef`. */
|
|
65
168
|
export interface HelmHelpers {
|
|
66
|
-
include
|
|
67
|
-
|
|
169
|
+
/** Render Helm `include` for a named template and context. */
|
|
170
|
+
include(templateName: string, context?: '.' | HelmValueRef<unknown>): HelmValueRef<string>;
|
|
171
|
+
/** Render Helm `printf` with typed value references or scalar arguments. */
|
|
172
|
+
printf(format: string, ...args: Array<HelmValueRef<unknown> | string | number>): HelmValueRef<string>;
|
|
173
|
+
/** References to Helm `.Release` built-ins. */
|
|
68
174
|
release: {
|
|
69
|
-
name:
|
|
70
|
-
namespace:
|
|
71
|
-
service:
|
|
72
|
-
isUpgrade:
|
|
73
|
-
isInstall:
|
|
74
|
-
revision:
|
|
175
|
+
name: HelmValueRef<string>;
|
|
176
|
+
namespace: HelmValueRef<string>;
|
|
177
|
+
service: HelmValueRef<string>;
|
|
178
|
+
isUpgrade: HelmValueRef<boolean>;
|
|
179
|
+
isInstall: HelmValueRef<boolean>;
|
|
180
|
+
revision: HelmValueRef<number>;
|
|
75
181
|
};
|
|
182
|
+
/** References to Helm `.Chart` built-ins. */
|
|
76
183
|
chart: {
|
|
77
|
-
name:
|
|
78
|
-
version:
|
|
79
|
-
appVersion:
|
|
80
|
-
type:
|
|
184
|
+
name: HelmValueRef<string>;
|
|
185
|
+
version: HelmValueRef<string>;
|
|
186
|
+
appVersion: HelmValueRef<string>;
|
|
187
|
+
type: HelmValueRef<string>;
|
|
81
188
|
};
|
|
189
|
+
/** References to selected Helm `.Capabilities` built-ins. */
|
|
82
190
|
capabilities: {
|
|
83
191
|
kubeVersion: {
|
|
84
|
-
version:
|
|
85
|
-
major:
|
|
86
|
-
minor:
|
|
192
|
+
version: HelmValueRef<string>;
|
|
193
|
+
major: HelmValueRef<string>;
|
|
194
|
+
minor: HelmValueRef<string>;
|
|
87
195
|
};
|
|
88
196
|
apiVersions: {
|
|
197
|
+
/** Test whether the target cluster advertises a Kubernetes API version. */
|
|
89
198
|
has(apiVersion: string): HelmCondition;
|
|
90
199
|
};
|
|
91
200
|
};
|
|
201
|
+
/** Escape hatch for conditions that cannot be expressed through typed helpers. */
|
|
92
202
|
rawCondition(condition: string): HelmCondition;
|
|
93
203
|
}
|
|
94
|
-
|
|
95
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Creates the runtime proxy used by ValuesRef and by serializer callback scopes.
|
|
206
|
+
* This function is intentionally not re-exported from the package root.
|
|
207
|
+
*/
|
|
208
|
+
export declare function createHelmValueProxy<T>(path: string): HelmValueRef<T>;
|
|
209
|
+
type HelmHelperKey = Extract<keyof HelmHelpers, string>;
|
|
210
|
+
/**
|
|
211
|
+
* Root ValuesRef shape. Root Helm helper names are reserved and can be reached
|
|
212
|
+
* as values through `at()`, for example `v.at('release')`.
|
|
213
|
+
*/
|
|
214
|
+
export type ValuesRef<T extends object> = HelmValue<T> & HelmHelpers & (T extends readonly unknown[] ? object : {
|
|
215
|
+
readonly [K in Exclude<StringKeyOf<T>, HelmValueReservedKey | HelmHelperKey>]-?: HelmValueRef<T[K]>;
|
|
216
|
+
});
|
|
217
|
+
/** Creates a type-safe reference tree rooted at `.Values`. */
|
|
218
|
+
export declare function valuesRef<T extends object>(): ValuesRef<T>;
|
|
219
|
+
/** Check if a value is a Helm value proxy. */
|
|
220
|
+
export declare function isHelmValue(value: unknown): value is HelmValueRef<unknown>;
|
|
221
|
+
/** Check if a value is a Helm condition. */
|
|
96
222
|
export declare function isHelmCondition(value: unknown): value is HelmCondition;
|
|
223
|
+
/** Check if a value is a field-level conditional. */
|
|
97
224
|
export declare function isHelmFieldConditional(value: unknown): value is HelmFieldConditional<unknown>;
|
|
98
|
-
|
|
99
|
-
export declare function
|
|
100
|
-
|
|
225
|
+
/** Check if a value is a range block. */
|
|
226
|
+
export declare function isHelmRange(value: unknown): value is HelmRange<unknown, unknown>;
|
|
227
|
+
/** Check if a value is a with block. */
|
|
228
|
+
export declare function isHelmWith(value: unknown): value is HelmWith<unknown, unknown>;
|
|
229
|
+
/** Serialize a Helm value reference to template syntax. */
|
|
230
|
+
export declare function serializeHelmValue(value: HelmValueRef<unknown>): string;
|
|
231
|
+
/** Serialize a Helm condition body. */
|
|
101
232
|
export declare function serializeHelmCondition(condition: HelmCondition): string;
|
|
102
233
|
export {};
|