@kustodian/generator 1.0.1 → 1.1.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/package.json +5 -5
- package/src/flux.ts +43 -1
- package/src/types.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kustodian/generator",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Template processing and Flux generation for Kustodian",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"registry": "https://npm.pkg.github.com"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@kustodian/core": "
|
|
39
|
-
"@kustodian/loader": "
|
|
40
|
-
"@kustodian/plugins": "
|
|
41
|
-
"@kustodian/schema": "
|
|
38
|
+
"@kustodian/core": "1.0.0",
|
|
39
|
+
"@kustodian/loader": "1.0.0",
|
|
40
|
+
"@kustodian/plugins": "1.0.0",
|
|
41
|
+
"@kustodian/schema": "1.0.0",
|
|
42
42
|
"yaml": "^2.8.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {}
|
package/src/flux.ts
CHANGED
|
@@ -80,13 +80,49 @@ export function generate_health_checks(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return kustomization.health_checks.map((check) => ({
|
|
83
|
-
apiVersion: 'apps/v1',
|
|
83
|
+
apiVersion: check.api_version ?? 'apps/v1',
|
|
84
84
|
kind: check.kind,
|
|
85
85
|
name: check.name,
|
|
86
86
|
namespace: check.namespace ?? namespace,
|
|
87
87
|
}));
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Generates custom health checks with CEL expressions for a Flux Kustomization.
|
|
92
|
+
*/
|
|
93
|
+
export function generate_custom_health_checks(
|
|
94
|
+
kustomization: KustomizationType,
|
|
95
|
+
namespace: string,
|
|
96
|
+
): FluxKustomizationType['spec']['customHealthChecks'] {
|
|
97
|
+
if (!kustomization.health_check_exprs || kustomization.health_check_exprs.length === 0) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return kustomization.health_check_exprs.map((check) => {
|
|
102
|
+
const healthCheck: {
|
|
103
|
+
apiVersion: string;
|
|
104
|
+
kind: string;
|
|
105
|
+
namespace?: string;
|
|
106
|
+
current?: string;
|
|
107
|
+
failed?: string;
|
|
108
|
+
} = {
|
|
109
|
+
apiVersion: check.api_version,
|
|
110
|
+
kind: check.kind,
|
|
111
|
+
namespace: check.namespace ?? namespace,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (check.current !== undefined) {
|
|
115
|
+
healthCheck.current = check.current;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (check.failed !== undefined) {
|
|
119
|
+
healthCheck.failed = check.failed;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return healthCheck;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
90
126
|
/**
|
|
91
127
|
* Generates a Flux OCIRepository resource.
|
|
92
128
|
*/
|
|
@@ -191,6 +227,12 @@ export function generate_flux_kustomization(
|
|
|
191
227
|
spec.healthChecks = health_checks;
|
|
192
228
|
}
|
|
193
229
|
|
|
230
|
+
// Add custom health checks with CEL expressions
|
|
231
|
+
const custom_health_checks = generate_custom_health_checks(kustomization, namespace);
|
|
232
|
+
if (custom_health_checks) {
|
|
233
|
+
spec.customHealthChecks = custom_health_checks;
|
|
234
|
+
}
|
|
235
|
+
|
|
194
236
|
return {
|
|
195
237
|
apiVersion: 'kustomize.toolkit.fluxcd.io/v1',
|
|
196
238
|
kind: 'Kustomization',
|
package/src/types.ts
CHANGED
|
@@ -116,5 +116,14 @@ export interface FluxKustomizationType {
|
|
|
116
116
|
name: string;
|
|
117
117
|
namespace: string;
|
|
118
118
|
}>;
|
|
119
|
+
customHealthChecks?: Array<{
|
|
120
|
+
apiVersion: string;
|
|
121
|
+
kind: string;
|
|
122
|
+
namespace?: string;
|
|
123
|
+
/** CEL expression for when resource is healthy/current */
|
|
124
|
+
current?: string;
|
|
125
|
+
/** CEL expression for when resource has failed */
|
|
126
|
+
failed?: string;
|
|
127
|
+
}>;
|
|
119
128
|
};
|
|
120
129
|
}
|