@kustodian/generator 1.0.0 → 1.0.1
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/README.md +72 -0
- package/package.json +1 -1
- package/src/external-substitutions.ts +5 -7
- package/src/output.ts +4 -1
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @kustodian/generator
|
|
2
|
+
|
|
3
|
+
Template processing and Flux CD resource generation for Kustodian.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @kustodian/generator
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This package provides the core generation engine for transforming Kustodian templates into Flux CD resources. It handles template resolution, variable substitution, dependency validation, and output serialization.
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
### Generator
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { create_generator } from '@kustodian/generator';
|
|
21
|
+
|
|
22
|
+
const generator = create_generator({
|
|
23
|
+
flux_namespace: 'flux-system',
|
|
24
|
+
git_repository_name: 'flux-system',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Generate Flux resources for a cluster
|
|
28
|
+
const result = await generator.generate(cluster, templates, {
|
|
29
|
+
output_dir: './output',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Write generated resources to disk
|
|
33
|
+
await generator.write(result.value);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Flux Resource Generation
|
|
37
|
+
|
|
38
|
+
- `generate_flux_kustomization()` - Creates Flux Kustomization resources
|
|
39
|
+
- `generate_flux_oci_repository()` - Creates OCI Repository sources
|
|
40
|
+
- `generate_depends_on()` - Resolves dependency references
|
|
41
|
+
- `generate_health_checks()` - Configures health checks
|
|
42
|
+
|
|
43
|
+
### Substitution Processing
|
|
44
|
+
|
|
45
|
+
- `substitute_string()` / `substitute_object()` - Apply variable substitutions
|
|
46
|
+
- `validate_substitutions()` - Validate required values are provided
|
|
47
|
+
- `extract_external_substitutions()` - Extract 1Password/Doppler references
|
|
48
|
+
|
|
49
|
+
### Namespace Management
|
|
50
|
+
|
|
51
|
+
- `generate_namespace_resources()` - Generate Namespace resources
|
|
52
|
+
- `collect_namespaces()` - Collect all namespaces from templates
|
|
53
|
+
- `filter_system_namespaces()` - Filter out system namespaces
|
|
54
|
+
|
|
55
|
+
### Dependency Validation
|
|
56
|
+
|
|
57
|
+
- `validate_dependencies()` - Validate dependency graph
|
|
58
|
+
- `validate_dependency_graph()` - Full graph validation with cycle detection
|
|
59
|
+
- `build_dependency_graph()` - Build dependency graph from templates
|
|
60
|
+
|
|
61
|
+
### Output Serialization
|
|
62
|
+
|
|
63
|
+
- `serialize_resource()` / `serialize_resources()` - Serialize to YAML/JSON
|
|
64
|
+
- `write_generation_result()` - Write all generated resources to disk
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
|
69
|
+
|
|
70
|
+
## Repository
|
|
71
|
+
|
|
72
|
+
[github.com/lucasilverentand/kustodian](https://github.com/lucasilverentand/kustodian)
|
package/package.json
CHANGED
|
@@ -4,10 +4,7 @@ import type {
|
|
|
4
4
|
SubstitutionType,
|
|
5
5
|
TemplateType,
|
|
6
6
|
} from '@kustodian/schema';
|
|
7
|
-
import {
|
|
8
|
-
is_doppler_substitution,
|
|
9
|
-
is_onepassword_substitution,
|
|
10
|
-
} from '@kustodian/schema';
|
|
7
|
+
import { is_doppler_substitution, is_onepassword_substitution } from '@kustodian/schema';
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
* Extracts 1Password substitutions from templates.
|
|
@@ -54,9 +51,10 @@ export function extract_doppler_substitutions(
|
|
|
54
51
|
/**
|
|
55
52
|
* Extracts all external substitutions (1Password and Doppler) from templates.
|
|
56
53
|
*/
|
|
57
|
-
export function extract_external_substitutions(
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
export function extract_external_substitutions(templates: TemplateType[]): {
|
|
55
|
+
onepassword: OnePasswordSubstitutionType[];
|
|
56
|
+
doppler: DopplerSubstitutionType[];
|
|
57
|
+
} {
|
|
60
58
|
return {
|
|
61
59
|
onepassword: extract_onepassword_substitutions(templates),
|
|
62
60
|
doppler: extract_doppler_substitutions(templates),
|
package/src/output.ts
CHANGED
|
@@ -150,7 +150,10 @@ export async function write_generation_result(
|
|
|
150
150
|
// Write each kustomization to templates/{template-name}/{kustomization-name}.yaml
|
|
151
151
|
for (const generated of result.kustomizations) {
|
|
152
152
|
const template_dir = path.join(templates_dir, generated.template);
|
|
153
|
-
const file_path = path.join(
|
|
153
|
+
const file_path = path.join(
|
|
154
|
+
template_dir,
|
|
155
|
+
`${generated.flux_kustomization.metadata.name}.${ext}`,
|
|
156
|
+
);
|
|
154
157
|
|
|
155
158
|
const content = serialize_resource(generated.flux_kustomization, format);
|
|
156
159
|
const file_result = await write_file(file_path, content, options);
|