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.
Files changed (351) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +346 -0
  3. package/dist/cli/bin.d.ts +3 -0
  4. package/dist/cli/bin.d.ts.map +1 -0
  5. package/dist/cli/bin.js +67 -0
  6. package/dist/cli/bin.js.map +1 -0
  7. package/dist/cli/command.d.ts +57 -0
  8. package/dist/cli/command.d.ts.map +1 -0
  9. package/dist/cli/command.js +26 -0
  10. package/dist/cli/command.js.map +1 -0
  11. package/dist/cli/commands/apply.d.ts +8 -0
  12. package/dist/cli/commands/apply.d.ts.map +1 -0
  13. package/dist/cli/commands/apply.js +802 -0
  14. package/dist/cli/commands/apply.js.map +1 -0
  15. package/dist/cli/commands/init.d.ts +5 -0
  16. package/dist/cli/commands/init.d.ts.map +1 -0
  17. package/dist/cli/commands/init.js +403 -0
  18. package/dist/cli/commands/init.js.map +1 -0
  19. package/dist/cli/commands/sources.d.ts +5 -0
  20. package/dist/cli/commands/sources.d.ts.map +1 -0
  21. package/dist/cli/commands/sources.js +377 -0
  22. package/dist/cli/commands/sources.js.map +1 -0
  23. package/dist/cli/commands/update.d.ts +5 -0
  24. package/dist/cli/commands/update.d.ts.map +1 -0
  25. package/dist/cli/commands/update.js +314 -0
  26. package/dist/cli/commands/update.js.map +1 -0
  27. package/dist/cli/commands/validate.d.ts +5 -0
  28. package/dist/cli/commands/validate.d.ts.map +1 -0
  29. package/dist/cli/commands/validate.js +126 -0
  30. package/dist/cli/commands/validate.js.map +1 -0
  31. package/dist/cli/container.d.ts +48 -0
  32. package/dist/cli/container.d.ts.map +1 -0
  33. package/dist/cli/container.js +49 -0
  34. package/dist/cli/container.js.map +1 -0
  35. package/dist/cli/index.d.ts +8 -0
  36. package/dist/cli/index.d.ts.map +1 -0
  37. package/dist/cli/index.js +9 -0
  38. package/dist/cli/index.js.map +1 -0
  39. package/dist/cli/middleware.d.ts +118 -0
  40. package/dist/cli/middleware.d.ts.map +1 -0
  41. package/dist/cli/middleware.js +280 -0
  42. package/dist/cli/middleware.js.map +1 -0
  43. package/dist/cli/runner.d.ts +34 -0
  44. package/dist/cli/runner.d.ts.map +1 -0
  45. package/dist/cli/runner.js +156 -0
  46. package/dist/cli/runner.js.map +1 -0
  47. package/dist/cli/utils/defaults.d.ts +23 -0
  48. package/dist/cli/utils/defaults.d.ts.map +1 -0
  49. package/dist/cli/utils/defaults.js +43 -0
  50. package/dist/cli/utils/defaults.js.map +1 -0
  51. package/dist/core/error.d.ts +117 -0
  52. package/dist/core/error.d.ts.map +1 -0
  53. package/dist/core/error.js +210 -0
  54. package/dist/core/error.js.map +1 -0
  55. package/dist/core/index.d.ts +6 -0
  56. package/dist/core/index.d.ts.map +1 -0
  57. package/dist/core/index.js +6 -0
  58. package/dist/core/index.js.map +1 -0
  59. package/dist/core/logger.d.ts +31 -0
  60. package/dist/core/logger.d.ts.map +1 -0
  61. package/dist/core/logger.js +78 -0
  62. package/dist/core/logger.js.map +1 -0
  63. package/dist/core/path.d.ts +57 -0
  64. package/dist/core/path.d.ts.map +1 -0
  65. package/dist/core/path.js +154 -0
  66. package/dist/core/path.js.map +1 -0
  67. package/dist/core/result.d.ts +80 -0
  68. package/dist/core/result.d.ts.map +1 -0
  69. package/dist/core/result.js +150 -0
  70. package/dist/core/result.js.map +1 -0
  71. package/dist/core/types.d.ts +80 -0
  72. package/dist/core/types.d.ts.map +1 -0
  73. package/dist/core/types.js +5 -0
  74. package/dist/core/types.js.map +1 -0
  75. package/dist/generator/external-substitutions.d.ts +21 -0
  76. package/dist/generator/external-substitutions.d.ts.map +1 -0
  77. package/dist/generator/external-substitutions.js +49 -0
  78. package/dist/generator/external-substitutions.js.map +1 -0
  79. package/dist/generator/flux.d.ts +61 -0
  80. package/dist/generator/flux.d.ts.map +1 -0
  81. package/dist/generator/flux.js +294 -0
  82. package/dist/generator/flux.js.map +1 -0
  83. package/dist/generator/generator.d.ts +77 -0
  84. package/dist/generator/generator.d.ts.map +1 -0
  85. package/dist/generator/generator.js +183 -0
  86. package/dist/generator/generator.js.map +1 -0
  87. package/dist/generator/index.d.ts +9 -0
  88. package/dist/generator/index.d.ts.map +1 -0
  89. package/dist/generator/index.js +9 -0
  90. package/dist/generator/index.js.map +1 -0
  91. package/dist/generator/kustomization-resolution.d.ts +40 -0
  92. package/dist/generator/kustomization-resolution.d.ts.map +1 -0
  93. package/dist/generator/kustomization-resolution.js +59 -0
  94. package/dist/generator/kustomization-resolution.js.map +1 -0
  95. package/dist/generator/namespace.d.ts +74 -0
  96. package/dist/generator/namespace.d.ts.map +1 -0
  97. package/dist/generator/namespace.js +109 -0
  98. package/dist/generator/namespace.js.map +1 -0
  99. package/dist/generator/output.d.ts +56 -0
  100. package/dist/generator/output.d.ts.map +1 -0
  101. package/dist/generator/output.js +171 -0
  102. package/dist/generator/output.js.map +1 -0
  103. package/dist/generator/preservation.d.ts +45 -0
  104. package/dist/generator/preservation.d.ts.map +1 -0
  105. package/dist/generator/preservation.js +71 -0
  106. package/dist/generator/preservation.js.map +1 -0
  107. package/dist/generator/substitution.d.ts +79 -0
  108. package/dist/generator/substitution.d.ts.map +1 -0
  109. package/dist/generator/substitution.js +210 -0
  110. package/dist/generator/substitution.js.map +1 -0
  111. package/dist/generator/types.d.ts +162 -0
  112. package/dist/generator/types.d.ts.map +1 -0
  113. package/dist/generator/types.js +2 -0
  114. package/dist/generator/types.js.map +1 -0
  115. package/dist/generator/validation/cycle-detection.d.ts +25 -0
  116. package/dist/generator/validation/cycle-detection.d.ts.map +1 -0
  117. package/dist/generator/validation/cycle-detection.js +101 -0
  118. package/dist/generator/validation/cycle-detection.js.map +1 -0
  119. package/dist/generator/validation/enablement.d.ts +24 -0
  120. package/dist/generator/validation/enablement.d.ts.map +1 -0
  121. package/dist/generator/validation/enablement.js +69 -0
  122. package/dist/generator/validation/enablement.js.map +1 -0
  123. package/dist/generator/validation/graph.d.ts +29 -0
  124. package/dist/generator/validation/graph.d.ts.map +1 -0
  125. package/dist/generator/validation/graph.js +106 -0
  126. package/dist/generator/validation/graph.js.map +1 -0
  127. package/dist/generator/validation/index.d.ts +38 -0
  128. package/dist/generator/validation/index.d.ts.map +1 -0
  129. package/dist/generator/validation/index.js +64 -0
  130. package/dist/generator/validation/index.js.map +1 -0
  131. package/dist/generator/validation/reference.d.ts +45 -0
  132. package/dist/generator/validation/reference.d.ts.map +1 -0
  133. package/dist/generator/validation/reference.js +143 -0
  134. package/dist/generator/validation/reference.js.map +1 -0
  135. package/dist/generator/validation/requirements.d.ts +25 -0
  136. package/dist/generator/validation/requirements.d.ts.map +1 -0
  137. package/dist/generator/validation/requirements.js +64 -0
  138. package/dist/generator/validation/requirements.js.map +1 -0
  139. package/dist/generator/validation/types.d.ts +116 -0
  140. package/dist/generator/validation/types.d.ts.map +1 -0
  141. package/dist/generator/validation/types.js +13 -0
  142. package/dist/generator/validation/types.js.map +1 -0
  143. package/dist/k8s/exec.d.ts +20 -0
  144. package/dist/k8s/exec.d.ts.map +1 -0
  145. package/dist/k8s/exec.js +47 -0
  146. package/dist/k8s/exec.js.map +1 -0
  147. package/dist/k8s/flux.d.ts +57 -0
  148. package/dist/k8s/flux.d.ts.map +1 -0
  149. package/dist/k8s/flux.js +202 -0
  150. package/dist/k8s/flux.js.map +1 -0
  151. package/dist/k8s/index.d.ts +6 -0
  152. package/dist/k8s/index.d.ts.map +1 -0
  153. package/dist/k8s/index.js +6 -0
  154. package/dist/k8s/index.js.map +1 -0
  155. package/dist/k8s/kubeconfig.d.ts +45 -0
  156. package/dist/k8s/kubeconfig.d.ts.map +1 -0
  157. package/dist/k8s/kubeconfig.js +152 -0
  158. package/dist/k8s/kubeconfig.js.map +1 -0
  159. package/dist/k8s/kubectl.d.ts +68 -0
  160. package/dist/k8s/kubectl.d.ts.map +1 -0
  161. package/dist/k8s/kubectl.js +187 -0
  162. package/dist/k8s/kubectl.js.map +1 -0
  163. package/dist/k8s/types.d.ts +65 -0
  164. package/dist/k8s/types.d.ts.map +1 -0
  165. package/dist/k8s/types.js +2 -0
  166. package/dist/k8s/types.js.map +1 -0
  167. package/dist/loader/file.d.ts +39 -0
  168. package/dist/loader/file.d.ts.map +1 -0
  169. package/dist/loader/file.js +121 -0
  170. package/dist/loader/file.js.map +1 -0
  171. package/dist/loader/index.d.ts +5 -0
  172. package/dist/loader/index.d.ts.map +1 -0
  173. package/dist/loader/index.js +5 -0
  174. package/dist/loader/index.js.map +1 -0
  175. package/dist/loader/profile.d.ts +23 -0
  176. package/dist/loader/profile.d.ts.map +1 -0
  177. package/dist/loader/profile.js +84 -0
  178. package/dist/loader/profile.js.map +1 -0
  179. package/dist/loader/project.d.ts +76 -0
  180. package/dist/loader/project.d.ts.map +1 -0
  181. package/dist/loader/project.js +279 -0
  182. package/dist/loader/project.js.map +1 -0
  183. package/dist/loader/yaml.d.ts +15 -0
  184. package/dist/loader/yaml.d.ts.map +1 -0
  185. package/dist/loader/yaml.js +44 -0
  186. package/dist/loader/yaml.js.map +1 -0
  187. package/dist/nodes/index.d.ts +5 -0
  188. package/dist/nodes/index.d.ts.map +1 -0
  189. package/dist/nodes/index.js +5 -0
  190. package/dist/nodes/index.js.map +1 -0
  191. package/dist/nodes/kubectl-labeler.d.ts +7 -0
  192. package/dist/nodes/kubectl-labeler.d.ts.map +1 -0
  193. package/dist/nodes/kubectl-labeler.js +89 -0
  194. package/dist/nodes/kubectl-labeler.js.map +1 -0
  195. package/dist/nodes/labeler.d.ts +74 -0
  196. package/dist/nodes/labeler.d.ts.map +1 -0
  197. package/dist/nodes/labeler.js +118 -0
  198. package/dist/nodes/labeler.js.map +1 -0
  199. package/dist/nodes/profile.d.ts +58 -0
  200. package/dist/nodes/profile.d.ts.map +1 -0
  201. package/dist/nodes/profile.js +128 -0
  202. package/dist/nodes/profile.js.map +1 -0
  203. package/dist/nodes/types.d.ts +84 -0
  204. package/dist/nodes/types.d.ts.map +1 -0
  205. package/dist/nodes/types.js +77 -0
  206. package/dist/nodes/types.js.map +1 -0
  207. package/dist/plugins/generators.d.ts +49 -0
  208. package/dist/plugins/generators.d.ts.map +1 -0
  209. package/dist/plugins/generators.js +7 -0
  210. package/dist/plugins/generators.js.map +1 -0
  211. package/dist/plugins/hooks.d.ts +120 -0
  212. package/dist/plugins/hooks.d.ts.map +1 -0
  213. package/dist/plugins/hooks.js +41 -0
  214. package/dist/plugins/hooks.js.map +1 -0
  215. package/dist/plugins/index.d.ts +8 -0
  216. package/dist/plugins/index.d.ts.map +1 -0
  217. package/dist/plugins/index.js +15 -0
  218. package/dist/plugins/index.js.map +1 -0
  219. package/dist/plugins/loader.d.ts +40 -0
  220. package/dist/plugins/loader.d.ts.map +1 -0
  221. package/dist/plugins/loader.js +236 -0
  222. package/dist/plugins/loader.js.map +1 -0
  223. package/dist/plugins/object-types.d.ts +71 -0
  224. package/dist/plugins/object-types.d.ts.map +1 -0
  225. package/dist/plugins/object-types.js +65 -0
  226. package/dist/plugins/object-types.js.map +1 -0
  227. package/dist/plugins/registry.d.ts +87 -0
  228. package/dist/plugins/registry.d.ts.map +1 -0
  229. package/dist/plugins/registry.js +158 -0
  230. package/dist/plugins/registry.js.map +1 -0
  231. package/dist/plugins/substitution-providers.d.ts +48 -0
  232. package/dist/plugins/substitution-providers.d.ts.map +1 -0
  233. package/dist/plugins/substitution-providers.js +2 -0
  234. package/dist/plugins/substitution-providers.js.map +1 -0
  235. package/dist/plugins/types.d.ts +288 -0
  236. package/dist/plugins/types.d.ts.map +1 -0
  237. package/dist/plugins/types.js +25 -0
  238. package/dist/plugins/types.js.map +1 -0
  239. package/dist/registry/auth.d.ts +14 -0
  240. package/dist/registry/auth.d.ts.map +1 -0
  241. package/dist/registry/auth.js +40 -0
  242. package/dist/registry/auth.js.map +1 -0
  243. package/dist/registry/client.d.ts +24 -0
  244. package/dist/registry/client.d.ts.map +1 -0
  245. package/dist/registry/client.js +85 -0
  246. package/dist/registry/client.js.map +1 -0
  247. package/dist/registry/dockerhub.d.ts +6 -0
  248. package/dist/registry/dockerhub.d.ts.map +1 -0
  249. package/dist/registry/dockerhub.js +91 -0
  250. package/dist/registry/dockerhub.js.map +1 -0
  251. package/dist/registry/ghcr.d.ts +6 -0
  252. package/dist/registry/ghcr.d.ts.map +1 -0
  253. package/dist/registry/ghcr.js +95 -0
  254. package/dist/registry/ghcr.js.map +1 -0
  255. package/dist/registry/helm.d.ts +11 -0
  256. package/dist/registry/helm.d.ts.map +1 -0
  257. package/dist/registry/helm.js +124 -0
  258. package/dist/registry/helm.js.map +1 -0
  259. package/dist/registry/index.d.ts +8 -0
  260. package/dist/registry/index.d.ts.map +1 -0
  261. package/dist/registry/index.js +12 -0
  262. package/dist/registry/index.js.map +1 -0
  263. package/dist/registry/types.d.ts +55 -0
  264. package/dist/registry/types.d.ts.map +1 -0
  265. package/dist/registry/types.js +2 -0
  266. package/dist/registry/types.js.map +1 -0
  267. package/dist/registry/version.d.ts +22 -0
  268. package/dist/registry/version.d.ts.map +1 -0
  269. package/dist/registry/version.js +62 -0
  270. package/dist/registry/version.js.map +1 -0
  271. package/dist/schema/cluster.d.ts +2890 -0
  272. package/dist/schema/cluster.d.ts.map +1 -0
  273. package/dist/schema/cluster.js +231 -0
  274. package/dist/schema/cluster.js.map +1 -0
  275. package/dist/schema/common.d.ts +1059 -0
  276. package/dist/schema/common.d.ts.map +1 -0
  277. package/dist/schema/common.js +340 -0
  278. package/dist/schema/common.js.map +1 -0
  279. package/dist/schema/index.d.ts +8 -0
  280. package/dist/schema/index.d.ts.map +1 -0
  281. package/dist/schema/index.js +8 -0
  282. package/dist/schema/index.js.map +1 -0
  283. package/dist/schema/node-list.d.ts +361 -0
  284. package/dist/schema/node-list.d.ts.map +1 -0
  285. package/dist/schema/node-list.js +104 -0
  286. package/dist/schema/node-list.js.map +1 -0
  287. package/dist/schema/profile.d.ts +166 -0
  288. package/dist/schema/profile.d.ts.map +1 -0
  289. package/dist/schema/profile.js +61 -0
  290. package/dist/schema/profile.js.map +1 -0
  291. package/dist/schema/project.d.ts +168 -0
  292. package/dist/schema/project.d.ts.map +1 -0
  293. package/dist/schema/project.js +40 -0
  294. package/dist/schema/project.js.map +1 -0
  295. package/dist/schema/sources.d.ts +338 -0
  296. package/dist/schema/sources.d.ts.map +1 -0
  297. package/dist/schema/sources.js +111 -0
  298. package/dist/schema/sources.js.map +1 -0
  299. package/dist/schema/template.d.ts +2711 -0
  300. package/dist/schema/template.d.ts.map +1 -0
  301. package/dist/schema/template.js +97 -0
  302. package/dist/schema/template.js.map +1 -0
  303. package/dist/sources/cache/index.d.ts +9 -0
  304. package/dist/sources/cache/index.d.ts.map +1 -0
  305. package/dist/sources/cache/index.js +278 -0
  306. package/dist/sources/cache/index.js.map +1 -0
  307. package/dist/sources/cache/metadata.d.ts +36 -0
  308. package/dist/sources/cache/metadata.d.ts.map +1 -0
  309. package/dist/sources/cache/metadata.js +21 -0
  310. package/dist/sources/cache/metadata.js.map +1 -0
  311. package/dist/sources/cache/ttl.d.ts +20 -0
  312. package/dist/sources/cache/ttl.d.ts.map +1 -0
  313. package/dist/sources/cache/ttl.js +53 -0
  314. package/dist/sources/cache/ttl.js.map +1 -0
  315. package/dist/sources/fetchers/git.d.ts +6 -0
  316. package/dist/sources/fetchers/git.d.ts.map +1 -0
  317. package/dist/sources/fetchers/git.js +165 -0
  318. package/dist/sources/fetchers/git.js.map +1 -0
  319. package/dist/sources/fetchers/http.d.ts +6 -0
  320. package/dist/sources/fetchers/http.d.ts.map +1 -0
  321. package/dist/sources/fetchers/http.js +159 -0
  322. package/dist/sources/fetchers/http.js.map +1 -0
  323. package/dist/sources/fetchers/index.d.ts +11 -0
  324. package/dist/sources/fetchers/index.d.ts.map +1 -0
  325. package/dist/sources/fetchers/index.js +24 -0
  326. package/dist/sources/fetchers/index.js.map +1 -0
  327. package/dist/sources/fetchers/oci.d.ts +6 -0
  328. package/dist/sources/fetchers/oci.d.ts.map +1 -0
  329. package/dist/sources/fetchers/oci.js +156 -0
  330. package/dist/sources/fetchers/oci.js.map +1 -0
  331. package/dist/sources/fetchers/types.d.ts +25 -0
  332. package/dist/sources/fetchers/types.d.ts.map +1 -0
  333. package/dist/sources/fetchers/types.js +2 -0
  334. package/dist/sources/fetchers/types.js.map +1 -0
  335. package/dist/sources/index.d.ts +6 -0
  336. package/dist/sources/index.d.ts.map +1 -0
  337. package/dist/sources/index.js +10 -0
  338. package/dist/sources/index.js.map +1 -0
  339. package/dist/sources/loader.d.ts +34 -0
  340. package/dist/sources/loader.d.ts.map +1 -0
  341. package/dist/sources/loader.js +89 -0
  342. package/dist/sources/loader.js.map +1 -0
  343. package/dist/sources/resolver.d.ts +17 -0
  344. package/dist/sources/resolver.d.ts.map +1 -0
  345. package/dist/sources/resolver.js +125 -0
  346. package/dist/sources/resolver.js.map +1 -0
  347. package/dist/sources/types.d.ts +151 -0
  348. package/dist/sources/types.d.ts.map +1 -0
  349. package/dist/sources/types.js +2 -0
  350. package/dist/sources/types.js.map +1 -0
  351. package/package.json +101 -0
@@ -0,0 +1,236 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { Errors, failure, is_success, success } from '../core/index.js';
5
+ /**
6
+ * Default npm package prefixes for plugin discovery.
7
+ */
8
+ const DEFAULT_NPM_PREFIXES = ['kustodian-', '@kustodian/plugin-', 'kustodian-plugin-'];
9
+ /**
10
+ * Default local plugin directories.
11
+ */
12
+ const DEFAULT_LOCAL_DIRS = ['./plugins'];
13
+ /**
14
+ * Validates that an object is a valid plugin manifest.
15
+ */
16
+ function is_valid_manifest(manifest) {
17
+ if (typeof manifest !== 'object' || manifest === null) {
18
+ return false;
19
+ }
20
+ const m = manifest;
21
+ return (typeof m['name'] === 'string' &&
22
+ typeof m['version'] === 'string' &&
23
+ Array.isArray(m['capabilities']));
24
+ }
25
+ /**
26
+ * Creates a new plugin loader.
27
+ */
28
+ export function create_plugin_loader(config = {}) {
29
+ const { local_plugin_dirs = DEFAULT_LOCAL_DIRS, search_node_modules = true, npm_prefixes = DEFAULT_NPM_PREFIXES, } = config;
30
+ // Cache for loaded plugins
31
+ const plugin_cache = new Map();
32
+ /**
33
+ * Discovers plugins in local directories.
34
+ */
35
+ async function discover_local_plugins() {
36
+ const locations = [];
37
+ for (const dir of local_plugin_dirs) {
38
+ const abs_dir = path.resolve(dir);
39
+ try {
40
+ const entries = await fs.readdir(abs_dir, { withFileTypes: true });
41
+ for (const entry of entries) {
42
+ if (entry.isDirectory()) {
43
+ const plugin_path = path.join(abs_dir, entry.name);
44
+ const package_json_path = path.join(plugin_path, 'package.json');
45
+ try {
46
+ await fs.access(package_json_path);
47
+ locations.push({
48
+ source: 'local',
49
+ module_path: entry.name,
50
+ resolved_path: plugin_path,
51
+ });
52
+ }
53
+ catch {
54
+ // Not a valid plugin directory (no package.json)
55
+ }
56
+ }
57
+ }
58
+ }
59
+ catch {
60
+ // Directory doesn't exist, skip
61
+ }
62
+ }
63
+ return locations;
64
+ }
65
+ /**
66
+ * Discovers plugins in node_modules.
67
+ */
68
+ async function discover_npm_plugins() {
69
+ if (!search_node_modules) {
70
+ return [];
71
+ }
72
+ const locations = [];
73
+ const node_modules = path.resolve('./node_modules');
74
+ try {
75
+ const entries = await fs.readdir(node_modules, { withFileTypes: true });
76
+ for (const entry of entries) {
77
+ if (entry.isDirectory()) {
78
+ // Check if it's a scoped package (@kustodian/plugin-*)
79
+ if (entry.name.startsWith('@')) {
80
+ try {
81
+ const scoped_path = path.join(node_modules, entry.name);
82
+ const scoped_entries = await fs.readdir(scoped_path, { withFileTypes: true });
83
+ for (const scoped_entry of scoped_entries) {
84
+ if (scoped_entry.isDirectory()) {
85
+ const full_name = `${entry.name}/${scoped_entry.name}`;
86
+ if (npm_prefixes.some((prefix) => full_name.startsWith(prefix))) {
87
+ locations.push({
88
+ source: 'npm',
89
+ module_path: full_name,
90
+ resolved_path: path.join(scoped_path, scoped_entry.name),
91
+ });
92
+ }
93
+ }
94
+ }
95
+ }
96
+ catch {
97
+ // Failed to read scoped directory
98
+ }
99
+ }
100
+ else if (npm_prefixes.some((prefix) => entry.name.startsWith(prefix))) {
101
+ // Unscoped package (kustodian-plugin-*)
102
+ locations.push({
103
+ source: 'npm',
104
+ module_path: entry.name,
105
+ resolved_path: path.join(node_modules, entry.name),
106
+ });
107
+ }
108
+ }
109
+ }
110
+ }
111
+ catch {
112
+ // node_modules doesn't exist
113
+ }
114
+ return locations;
115
+ }
116
+ /**
117
+ * Loads a plugin module from a resolved path.
118
+ */
119
+ async function load_plugin_module(resolved_path, source) {
120
+ try {
121
+ // Read package.json to get main entry point
122
+ const package_json_path = path.join(resolved_path, 'package.json');
123
+ const package_content = await fs.readFile(package_json_path, 'utf-8');
124
+ const package_json = JSON.parse(package_content);
125
+ // Determine entry point (prefer exports, then main)
126
+ let entry_point = package_json['main'] ?? './dist/index.js';
127
+ const exports_field = package_json['exports'];
128
+ if (exports_field) {
129
+ if (typeof exports_field === 'string') {
130
+ entry_point = exports_field;
131
+ }
132
+ else if (typeof exports_field === 'object' && exports_field !== null) {
133
+ const exports_obj = exports_field;
134
+ const root_export = exports_obj['.'];
135
+ if (typeof root_export === 'string') {
136
+ entry_point = root_export;
137
+ }
138
+ else if (typeof root_export === 'object' && root_export !== null) {
139
+ const root_obj = root_export;
140
+ entry_point =
141
+ root_obj['import'] ?? root_obj['default'] ?? entry_point;
142
+ }
143
+ }
144
+ }
145
+ const module_path = path.join(resolved_path, entry_point);
146
+ const module_url = pathToFileURL(module_path).href;
147
+ // Dynamic import
148
+ const module = (await import(module_url));
149
+ // Look for default export or named 'plugin' export
150
+ const plugin = (module['default'] ?? module['plugin']);
151
+ if (!plugin) {
152
+ return failure(Errors.plugin_load_error(resolved_path, 'No default or named plugin export found'));
153
+ }
154
+ // Validate manifest
155
+ if (!plugin.manifest || !is_valid_manifest(plugin.manifest)) {
156
+ return failure(Errors.plugin_load_error(resolved_path, 'Invalid or missing plugin manifest'));
157
+ }
158
+ const loaded = {
159
+ plugin,
160
+ location: {
161
+ source,
162
+ module_path: resolved_path,
163
+ resolved_path,
164
+ },
165
+ };
166
+ return success(loaded);
167
+ }
168
+ catch (error) {
169
+ return failure(Errors.plugin_load_error(resolved_path, error));
170
+ }
171
+ }
172
+ return {
173
+ async discover() {
174
+ const local = await discover_local_plugins();
175
+ const npm = await discover_npm_plugins();
176
+ return success([...local, ...npm]);
177
+ },
178
+ async load(name) {
179
+ // Check cache
180
+ const cached = plugin_cache.get(name);
181
+ if (cached) {
182
+ return success(cached);
183
+ }
184
+ // Discover and find
185
+ const discover_result = await this.discover();
186
+ if (!is_success(discover_result)) {
187
+ return discover_result;
188
+ }
189
+ // Try to find by various name patterns
190
+ const location = discover_result.value.find((loc) => loc.module_path === name ||
191
+ loc.module_path.endsWith(`/${name}`) ||
192
+ loc.module_path === `kustodian-${name}` ||
193
+ loc.module_path === `@kustodian/plugin-${name}` ||
194
+ loc.module_path === `kustodian-plugin-${name}`);
195
+ if (!location) {
196
+ return failure(Errors.plugin_not_found(name));
197
+ }
198
+ const load_result = await load_plugin_module(location.resolved_path, location.source);
199
+ if (!is_success(load_result)) {
200
+ return load_result;
201
+ }
202
+ // Cache the loaded plugin
203
+ plugin_cache.set(name, load_result.value);
204
+ plugin_cache.set(load_result.value.plugin.manifest.name, load_result.value);
205
+ return success(load_result.value);
206
+ },
207
+ async load_from_path(plugin_path) {
208
+ const resolved_path = path.resolve(plugin_path);
209
+ // Check cache by resolved path
210
+ for (const [, cached] of plugin_cache) {
211
+ if (cached.location.resolved_path === resolved_path) {
212
+ return success(cached);
213
+ }
214
+ }
215
+ const load_result = await load_plugin_module(resolved_path, 'local');
216
+ if (!is_success(load_result)) {
217
+ return load_result;
218
+ }
219
+ // Cache the loaded plugin
220
+ plugin_cache.set(load_result.value.plugin.manifest.name, load_result.value);
221
+ return success(load_result.value);
222
+ },
223
+ async load_all(names) {
224
+ const results = [];
225
+ for (const name of names) {
226
+ const result = await this.load(name);
227
+ if (!is_success(result)) {
228
+ return result;
229
+ }
230
+ results.push(result.value);
231
+ }
232
+ return success(results);
233
+ },
234
+ };
235
+ }
236
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAmB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA+CzF;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,WAAW,CAAC,CAAC;AAEzC;;GAEG;AACH,SAAS,iBAAiB,CAAC,QAAiB;IAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,GAAG,QAAmC,CAAC;IAC9C,OAAO,CACL,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ;QAC7B,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,QAAQ;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CACjC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAoC,EAAE;IACzE,MAAM,EACJ,iBAAiB,GAAG,kBAAkB,EACtC,mBAAmB,GAAG,IAAI,EAC1B,YAAY,GAAG,oBAAoB,GACpC,GAAG,MAAM,CAAC;IAEX,2BAA2B;IAC3B,MAAM,YAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEzD;;OAEG;IACH,KAAK,UAAU,sBAAs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oBACxB,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { z } from 'zod';
2
+ /**
3
+ * Locations where plugin objects can appear.
4
+ */
5
+ export type ObjectLocationType = 'cluster.spec' | 'template.spec' | 'standalone' | 'inline';
6
+ /**
7
+ * Plugin object type definition.
8
+ * Defines a custom Kubernetes-style object that plugins can introduce.
9
+ */
10
+ export interface PluginObjectTypeType<T = unknown> {
11
+ /** API version (e.g., "helm.kustodian.io/v1") */
12
+ api_version: string;
13
+ /** Kind identifier (e.g., "HelmChart") */
14
+ kind: string;
15
+ /** Zod schema for validation */
16
+ schema: z.ZodType<T>;
17
+ /** Valid locations for this object type */
18
+ locations: ObjectLocationType[];
19
+ /** Optional description */
20
+ description?: string;
21
+ }
22
+ /**
23
+ * Parsed object with type information.
24
+ */
25
+ export interface ParsedObjectType<T = unknown> {
26
+ api_version: string;
27
+ kind: string;
28
+ data: T;
29
+ source_path?: string;
30
+ }
31
+ /**
32
+ * Object type registry for managing plugin-defined object types.
33
+ */
34
+ export interface ObjectTypeRegistryType {
35
+ /**
36
+ * Registers an object type.
37
+ */
38
+ register<T>(object_type: PluginObjectTypeType<T>): void;
39
+ /**
40
+ * Gets an object type by api_version and kind.
41
+ */
42
+ get(api_version: string, kind: string): PluginObjectTypeType | undefined;
43
+ /**
44
+ * Validates an object against its registered schema.
45
+ * Returns the parsed object if valid, or validation errors.
46
+ */
47
+ validate(object: unknown): ParsedObjectType | {
48
+ errors: string[];
49
+ };
50
+ /**
51
+ * Checks if an object type is registered.
52
+ */
53
+ has(api_version: string, kind: string): boolean;
54
+ /**
55
+ * Lists all registered object types.
56
+ */
57
+ list(): PluginObjectTypeType[];
58
+ /**
59
+ * Gets all object types that can appear in a specific location.
60
+ */
61
+ get_by_location(location: ObjectLocationType): PluginObjectTypeType[];
62
+ }
63
+ /**
64
+ * Creates a new object type registry.
65
+ */
66
+ export declare function create_object_type_registry(): ObjectTypeRegistryType;
67
+ /**
68
+ * Helper to define a plugin object type with proper typing.
69
+ */
70
+ export declare function define_object_type<T>(config: PluginObjectTypeType<T>): PluginObjectTypeType<T>;
71
+ //# sourceMappingURL=object-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-types.d.ts","sourceRoot":"","sources":["../../src/plugins/object-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,cAAc,GACd,eAAe,GACf,YAAY,GACZ,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,OAAO;IAC/C,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,2CAA2C;IAC3C,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAC;IAEzE;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,GAAG;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAEnE;;OAEG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEhD;;OAEG;IACH,IAAI,IAAI,oBAAoB,EAAE,CAAC;IAE/B;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAAC;CACvE;AASD;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CA8DpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAE9F"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Creates a unique key for an object type.
3
+ */
4
+ function make_key(api_version, kind) {
5
+ return `${api_version}/${kind}`;
6
+ }
7
+ /**
8
+ * Creates a new object type registry.
9
+ */
10
+ export function create_object_type_registry() {
11
+ const types = new Map();
12
+ return {
13
+ register(object_type) {
14
+ const key = make_key(object_type.api_version, object_type.kind);
15
+ types.set(key, object_type);
16
+ },
17
+ get(api_version, kind) {
18
+ const key = make_key(api_version, kind);
19
+ return types.get(key);
20
+ },
21
+ validate(object) {
22
+ if (typeof object !== 'object' || object === null) {
23
+ return { errors: ['Object must be a non-null object'] };
24
+ }
25
+ const obj = object;
26
+ const api_version = obj['apiVersion'];
27
+ const kind = obj['kind'];
28
+ if (!api_version || !kind) {
29
+ return { errors: ['Object must have apiVersion and kind fields'] };
30
+ }
31
+ const object_type = this.get(api_version, kind);
32
+ if (!object_type) {
33
+ return { errors: [`Unknown object type: ${api_version}/${kind}`] };
34
+ }
35
+ const result = object_type.schema.safeParse(object);
36
+ if (!result.success) {
37
+ return {
38
+ errors: result.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`),
39
+ };
40
+ }
41
+ return {
42
+ api_version,
43
+ kind,
44
+ data: result.data,
45
+ };
46
+ },
47
+ has(api_version, kind) {
48
+ const key = make_key(api_version, kind);
49
+ return types.has(key);
50
+ },
51
+ list() {
52
+ return Array.from(types.values());
53
+ },
54
+ get_by_location(location) {
55
+ return Array.from(types.values()).filter((t) => t.locations.includes(location));
56
+ },
57
+ };
58
+ }
59
+ /**
60
+ * Helper to define a plugin object type with proper typing.
61
+ */
62
+ export function define_object_type(config) {
63
+ return config;
64
+ }
65
+ //# sourceMappingURL=object-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-types.js","sourceRoot":"","sources":["../../src/plugins/object-types.ts"],"names":[],"mappings":"AA0EA;;GAEG;AACH,SAAS,QAAQ,CAAC,WAAmB,EAAE,IAAY;IACjD,OAAO,GAAG,WAAW,IAAI,IAAI,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEtD,OAAO;QACL,QAAQ,CAAI,WAAoC;YAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;YAChE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,WAAmC,CAAC,CAAC;QACtD,CAAC;QAED,GAAG,CAAC,WAAW,EAAE,IAAI;YACnB,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACxC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAED,QAAQ,CAAC,MAAM;YACb,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClD,OAAO,EAAE,MAAM,EAAE,CAAC,kCAAkC,CAAC,EAA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AAe,CAAC,QAAQ;YACtB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClF,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAI,MAA+B;IACnE,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { KustodianErrorType } from '../core/index.js';
2
+ import { type ResultType } from '../core/index.js';
3
+ import type { PluginGeneratorType } from './generators.js';
4
+ import { type HookDispatcherType } from './hooks.js';
5
+ import { type ObjectTypeRegistryType } from './object-types.js';
6
+ import type { SubstitutionProviderType } from './substitution-providers.js';
7
+ import type { KustodianPluginType, LoadedPluginType, PluginActivationContextType, PluginCommandContributionType, PluginManifestType } from './types.js';
8
+ /**
9
+ * Unified plugin registry that manages all plugin contributions.
10
+ */
11
+ export interface PluginRegistryType {
12
+ /**
13
+ * Registers a loaded plugin.
14
+ */
15
+ register(loaded: LoadedPluginType): ResultType<void, KustodianErrorType>;
16
+ /**
17
+ * Activates all registered plugins.
18
+ */
19
+ activate_all(ctx: PluginActivationContextType): Promise<ResultType<void, KustodianErrorType>>;
20
+ /**
21
+ * Deactivates all registered plugins.
22
+ */
23
+ deactivate_all(): Promise<ResultType<void, KustodianErrorType>>;
24
+ /**
25
+ * Gets a plugin by name.
26
+ */
27
+ get(name: string): KustodianPluginType | undefined;
28
+ /**
29
+ * Lists all registered plugin manifests.
30
+ */
31
+ list(): PluginManifestType[];
32
+ /**
33
+ * Lists all registered plugin names.
34
+ */
35
+ list_names(): string[];
36
+ /**
37
+ * Gets all command contributions from plugins.
38
+ */
39
+ get_commands(): PluginCommandContributionType[];
40
+ /**
41
+ * Gets the hook dispatcher for dispatching events.
42
+ */
43
+ get_hook_dispatcher(): HookDispatcherType;
44
+ /**
45
+ * Gets all generators from plugins.
46
+ */
47
+ get_generators(): PluginGeneratorType[];
48
+ /**
49
+ * Gets the object type registry.
50
+ */
51
+ get_object_types(): ObjectTypeRegistryType;
52
+ /**
53
+ * Gets a generator that handles a specific object type.
54
+ */
55
+ get_generator_for_type(api_version: string, kind: string): PluginGeneratorType | undefined;
56
+ /**
57
+ * Gets all substitution providers from plugins.
58
+ */
59
+ get_substitution_providers(): SubstitutionProviderType[];
60
+ /**
61
+ * Gets a substitution provider for a specific type.
62
+ */
63
+ get_substitution_provider(type: string): SubstitutionProviderType | undefined;
64
+ }
65
+ /**
66
+ * Creates a new unified plugin registry.
67
+ */
68
+ export declare function create_plugin_registry(): PluginRegistryType;
69
+ import type { LegacyPluginType, ResourceGeneratorPluginType, SecretProviderPluginType, TransformerPluginType, ValidatorPluginType } from './types.js';
70
+ /**
71
+ * @deprecated Use PluginRegistryType instead
72
+ */
73
+ export interface LegacyPluginRegistryType {
74
+ register(plugin: LegacyPluginType): ResultType<void, KustodianErrorType>;
75
+ get(name: string): LegacyPluginType | undefined;
76
+ get_secret_providers(): SecretProviderPluginType[];
77
+ get_secret_provider_by_scheme(scheme: string): SecretProviderPluginType | undefined;
78
+ get_resource_generators(): ResourceGeneratorPluginType[];
79
+ get_validators(): ValidatorPluginType[];
80
+ get_transformers(): TransformerPluginType[];
81
+ list(): string[];
82
+ }
83
+ /**
84
+ * @deprecated Use create_plugin_registry instead
85
+ */
86
+ export declare function create_legacy_plugin_registry(): LegacyPluginRegistryType;
87
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugins/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAU,KAAK,UAAU,EAAgC,MAAM,kBAAkB,CAAC;AAEzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBA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yB,CAAC,IAAI,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAAC;CAC/E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,kBAAkB,CA+I3D;AAMD,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAQpB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACzE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;IAChD,oBAAoB,IAAI,wBAAwB,EAAE,CAAC;IACnD,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAAC;IACpF,uBAAuB,IAAI,2BAA2B,EAAE,CAAC;IACzD,cAAc,IAAI,mBAAmB,EAAE,CAAC;IACxC,gBAAgB,IAAI,qBAAqB,EAAE,CAAC;IAC5C,IAAI,IAAI,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,wBAAwB,CAyCxE"}
@@ -0,0 +1,158 @@
1
+ import { Errors, failure, is_success, success } from '../core/index.js';
2
+ import { create_hook_dispatcher } from './hooks.js';
3
+ import { create_object_type_registry } from './object-types.js';
4
+ /**
5
+ * Creates a new unified plugin registry.
6
+ */
7
+ export function create_plugin_registry() {
8
+ const plugins = new Map();
9
+ const activated = new Set();
10
+ // Contribution collections
11
+ const commands = [];
12
+ const generators = [];
13
+ const substitution_providers = [];
14
+ const hook_dispatcher = create_hook_dispatcher();
15
+ const object_type_registry = create_object_type_registry();
16
+ return {
17
+ register(loaded) {
18
+ const { plugin } = loaded;
19
+ const name = plugin.manifest.name;
20
+ if (plugins.has(name)) {
21
+ return failure(Errors.already_exists('Plugin', name));
22
+ }
23
+ plugins.set(name, plugin);
24
+ // Collect command contributions
25
+ if (plugin.get_commands) {
26
+ const plugin_commands = plugin.get_commands();
27
+ commands.push(...plugin_commands);
28
+ }
29
+ // Collect hook contributions
30
+ if (plugin.get_hooks) {
31
+ const plugin_hooks = plugin.get_hooks();
32
+ for (const hook of plugin_hooks) {
33
+ hook_dispatcher.register(hook);
34
+ }
35
+ }
36
+ // Collect generator contributions
37
+ if (plugin.get_generators) {
38
+ const plugin_generators = plugin.get_generators();
39
+ generators.push(...plugin_generators);
40
+ }
41
+ // Collect object type contributions
42
+ if (plugin.get_object_types) {
43
+ const plugin_object_types = plugin.get_object_types();
44
+ for (const object_type of plugin_object_types) {
45
+ object_type_registry.register(object_type);
46
+ }
47
+ }
48
+ // Collect substitution provider contributions
49
+ if (plugin.get_substitution_providers) {
50
+ const plugin_substitution_providers = plugin.get_substitution_providers();
51
+ substitution_providers.push(...plugin_substitution_providers);
52
+ }
53
+ return success(undefined);
54
+ },
55
+ async activate_all(ctx) {
56
+ for (const [name, plugin] of plugins) {
57
+ if (activated.has(name)) {
58
+ continue;
59
+ }
60
+ if (plugin.activate) {
61
+ const result = await plugin.activate(ctx);
62
+ if (!is_success(result)) {
63
+ return result;
64
+ }
65
+ }
66
+ activated.add(name);
67
+ }
68
+ return success(undefined);
69
+ },
70
+ async deactivate_all() {
71
+ // Deactivate in reverse order
72
+ const names = Array.from(activated).reverse();
73
+ for (const name of names) {
74
+ const plugin = plugins.get(name);
75
+ if (!plugin) {
76
+ continue;
77
+ }
78
+ if (plugin.deactivate) {
79
+ const result = await plugin.deactivate();
80
+ if (!is_success(result)) {
81
+ return result;
82
+ }
83
+ }
84
+ activated.delete(name);
85
+ }
86
+ return success(undefined);
87
+ },
88
+ get(name) {
89
+ return plugins.get(name);
90
+ },
91
+ list() {
92
+ return Array.from(plugins.values()).map((p) => p.manifest);
93
+ },
94
+ list_names() {
95
+ return Array.from(plugins.keys());
96
+ },
97
+ get_commands() {
98
+ return [...commands];
99
+ },
100
+ get_hook_dispatcher() {
101
+ return hook_dispatcher;
102
+ },
103
+ get_generators() {
104
+ return [...generators];
105
+ },
106
+ get_object_types() {
107
+ return object_type_registry;
108
+ },
109
+ get_generator_for_type(api_version, kind) {
110
+ return generators.find((g) => g.handles.some((h) => h.api_version === api_version && h.kind === kind));
111
+ },
112
+ get_substitution_providers() {
113
+ return [...substitution_providers];
114
+ },
115
+ get_substitution_provider(type) {
116
+ return substitution_providers.find((p) => p.type === type);
117
+ },
118
+ };
119
+ }
120
+ import { is_resource_generator, is_secret_provider, is_transformer, is_validator, } from './types.js';
121
+ /**
122
+ * @deprecated Use create_plugin_registry instead
123
+ */
124
+ export function create_legacy_plugin_registry() {
125
+ const plugins = new Map();
126
+ return {
127
+ register(plugin) {
128
+ const name = plugin.manifest.name;
129
+ if (plugins.has(name)) {
130
+ return failure(Errors.already_exists('Plugin', name));
131
+ }
132
+ plugins.set(name, plugin);
133
+ return success(undefined);
134
+ },
135
+ get(name) {
136
+ return plugins.get(name);
137
+ },
138
+ get_secret_providers() {
139
+ return Array.from(plugins.values()).filter(is_secret_provider);
140
+ },
141
+ get_secret_provider_by_scheme(scheme) {
142
+ return this.get_secret_providers().find((p) => p.scheme === scheme);
143
+ },
144
+ get_resource_generators() {
145
+ return Array.from(plugins.values()).filter(is_resource_generator);
146
+ },
147
+ get_validators() {
148
+ return Array.from(plugins.values()).filter(is_validator);
149
+ },
150
+ get_transformers() {
151
+ return Array.from(plugins.values()).filter(is_transformer);
152
+ },
153
+ list() {
154
+ return Array.from(plugins.keys());
155
+ },
156
+ };
157
+ }
158
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/plugins/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAmB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGzF,OAAO,EAA2B,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO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