kustodian 1.0.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/LICENSE +21 -0
- package/README.md +346 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +67 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/command.d.ts +57 -0
- package/dist/cli/command.d.ts.map +1 -0
- package/dist/cli/command.js +26 -0
- package/dist/cli/command.js.map +1 -0
- package/dist/cli/commands/apply.d.ts +8 -0
- package/dist/cli/commands/apply.d.ts.map +1 -0
- package/dist/cli/commands/apply.js +802 -0
- package/dist/cli/commands/apply.js.map +1 -0
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +403 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/sources.d.ts +5 -0
- package/dist/cli/commands/sources.d.ts.map +1 -0
- package/dist/cli/commands/sources.js +377 -0
- package/dist/cli/commands/sources.js.map +1 -0
- package/dist/cli/commands/update.d.ts +5 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +314 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +5 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +126 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/container.d.ts +48 -0
- package/dist/cli/container.d.ts.map +1 -0
- package/dist/cli/container.js +49 -0
- package/dist/cli/container.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/middleware.d.ts +118 -0
- package/dist/cli/middleware.d.ts.map +1 -0
- package/dist/cli/middleware.js +280 -0
- package/dist/cli/middleware.js.map +1 -0
- package/dist/cli/runner.d.ts +34 -0
- package/dist/cli/runner.d.ts.map +1 -0
- package/dist/cli/runner.js +156 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli/utils/defaults.d.ts +23 -0
- package/dist/cli/utils/defaults.d.ts.map +1 -0
- package/dist/cli/utils/defaults.js +43 -0
- package/dist/cli/utils/defaults.js.map +1 -0
- package/dist/core/error.d.ts +117 -0
- package/dist/core/error.d.ts.map +1 -0
- package/dist/core/error.js +210 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +31 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +78 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/path.d.ts +57 -0
- package/dist/core/path.d.ts.map +1 -0
- package/dist/core/path.js +154 -0
- package/dist/core/path.js.map +1 -0
- package/dist/core/result.d.ts +80 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +150 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/types.d.ts +80 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generator/external-substitutions.d.ts +21 -0
- package/dist/generator/external-substitutions.d.ts.map +1 -0
- package/dist/generator/external-substitutions.js +49 -0
- package/dist/generator/external-substitutions.js.map +1 -0
- package/dist/generator/flux.d.ts +61 -0
- package/dist/generator/flux.d.ts.map +1 -0
- package/dist/generator/flux.js +294 -0
- package/dist/generator/flux.js.map +1 -0
- package/dist/generator/generator.d.ts +77 -0
- package/dist/generator/generator.d.ts.map +1 -0
- package/dist/generator/generator.js +183 -0
- package/dist/generator/generator.js.map +1 -0
- package/dist/generator/index.d.ts +9 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +9 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/kustomization-resolution.d.ts +40 -0
- package/dist/generator/kustomization-resolution.d.ts.map +1 -0
- package/dist/generator/kustomization-resolution.js +59 -0
- package/dist/generator/kustomization-resolution.js.map +1 -0
- package/dist/generator/namespace.d.ts +74 -0
- package/dist/generator/namespace.d.ts.map +1 -0
- package/dist/generator/namespace.js +109 -0
- package/dist/generator/namespace.js.map +1 -0
- package/dist/generator/output.d.ts +56 -0
- package/dist/generator/output.d.ts.map +1 -0
- package/dist/generator/output.js +171 -0
- package/dist/generator/output.js.map +1 -0
- package/dist/generator/preservation.d.ts +45 -0
- package/dist/generator/preservation.d.ts.map +1 -0
- package/dist/generator/preservation.js +71 -0
- package/dist/generator/preservation.js.map +1 -0
- package/dist/generator/substitution.d.ts +79 -0
- package/dist/generator/substitution.d.ts.map +1 -0
- package/dist/generator/substitution.js +210 -0
- package/dist/generator/substitution.js.map +1 -0
- package/dist/generator/types.d.ts +162 -0
- package/dist/generator/types.d.ts.map +1 -0
- package/dist/generator/types.js +2 -0
- package/dist/generator/types.js.map +1 -0
- package/dist/generator/validation/cycle-detection.d.ts +25 -0
- package/dist/generator/validation/cycle-detection.d.ts.map +1 -0
- package/dist/generator/validation/cycle-detection.js +101 -0
- package/dist/generator/validation/cycle-detection.js.map +1 -0
- package/dist/generator/validation/enablement.d.ts +24 -0
- package/dist/generator/validation/enablement.d.ts.map +1 -0
- package/dist/generator/validation/enablement.js +69 -0
- package/dist/generator/validation/enablement.js.map +1 -0
- package/dist/generator/validation/graph.d.ts +29 -0
- package/dist/generator/validation/graph.d.ts.map +1 -0
- package/dist/generator/validation/graph.js +106 -0
- package/dist/generator/validation/graph.js.map +1 -0
- package/dist/generator/validation/index.d.ts +38 -0
- package/dist/generator/validation/index.d.ts.map +1 -0
- package/dist/generator/validation/index.js +64 -0
- package/dist/generator/validation/index.js.map +1 -0
- package/dist/generator/validation/reference.d.ts +45 -0
- package/dist/generator/validation/reference.d.ts.map +1 -0
- package/dist/generator/validation/reference.js +143 -0
- package/dist/generator/validation/reference.js.map +1 -0
- package/dist/generator/validation/requirements.d.ts +25 -0
- package/dist/generator/validation/requirements.d.ts.map +1 -0
- package/dist/generator/validation/requirements.js +64 -0
- package/dist/generator/validation/requirements.js.map +1 -0
- package/dist/generator/validation/types.d.ts +116 -0
- package/dist/generator/validation/types.d.ts.map +1 -0
- package/dist/generator/validation/types.js +13 -0
- package/dist/generator/validation/types.js.map +1 -0
- package/dist/k8s/exec.d.ts +20 -0
- package/dist/k8s/exec.d.ts.map +1 -0
- package/dist/k8s/exec.js +47 -0
- package/dist/k8s/exec.js.map +1 -0
- package/dist/k8s/flux.d.ts +57 -0
- package/dist/k8s/flux.d.ts.map +1 -0
- package/dist/k8s/flux.js +202 -0
- package/dist/k8s/flux.js.map +1 -0
- package/dist/k8s/index.d.ts +6 -0
- package/dist/k8s/index.d.ts.map +1 -0
- package/dist/k8s/index.js +6 -0
- package/dist/k8s/index.js.map +1 -0
- package/dist/k8s/kubeconfig.d.ts +45 -0
- package/dist/k8s/kubeconfig.d.ts.map +1 -0
- package/dist/k8s/kubeconfig.js +152 -0
- package/dist/k8s/kubeconfig.js.map +1 -0
- package/dist/k8s/kubectl.d.ts +68 -0
- package/dist/k8s/kubectl.d.ts.map +1 -0
- package/dist/k8s/kubectl.js +187 -0
- package/dist/k8s/kubectl.js.map +1 -0
- package/dist/k8s/types.d.ts +65 -0
- package/dist/k8s/types.d.ts.map +1 -0
- package/dist/k8s/types.js +2 -0
- package/dist/k8s/types.js.map +1 -0
- package/dist/loader/file.d.ts +39 -0
- package/dist/loader/file.d.ts.map +1 -0
- package/dist/loader/file.js +121 -0
- package/dist/loader/file.js.map +1 -0
- package/dist/loader/index.d.ts +5 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +5 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/loader/profile.d.ts +23 -0
- package/dist/loader/profile.d.ts.map +1 -0
- package/dist/loader/profile.js +84 -0
- package/dist/loader/profile.js.map +1 -0
- package/dist/loader/project.d.ts +76 -0
- package/dist/loader/project.d.ts.map +1 -0
- package/dist/loader/project.js +279 -0
- package/dist/loader/project.js.map +1 -0
- package/dist/loader/yaml.d.ts +15 -0
- package/dist/loader/yaml.d.ts.map +1 -0
- package/dist/loader/yaml.js +44 -0
- package/dist/loader/yaml.js.map +1 -0
- package/dist/nodes/index.d.ts +5 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +5 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/kubectl-labeler.d.ts +7 -0
- package/dist/nodes/kubectl-labeler.d.ts.map +1 -0
- package/dist/nodes/kubectl-labeler.js +89 -0
- package/dist/nodes/kubectl-labeler.js.map +1 -0
- package/dist/nodes/labeler.d.ts +74 -0
- package/dist/nodes/labeler.d.ts.map +1 -0
- package/dist/nodes/labeler.js +118 -0
- package/dist/nodes/labeler.js.map +1 -0
- package/dist/nodes/profile.d.ts +58 -0
- package/dist/nodes/profile.d.ts.map +1 -0
- package/dist/nodes/profile.js +128 -0
- package/dist/nodes/profile.js.map +1 -0
- package/dist/nodes/types.d.ts +84 -0
- package/dist/nodes/types.d.ts.map +1 -0
- package/dist/nodes/types.js +77 -0
- package/dist/nodes/types.js.map +1 -0
- package/dist/plugins/generators.d.ts +49 -0
- package/dist/plugins/generators.d.ts.map +1 -0
- package/dist/plugins/generators.js +7 -0
- package/dist/plugins/generators.js.map +1 -0
- package/dist/plugins/hooks.d.ts +120 -0
- package/dist/plugins/hooks.d.ts.map +1 -0
- package/dist/plugins/hooks.js +41 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/index.d.ts +8 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +15 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/loader.d.ts +40 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +236 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/object-types.d.ts +71 -0
- package/dist/plugins/object-types.d.ts.map +1 -0
- package/dist/plugins/object-types.js +65 -0
- package/dist/plugins/object-types.js.map +1 -0
- package/dist/plugins/registry.d.ts +87 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +158 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/substitution-providers.d.ts +48 -0
- package/dist/plugins/substitution-providers.d.ts.map +1 -0
- package/dist/plugins/substitution-providers.js +2 -0
- package/dist/plugins/substitution-providers.js.map +1 -0
- package/dist/plugins/types.d.ts +288 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +25 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/registry/auth.d.ts +14 -0
- package/dist/registry/auth.d.ts.map +1 -0
- package/dist/registry/auth.js +40 -0
- package/dist/registry/auth.js.map +1 -0
- package/dist/registry/client.d.ts +24 -0
- package/dist/registry/client.d.ts.map +1 -0
- package/dist/registry/client.js +85 -0
- package/dist/registry/client.js.map +1 -0
- package/dist/registry/dockerhub.d.ts +6 -0
- package/dist/registry/dockerhub.d.ts.map +1 -0
- package/dist/registry/dockerhub.js +91 -0
- package/dist/registry/dockerhub.js.map +1 -0
- package/dist/registry/ghcr.d.ts +6 -0
- package/dist/registry/ghcr.d.ts.map +1 -0
- package/dist/registry/ghcr.js +95 -0
- package/dist/registry/ghcr.js.map +1 -0
- package/dist/registry/helm.d.ts +11 -0
- package/dist/registry/helm.d.ts.map +1 -0
- package/dist/registry/helm.js +124 -0
- package/dist/registry/helm.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/types.d.ts +55 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +2 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/registry/version.d.ts +22 -0
- package/dist/registry/version.d.ts.map +1 -0
- package/dist/registry/version.js +62 -0
- package/dist/registry/version.js.map +1 -0
- package/dist/schema/cluster.d.ts +2890 -0
- package/dist/schema/cluster.d.ts.map +1 -0
- package/dist/schema/cluster.js +231 -0
- package/dist/schema/cluster.js.map +1 -0
- package/dist/schema/common.d.ts +1059 -0
- package/dist/schema/common.d.ts.map +1 -0
- package/dist/schema/common.js +340 -0
- package/dist/schema/common.js.map +1 -0
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +8 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/node-list.d.ts +361 -0
- package/dist/schema/node-list.d.ts.map +1 -0
- package/dist/schema/node-list.js +104 -0
- package/dist/schema/node-list.js.map +1 -0
- package/dist/schema/profile.d.ts +166 -0
- package/dist/schema/profile.d.ts.map +1 -0
- package/dist/schema/profile.js +61 -0
- package/dist/schema/profile.js.map +1 -0
- package/dist/schema/project.d.ts +168 -0
- package/dist/schema/project.d.ts.map +1 -0
- package/dist/schema/project.js +40 -0
- package/dist/schema/project.js.map +1 -0
- package/dist/schema/sources.d.ts +338 -0
- package/dist/schema/sources.d.ts.map +1 -0
- package/dist/schema/sources.js +111 -0
- package/dist/schema/sources.js.map +1 -0
- package/dist/schema/template.d.ts +2711 -0
- package/dist/schema/template.d.ts.map +1 -0
- package/dist/schema/template.js +97 -0
- package/dist/schema/template.js.map +1 -0
- package/dist/sources/cache/index.d.ts +9 -0
- package/dist/sources/cache/index.d.ts.map +1 -0
- package/dist/sources/cache/index.js +278 -0
- package/dist/sources/cache/index.js.map +1 -0
- package/dist/sources/cache/metadata.d.ts +36 -0
- package/dist/sources/cache/metadata.d.ts.map +1 -0
- package/dist/sources/cache/metadata.js +21 -0
- package/dist/sources/cache/metadata.js.map +1 -0
- package/dist/sources/cache/ttl.d.ts +20 -0
- package/dist/sources/cache/ttl.d.ts.map +1 -0
- package/dist/sources/cache/ttl.js +53 -0
- package/dist/sources/cache/ttl.js.map +1 -0
- package/dist/sources/fetchers/git.d.ts +6 -0
- package/dist/sources/fetchers/git.d.ts.map +1 -0
- package/dist/sources/fetchers/git.js +165 -0
- package/dist/sources/fetchers/git.js.map +1 -0
- package/dist/sources/fetchers/http.d.ts +6 -0
- package/dist/sources/fetchers/http.d.ts.map +1 -0
- package/dist/sources/fetchers/http.js +159 -0
- package/dist/sources/fetchers/http.js.map +1 -0
- package/dist/sources/fetchers/index.d.ts +11 -0
- package/dist/sources/fetchers/index.d.ts.map +1 -0
- package/dist/sources/fetchers/index.js +24 -0
- package/dist/sources/fetchers/index.js.map +1 -0
- package/dist/sources/fetchers/oci.d.ts +6 -0
- package/dist/sources/fetchers/oci.d.ts.map +1 -0
- package/dist/sources/fetchers/oci.js +156 -0
- package/dist/sources/fetchers/oci.js.map +1 -0
- package/dist/sources/fetchers/types.d.ts +25 -0
- package/dist/sources/fetchers/types.d.ts.map +1 -0
- package/dist/sources/fetchers/types.js +2 -0
- package/dist/sources/fetchers/types.js.map +1 -0
- package/dist/sources/index.d.ts +6 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +10 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/loader.d.ts +34 -0
- package/dist/sources/loader.d.ts.map +1 -0
- package/dist/sources/loader.js +89 -0
- package/dist/sources/loader.js.map +1 -0
- package/dist/sources/resolver.d.ts +17 -0
- package/dist/sources/resolver.d.ts.map +1 -0
- package/dist/sources/resolver.js +125 -0
- package/dist/sources/resolver.js.map +1 -0
- package/dist/sources/types.d.ts +151 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +2 -0
- package/dist/sources/types.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { Errors, failure, from_promise, success } from '../core/index.js';
|
|
4
|
+
import { parse_yaml, stringify_yaml } from './yaml.js';
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a file exists.
|
|
7
|
+
*/
|
|
8
|
+
export async function file_exists(file_path) {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(file_path);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a path is a directory.
|
|
19
|
+
*/
|
|
20
|
+
export async function is_directory(dir_path) {
|
|
21
|
+
try {
|
|
22
|
+
const stats = await fs.stat(dir_path);
|
|
23
|
+
return stats.isDirectory();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads a file and returns its contents as a string.
|
|
31
|
+
*/
|
|
32
|
+
export async function read_file(file_path) {
|
|
33
|
+
const exists = await file_exists(file_path);
|
|
34
|
+
if (!exists) {
|
|
35
|
+
return failure(Errors.file_not_found(file_path));
|
|
36
|
+
}
|
|
37
|
+
return from_promise(fs.readFile(file_path, 'utf-8'), (error) => Errors.file_read_error(file_path, error));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Writes content to a file, creating directories as needed.
|
|
41
|
+
*/
|
|
42
|
+
export async function write_file(file_path, content) {
|
|
43
|
+
try {
|
|
44
|
+
const dir = path.dirname(file_path);
|
|
45
|
+
await fs.mkdir(dir, { recursive: true });
|
|
46
|
+
await fs.writeFile(file_path, content, 'utf-8');
|
|
47
|
+
return success(undefined);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return failure(Errors.file_write_error(file_path, error));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reads a YAML file and parses it.
|
|
55
|
+
*/
|
|
56
|
+
export async function read_yaml_file(file_path) {
|
|
57
|
+
const content_result = await read_file(file_path);
|
|
58
|
+
if (!content_result.success) {
|
|
59
|
+
return content_result;
|
|
60
|
+
}
|
|
61
|
+
return parse_yaml(content_result.value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reads a multi-document YAML file and parses it.
|
|
65
|
+
*/
|
|
66
|
+
export async function read_multi_yaml_file(file_path) {
|
|
67
|
+
const content_result = await read_file(file_path);
|
|
68
|
+
if (!content_result.success) {
|
|
69
|
+
return content_result;
|
|
70
|
+
}
|
|
71
|
+
const { parse_multi_yaml } = await import('./yaml.js');
|
|
72
|
+
return parse_multi_yaml(content_result.value);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Writes an object to a YAML file.
|
|
76
|
+
*/
|
|
77
|
+
export async function write_yaml_file(file_path, data) {
|
|
78
|
+
const yaml_result = stringify_yaml(data);
|
|
79
|
+
if (!yaml_result.success) {
|
|
80
|
+
return yaml_result;
|
|
81
|
+
}
|
|
82
|
+
return write_file(file_path, yaml_result.value);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Lists all files in a directory matching a pattern.
|
|
86
|
+
*/
|
|
87
|
+
export async function list_files(dir_path, extension) {
|
|
88
|
+
const exists = await is_directory(dir_path);
|
|
89
|
+
if (!exists) {
|
|
90
|
+
return failure(Errors.not_found('Directory', dir_path));
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const entries = await fs.readdir(dir_path, { withFileTypes: true });
|
|
94
|
+
let files = entries.filter((e) => e.isFile()).map((e) => path.join(dir_path, e.name));
|
|
95
|
+
if (extension) {
|
|
96
|
+
files = files.filter((f) => f.endsWith(extension));
|
|
97
|
+
}
|
|
98
|
+
return success(files);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return failure(Errors.file_read_error(dir_path, error));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Lists all subdirectories in a directory.
|
|
106
|
+
*/
|
|
107
|
+
export async function list_directories(dir_path) {
|
|
108
|
+
const exists = await is_directory(dir_path);
|
|
109
|
+
if (!exists) {
|
|
110
|
+
return failure(Errors.not_found('Directory', dir_path));
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const entries = await fs.readdir(dir_path, { withFileTypes: true });
|
|
114
|
+
const dirs = entries.filter((e) => e.isDirectory()).map((e) => path.join(dir_path, e.name));
|
|
115
|
+
return success(dirs);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return failure(Errors.file_read_error(dir_path, error));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/loader/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAmB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAiB;IACjD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,SAAiB;IAEjB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CA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cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loader/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { KustodianErrorType } from '../core/index.js';
|
|
2
|
+
import { type ResultType } from '../core/index.js';
|
|
3
|
+
import { type NodeProfileType } from '../schema/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Standard directory name for profiles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PROFILES_DIR = "profiles";
|
|
8
|
+
/**
|
|
9
|
+
* Loaded profile with its source path.
|
|
10
|
+
*/
|
|
11
|
+
export interface LoadedProfileType {
|
|
12
|
+
path: string;
|
|
13
|
+
profile: NodeProfileType;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Loads all profiles from the profiles directory.
|
|
17
|
+
*/
|
|
18
|
+
export declare function load_all_profiles(project_root: string): Promise<ResultType<Map<string, NodeProfileType>, KustodianErrorType>>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets a profile by name from a profiles map.
|
|
21
|
+
*/
|
|
22
|
+
export declare function get_profile(profiles: Map<string, NodeProfileType>, name: string): ResultType<NodeProfileType, KustodianErrorType>;
|
|
23
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/loader/profile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAU,KAAK,UAAU,EAAgC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;CAC1B;AAqCD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,kBAAkB,CAAC,CAAC,CA4CvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACtC,IAAI,EAAE,MAAM,GACX,UAAU,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAMjD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { Errors, failure, is_success, success } from '../core/index.js';
|
|
3
|
+
import { node_profile_resource_to_profile, validate_node_profile_resource, } from '../schema/index.js';
|
|
4
|
+
import { file_exists, is_directory, list_files, read_multi_yaml_file } from './file.js';
|
|
5
|
+
/**
|
|
6
|
+
* Standard directory name for profiles.
|
|
7
|
+
*/
|
|
8
|
+
export const PROFILES_DIR = 'profiles';
|
|
9
|
+
/**
|
|
10
|
+
* Loads profiles from a single YAML file (supports multi-document).
|
|
11
|
+
*/
|
|
12
|
+
async function load_profiles_from_file(file_path) {
|
|
13
|
+
const docs_result = await read_multi_yaml_file(file_path);
|
|
14
|
+
if (!is_success(docs_result)) {
|
|
15
|
+
return docs_result;
|
|
16
|
+
}
|
|
17
|
+
const profiles = [];
|
|
18
|
+
const errors = [];
|
|
19
|
+
for (const doc of docs_result.value) {
|
|
20
|
+
const validation = validate_node_profile_resource(doc);
|
|
21
|
+
if (!validation.success) {
|
|
22
|
+
const validation_errors = validation.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
|
|
23
|
+
errors.push(`${path.basename(file_path)}:\n ${validation_errors.join('\n ')}`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
profiles.push(node_profile_resource_to_profile(validation.data));
|
|
27
|
+
}
|
|
28
|
+
if (errors.length > 0) {
|
|
29
|
+
return failure(Errors.validation_error(`Failed to load profiles:\n${errors.join('\n')}`));
|
|
30
|
+
}
|
|
31
|
+
return success(profiles);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Loads all profiles from the profiles directory.
|
|
35
|
+
*/
|
|
36
|
+
export async function load_all_profiles(project_root) {
|
|
37
|
+
const profiles_dir = path.join(project_root, PROFILES_DIR);
|
|
38
|
+
const profiles_map = new Map();
|
|
39
|
+
// Return empty map if profiles directory doesn't exist
|
|
40
|
+
if (!(await file_exists(profiles_dir))) {
|
|
41
|
+
return success(profiles_map);
|
|
42
|
+
}
|
|
43
|
+
if (!(await is_directory(profiles_dir))) {
|
|
44
|
+
return success(profiles_map);
|
|
45
|
+
}
|
|
46
|
+
const errors = [];
|
|
47
|
+
// Load all YAML files from directory
|
|
48
|
+
const yml_files = await list_files(profiles_dir, '.yml');
|
|
49
|
+
const yaml_files = await list_files(profiles_dir, '.yaml');
|
|
50
|
+
const all_files = [
|
|
51
|
+
...(is_success(yml_files) ? yml_files.value : []),
|
|
52
|
+
...(is_success(yaml_files) ? yaml_files.value : []),
|
|
53
|
+
];
|
|
54
|
+
for (const file_path of all_files) {
|
|
55
|
+
const result = await load_profiles_from_file(file_path);
|
|
56
|
+
if (is_success(result)) {
|
|
57
|
+
for (const profile of result.value) {
|
|
58
|
+
if (profiles_map.has(profile.name)) {
|
|
59
|
+
errors.push(`Duplicate profile name: ${profile.name}`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
profiles_map.set(profile.name, profile);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
errors.push(result.error.message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (errors.length > 0) {
|
|
70
|
+
return failure(Errors.validation_error(`Failed to load profiles:\n${errors.join('\n')}`));
|
|
71
|
+
}
|
|
72
|
+
return success(profiles_map);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets a profile by name from a profiles map.
|
|
76
|
+
*/
|
|
77
|
+
export function get_profile(profiles, name) {
|
|
78
|
+
const profile = profiles.get(name);
|
|
79
|
+
if (!profile) {
|
|
80
|
+
return failure(Errors.profile_not_found(name));
|
|
81
|
+
}
|
|
82
|
+
return success(profile);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/loader/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAmB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAEL,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAExF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AAUvC;;GAEG;AACH,KAAK,UAAU,uBAAuB,CACpC,SAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAU,SAAS,CAAC,CAAC;IAEnE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC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AU,WAAW,CACzB,QAAsC,EACtC,IAAY;IAEZ,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { KustodianErrorType } from '../core/index.js';
|
|
2
|
+
import { type ResultType } from '../core/index.js';
|
|
3
|
+
import { type ClusterType, type NodeProfileType, type NodeSchemaType, type ProjectType as ProjectConfigType, type TemplateType } from '../schema/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Standard file names used in Kustodian projects.
|
|
6
|
+
*/
|
|
7
|
+
export declare const StandardFiles: {
|
|
8
|
+
readonly TEMPLATE: "template.yaml";
|
|
9
|
+
readonly CLUSTER: "cluster.yaml";
|
|
10
|
+
readonly NODES: "nodes.yaml";
|
|
11
|
+
readonly PROJECT: "kustodian.yaml";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Standard directory names used in Kustodian projects.
|
|
15
|
+
*/
|
|
16
|
+
export declare const StandardDirs: {
|
|
17
|
+
readonly TEMPLATES: "templates";
|
|
18
|
+
readonly CLUSTERS: "clusters";
|
|
19
|
+
readonly NODES: "nodes";
|
|
20
|
+
readonly PROFILES: "profiles";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Loaded template with its source path.
|
|
24
|
+
*/
|
|
25
|
+
export interface LoadedTemplateType {
|
|
26
|
+
path: string;
|
|
27
|
+
template: TemplateType;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Loaded cluster with its source path.
|
|
31
|
+
*/
|
|
32
|
+
export interface LoadedClusterType {
|
|
33
|
+
path: string;
|
|
34
|
+
cluster: ClusterType;
|
|
35
|
+
nodes: NodeSchemaType[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A fully loaded Kustodian project.
|
|
39
|
+
*/
|
|
40
|
+
export interface ProjectType {
|
|
41
|
+
root: string;
|
|
42
|
+
config?: ProjectConfigType;
|
|
43
|
+
templates: LoadedTemplateType[];
|
|
44
|
+
clusters: LoadedClusterType[];
|
|
45
|
+
profiles: Map<string, NodeProfileType>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Finds the project root by looking for kustodian.yaml.
|
|
49
|
+
*/
|
|
50
|
+
export declare function find_project_root(start_path: string): Promise<ResultType<string, KustodianErrorType>>;
|
|
51
|
+
/**
|
|
52
|
+
* Loads a single template from its directory.
|
|
53
|
+
*/
|
|
54
|
+
export declare function load_template(template_dir: string): Promise<ResultType<LoadedTemplateType, KustodianErrorType>>;
|
|
55
|
+
/**
|
|
56
|
+
* Loads all node files from specified paths (files or directories).
|
|
57
|
+
*/
|
|
58
|
+
export declare function load_cluster_nodes(cluster_dir: string, node_file_paths?: string[]): Promise<ResultType<NodeSchemaType[], KustodianErrorType>>;
|
|
59
|
+
/**
|
|
60
|
+
* Loads a single cluster from its directory.
|
|
61
|
+
*/
|
|
62
|
+
export declare function load_cluster(cluster_dir: string): Promise<ResultType<LoadedClusterType, KustodianErrorType>>;
|
|
63
|
+
/**
|
|
64
|
+
* Loads all templates from the templates directory.
|
|
65
|
+
* Supports both flat and nested directory structures.
|
|
66
|
+
*/
|
|
67
|
+
export declare function load_all_templates(project_root: string): Promise<ResultType<LoadedTemplateType[], KustodianErrorType>>;
|
|
68
|
+
/**
|
|
69
|
+
* Loads all clusters from the clusters directory.
|
|
70
|
+
*/
|
|
71
|
+
export declare function load_all_clusters(project_root: string): Promise<ResultType<LoadedClusterType[], KustodianErrorType>>;
|
|
72
|
+
/**
|
|
73
|
+
* Loads a complete Kustodian project.
|
|
74
|
+
*/
|
|
75
|
+
export declare function load_project(project_root: string): Promise<ResultType<ProjectType, KustodianErrorType>>;
|
|
76
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/loader/project.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAU,KAAK,UAAU,EAAgC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,IAAI,iBAAiB,EACrC,KAAK,YAAY,EAMlB,MAAM,oBAAoB,CAAC;AAK5B;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAejD;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAoB7D;AAsCD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,kBAAkB,CAAC,CAAC,CA8C3D;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC,CA4B5D;AA4BD;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE,kBAAkB,CAAC,CAAC,CA6B/D;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,kBAAkB,CAAC,CAAC,CA6B9D;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAgDtD"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { Errors, failure, is_success, success } from '../core/index.js';
|
|
3
|
+
import { node_resource_to_node, validate_cluster, validate_node_resource, validate_project, validate_template, } from '../schema/index.js';
|
|
4
|
+
import { file_exists, list_directories, list_files, read_yaml_file } from './file.js';
|
|
5
|
+
import { load_all_profiles } from './profile.js';
|
|
6
|
+
/**
|
|
7
|
+
* Standard file names used in Kustodian projects.
|
|
8
|
+
*/
|
|
9
|
+
export const StandardFiles = {
|
|
10
|
+
TEMPLATE: 'template.yaml',
|
|
11
|
+
CLUSTER: 'cluster.yaml',
|
|
12
|
+
NODES: 'nodes.yaml',
|
|
13
|
+
PROJECT: 'kustodian.yaml',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Standard directory names used in Kustodian projects.
|
|
17
|
+
*/
|
|
18
|
+
export const StandardDirs = {
|
|
19
|
+
TEMPLATES: 'templates',
|
|
20
|
+
CLUSTERS: 'clusters',
|
|
21
|
+
NODES: 'nodes',
|
|
22
|
+
PROFILES: 'profiles',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Finds the project root by looking for kustodian.yaml.
|
|
26
|
+
*/
|
|
27
|
+
export async function find_project_root(start_path) {
|
|
28
|
+
let current = path.resolve(start_path);
|
|
29
|
+
const root = path.parse(current).root;
|
|
30
|
+
while (current !== root) {
|
|
31
|
+
const project_file = path.join(current, StandardFiles.PROJECT);
|
|
32
|
+
if (await file_exists(project_file)) {
|
|
33
|
+
return success(current);
|
|
34
|
+
}
|
|
35
|
+
current = path.dirname(current);
|
|
36
|
+
}
|
|
37
|
+
return failure(Errors.config_not_found('Project', `${StandardFiles.PROJECT} not found in parent directories`));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loads a single template from its directory.
|
|
41
|
+
*/
|
|
42
|
+
export async function load_template(template_dir) {
|
|
43
|
+
const template_path = path.join(template_dir, StandardFiles.TEMPLATE);
|
|
44
|
+
const yaml_result = await read_yaml_file(template_path);
|
|
45
|
+
if (!is_success(yaml_result)) {
|
|
46
|
+
return yaml_result;
|
|
47
|
+
}
|
|
48
|
+
const validation = validate_template(yaml_result.value);
|
|
49
|
+
if (!validation.success) {
|
|
50
|
+
const errors = validation.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
|
|
51
|
+
return failure(Errors.schema_validation_error(errors));
|
|
52
|
+
}
|
|
53
|
+
return success({
|
|
54
|
+
path: template_dir,
|
|
55
|
+
template: validation.data,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Loads nodes from a single YAML file (supports multi-document).
|
|
60
|
+
*/
|
|
61
|
+
async function load_nodes_from_file(file_path) {
|
|
62
|
+
const { read_multi_yaml_file } = await import('./file.js');
|
|
63
|
+
const docs_result = await read_multi_yaml_file(file_path);
|
|
64
|
+
if (!is_success(docs_result)) {
|
|
65
|
+
return docs_result;
|
|
66
|
+
}
|
|
67
|
+
const nodes = [];
|
|
68
|
+
const errors = [];
|
|
69
|
+
for (const doc of docs_result.value) {
|
|
70
|
+
const validation = validate_node_resource(doc);
|
|
71
|
+
if (!validation.success) {
|
|
72
|
+
const validation_errors = validation.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
|
|
73
|
+
errors.push(`${path.basename(file_path)}:\n ${validation_errors.join('\n ')}`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
nodes.push(node_resource_to_node(validation.data));
|
|
77
|
+
}
|
|
78
|
+
if (errors.length > 0) {
|
|
79
|
+
return failure(Errors.validation_error(`Failed to load nodes:\n${errors.join('\n')}`));
|
|
80
|
+
}
|
|
81
|
+
return success(nodes);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Loads all node files from specified paths (files or directories).
|
|
85
|
+
*/
|
|
86
|
+
export async function load_cluster_nodes(cluster_dir, node_file_paths) {
|
|
87
|
+
const nodes = [];
|
|
88
|
+
const errors = [];
|
|
89
|
+
// If no paths specified, try default nodes/ directory
|
|
90
|
+
const paths_to_scan = node_file_paths || [StandardDirs.NODES];
|
|
91
|
+
for (const ref_path of paths_to_scan) {
|
|
92
|
+
const full_path = path.isAbsolute(ref_path) ? ref_path : path.join(cluster_dir, ref_path);
|
|
93
|
+
// Check if it's a directory
|
|
94
|
+
const { is_directory } = await import('./file.js');
|
|
95
|
+
if (await is_directory(full_path)) {
|
|
96
|
+
// Load all YAML files from directory
|
|
97
|
+
const yml_files = await list_files(full_path, '.yml');
|
|
98
|
+
const yaml_files = await list_files(full_path, '.yaml');
|
|
99
|
+
const all_files = [
|
|
100
|
+
...(is_success(yml_files) ? yml_files.value : []),
|
|
101
|
+
...(is_success(yaml_files) ? yaml_files.value : []),
|
|
102
|
+
];
|
|
103
|
+
for (const file_path of all_files) {
|
|
104
|
+
const result = await load_nodes_from_file(file_path);
|
|
105
|
+
if (is_success(result)) {
|
|
106
|
+
nodes.push(...result.value);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
errors.push(result.error.message);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (await file_exists(full_path)) {
|
|
114
|
+
// Load single file (may contain multiple documents)
|
|
115
|
+
const result = await load_nodes_from_file(full_path);
|
|
116
|
+
if (is_success(result)) {
|
|
117
|
+
nodes.push(...result.value);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
errors.push(result.error.message);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (errors.length > 0) {
|
|
125
|
+
return failure(Errors.validation_error(`Failed to load nodes:\n${errors.join('\n')}`));
|
|
126
|
+
}
|
|
127
|
+
return success(nodes);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Loads a single cluster from its directory.
|
|
131
|
+
*/
|
|
132
|
+
export async function load_cluster(cluster_dir) {
|
|
133
|
+
const cluster_path = path.join(cluster_dir, StandardFiles.CLUSTER);
|
|
134
|
+
const yaml_result = await read_yaml_file(cluster_path);
|
|
135
|
+
if (!is_success(yaml_result)) {
|
|
136
|
+
return yaml_result;
|
|
137
|
+
}
|
|
138
|
+
const validation = validate_cluster(yaml_result.value);
|
|
139
|
+
if (!validation.success) {
|
|
140
|
+
const errors = validation.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
|
|
141
|
+
return failure(Errors.schema_validation_error(errors));
|
|
142
|
+
}
|
|
143
|
+
// Load nodes from specified paths or default nodes/ directory
|
|
144
|
+
const node_file_paths = validation.data.spec?.nodes;
|
|
145
|
+
const nodes_result = await load_cluster_nodes(cluster_dir, node_file_paths);
|
|
146
|
+
if (!is_success(nodes_result)) {
|
|
147
|
+
return nodes_result;
|
|
148
|
+
}
|
|
149
|
+
return success({
|
|
150
|
+
path: cluster_dir,
|
|
151
|
+
cluster: validation.data,
|
|
152
|
+
nodes: nodes_result.value,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Recursively finds all directories containing template.yaml files.
|
|
157
|
+
*/
|
|
158
|
+
async function find_template_directories(dir) {
|
|
159
|
+
const template_path = path.join(dir, StandardFiles.TEMPLATE);
|
|
160
|
+
// If this directory has a template.yaml, return it
|
|
161
|
+
if (await file_exists(template_path)) {
|
|
162
|
+
return [dir];
|
|
163
|
+
}
|
|
164
|
+
// Otherwise, recursively check subdirectories
|
|
165
|
+
const subdirs_result = await list_directories(dir);
|
|
166
|
+
if (!is_success(subdirs_result)) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
const template_dirs = [];
|
|
170
|
+
for (const subdir of subdirs_result.value) {
|
|
171
|
+
const found = await find_template_directories(subdir);
|
|
172
|
+
template_dirs.push(...found);
|
|
173
|
+
}
|
|
174
|
+
return template_dirs;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Loads all templates from the templates directory.
|
|
178
|
+
* Supports both flat and nested directory structures.
|
|
179
|
+
*/
|
|
180
|
+
export async function load_all_templates(project_root) {
|
|
181
|
+
const templates_dir = path.join(project_root, StandardDirs.TEMPLATES);
|
|
182
|
+
// Check if templates directory exists
|
|
183
|
+
if (!(await file_exists(templates_dir))) {
|
|
184
|
+
return success([]);
|
|
185
|
+
}
|
|
186
|
+
// Find all directories containing template.yaml (recursively)
|
|
187
|
+
const template_dirs = await find_template_directories(templates_dir);
|
|
188
|
+
const templates = [];
|
|
189
|
+
const errors = [];
|
|
190
|
+
for (const dir of template_dirs) {
|
|
191
|
+
const result = await load_template(dir);
|
|
192
|
+
if (is_success(result)) {
|
|
193
|
+
templates.push(result.value);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const relative_path = path.relative(templates_dir, dir);
|
|
197
|
+
errors.push(`${relative_path}: ${result.error.message}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (errors.length > 0) {
|
|
201
|
+
return failure(Errors.validation_error(`Failed to load templates:\n${errors.join('\n')}`));
|
|
202
|
+
}
|
|
203
|
+
return success(templates);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Loads all clusters from the clusters directory.
|
|
207
|
+
*/
|
|
208
|
+
export async function load_all_clusters(project_root) {
|
|
209
|
+
const clusters_dir = path.join(project_root, StandardDirs.CLUSTERS);
|
|
210
|
+
const dirs_result = await list_directories(clusters_dir);
|
|
211
|
+
if (!is_success(dirs_result)) {
|
|
212
|
+
// Return empty array if clusters directory doesn't exist
|
|
213
|
+
if (dirs_result.error.code === 'NOT_FOUND') {
|
|
214
|
+
return success([]);
|
|
215
|
+
}
|
|
216
|
+
return dirs_result;
|
|
217
|
+
}
|
|
218
|
+
const clusters = [];
|
|
219
|
+
const errors = [];
|
|
220
|
+
for (const dir of dirs_result.value) {
|
|
221
|
+
const result = await load_cluster(dir);
|
|
222
|
+
if (is_success(result)) {
|
|
223
|
+
clusters.push(result.value);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
errors.push(`${path.basename(dir)}: ${result.error.message}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (errors.length > 0) {
|
|
230
|
+
return failure(Errors.validation_error(`Failed to load clusters:\n${errors.join('\n')}`));
|
|
231
|
+
}
|
|
232
|
+
return success(clusters);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Loads a complete Kustodian project.
|
|
236
|
+
*/
|
|
237
|
+
export async function load_project(project_root) {
|
|
238
|
+
// Verify project exists
|
|
239
|
+
const project_file = path.join(project_root, StandardFiles.PROJECT);
|
|
240
|
+
if (!(await file_exists(project_file))) {
|
|
241
|
+
return failure(Errors.config_not_found('Project', project_file));
|
|
242
|
+
}
|
|
243
|
+
// Load project config if kustodian.yaml exists
|
|
244
|
+
let project_config;
|
|
245
|
+
const yaml_result = await read_yaml_file(project_file);
|
|
246
|
+
if (is_success(yaml_result)) {
|
|
247
|
+
const validation = validate_project(yaml_result.value);
|
|
248
|
+
if (validation.success) {
|
|
249
|
+
project_config = validation.data;
|
|
250
|
+
}
|
|
251
|
+
// Note: Validation errors are non-fatal for backward compatibility
|
|
252
|
+
}
|
|
253
|
+
// Load profiles first (they may be referenced by nodes)
|
|
254
|
+
const profiles_result = await load_all_profiles(project_root);
|
|
255
|
+
if (!is_success(profiles_result)) {
|
|
256
|
+
return profiles_result;
|
|
257
|
+
}
|
|
258
|
+
// Load templates
|
|
259
|
+
const templates_result = await load_all_templates(project_root);
|
|
260
|
+
if (!is_success(templates_result)) {
|
|
261
|
+
return templates_result;
|
|
262
|
+
}
|
|
263
|
+
// Load clusters
|
|
264
|
+
const clusters_result = await load_all_clusters(project_root);
|
|
265
|
+
if (!is_success(clusters_result)) {
|
|
266
|
+
return clusters_result;
|
|
267
|
+
}
|
|
268
|
+
const result = {
|
|
269
|
+
root: project_root,
|
|
270
|
+
templates: templates_result.value,
|
|
271
|
+
clusters: clusters_result.value,
|
|
272
|
+
profiles: profiles_result.value,
|
|
273
|
+
};
|
|
274
|
+
if (project_config) {
|
|
275
|
+
result.config = project_config;
|
|
276
|
+
}
|
|
277
|
+
return success(result);
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/loader/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAmB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAML,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,E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,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,iBAAiB;IACjB,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,gBAAgB;IAChB,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,MAAM,MAAM,GAAgB;QAC1B,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE,gBAAgB,CAAC,KAAK;QACjC,QAAQ,EAAE,eAAe,CAAC,KAAK;QAC/B,QAAQ,EAAE,eAAe,CAAC,KAAK;KAChC,CAAC;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC;IACjC,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KustodianErrorType } from '../core/index.js';
|
|
2
|
+
import { type ResultType } from '../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Parses a YAML string into an object.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parse_yaml<T>(content: string): ResultType<T, KustodianErrorType>;
|
|
7
|
+
/**
|
|
8
|
+
* Parses a multi-document YAML string (separated by ---) into an array of objects.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parse_multi_yaml<T>(content: string): ResultType<T[], KustodianErrorType>;
|
|
11
|
+
/**
|
|
12
|
+
* Converts an object to a YAML string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stringify_yaml<T>(data: T): ResultType<string, KustodianErrorType>;
|
|
15
|
+
//# sourceMappingURL=yaml.d.ts.map
|