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,10 @@
1
+ // Types
2
+ // Cache
3
+ export { cache_meta_schema, calculate_expiry, create_cache_manager, DEFAULT_TTL, is_expired, META_FILENAME, parse_ttl, TEMPLATES_DIRNAME, } from './cache/index.js';
4
+ // Fetchers
5
+ export { create_git_fetcher, create_http_fetcher, create_oci_fetcher, get_fetcher_for_source, } from './fetchers/index.js';
6
+ // Template loader integration
7
+ export { load_templates_from_sources, } from './loader.js';
8
+ // Resolver
9
+ export { create_source_resolver, DEFAULT_CACHE_DIR, } from './resolver.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sources/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AAER,QAAQ;AACR,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,WAAW;AACX,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,8BAA8B;AAC9B,OAAO,EAGL,2BAA2B,GAE5B,MAAM,aAAa,CAAC;AAErB,WAAW;AACX,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type KustodianErrorType, type ResultType } from '../core/index.js';
2
+ import { type LoadedTemplateType } from '../loader/index.js';
3
+ import type { TemplateSourceType } from '../schema/index.js';
4
+ import { type CreateResolverOptionsType } from './resolver.js';
5
+ import type { FetchOptionsType, ResolvedSourceType } from './types.js';
6
+ /**
7
+ * A loaded template with source information.
8
+ */
9
+ export interface SourcedTemplateType extends LoadedTemplateType {
10
+ /** Name of the source this template came from */
11
+ source_name: string;
12
+ }
13
+ /**
14
+ * Result of loading templates from sources.
15
+ */
16
+ export interface LoadedSourcesResultType {
17
+ /** All loaded templates from all sources */
18
+ templates: SourcedTemplateType[];
19
+ /** Successfully resolved sources */
20
+ resolved: ResolvedSourceType[];
21
+ }
22
+ /**
23
+ * Options for loading templates from sources.
24
+ */
25
+ export interface LoadSourcesOptionsType extends FetchOptionsType, CreateResolverOptionsType {
26
+ /** Run fetches in parallel (default: true) */
27
+ parallel?: boolean;
28
+ }
29
+ /**
30
+ * Loads templates from all configured sources.
31
+ * Fetches from remote (or cache) and loads all template.yaml files found.
32
+ */
33
+ export declare function load_templates_from_sources(sources: TemplateSourceType[], options?: LoadSourcesOptionsType): Promise<ResultType<LoadedSourcesResultType, KustodianErrorType>>;
34
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/sources/loader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAIhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,kBAAkB,EAAmC,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,KAAK,yBAAyB,EAA0B,MAAM,eAAe,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,4CAA4C;IAC5C,SAAS,EAAE,mBAAmB,EAAE,CAAC;IACjC,oCAAoC;IACpC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,EAAE,yBAAyB;IACzF,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,UAAU,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC,CA4ClE"}
@@ -0,0 +1,89 @@
1
+ import * as path from 'node:path';
2
+ import { failure, is_success, success, } from '../core/index.js';
3
+ import { list_directories, load_template } from '../loader/index.js';
4
+ import { create_source_resolver } from './resolver.js';
5
+ /**
6
+ * Loads templates from all configured sources.
7
+ * Fetches from remote (or cache) and loads all template.yaml files found.
8
+ */
9
+ export async function load_templates_from_sources(sources, options) {
10
+ if (sources.length === 0) {
11
+ return success({ templates: [], resolved: [] });
12
+ }
13
+ // Fetch all sources
14
+ const resolver = create_source_resolver(options);
15
+ const fetch_result = await resolver.resolve_all(sources, options);
16
+ if (!fetch_result.success) {
17
+ return fetch_result;
18
+ }
19
+ // Load templates from each fetched source
20
+ const all_templates = [];
21
+ const errors = [];
22
+ for (const resolved of fetch_result.value) {
23
+ const templates_result = await load_templates_from_path(resolved.fetch_result.path);
24
+ if (is_success(templates_result)) {
25
+ // Add source name to each template
26
+ for (const loaded of templates_result.value) {
27
+ all_templates.push({
28
+ ...loaded,
29
+ source_name: resolved.source.name,
30
+ });
31
+ }
32
+ }
33
+ else {
34
+ errors.push(`${resolved.source.name}: ${templates_result.error.message}`);
35
+ }
36
+ }
37
+ if (errors.length > 0) {
38
+ return failure({
39
+ code: 'VALIDATION_ERROR',
40
+ message: `Failed to load templates from sources:\n${errors.join('\n')}`,
41
+ });
42
+ }
43
+ return success({
44
+ templates: all_templates,
45
+ resolved: fetch_result.value,
46
+ });
47
+ }
48
+ /**
49
+ * Loads all templates from a directory path.
50
+ * Looks for subdirectories containing template.yaml files.
51
+ */
52
+ async function load_templates_from_path(source_path) {
53
+ // List all subdirectories that might be templates
54
+ const dirs_result = await list_directories(source_path);
55
+ if (!is_success(dirs_result)) {
56
+ // Check if this path itself is a template
57
+ const direct_result = await load_template(source_path);
58
+ if (is_success(direct_result)) {
59
+ return success([direct_result.value]);
60
+ }
61
+ return failure({
62
+ code: 'NOT_FOUND',
63
+ message: `No templates found in ${source_path}`,
64
+ });
65
+ }
66
+ const templates = [];
67
+ const errors = [];
68
+ for (const dir of dirs_result.value) {
69
+ const result = await load_template(dir);
70
+ if (is_success(result)) {
71
+ templates.push(result.value);
72
+ }
73
+ else {
74
+ // Only log errors for directories that look like templates
75
+ // (i.e., they have a template.yaml that failed validation)
76
+ if (result.error.code === 'SCHEMA_VALIDATION_ERROR') {
77
+ errors.push(`${path.basename(dir)}: ${result.error.message}`);
78
+ }
79
+ }
80
+ }
81
+ if (templates.length === 0 && errors.length > 0) {
82
+ return failure({
83
+ code: 'VALIDATION_ERROR',
84
+ message: `Failed to load templates:\n${errors.join('\n')}`,
85
+ });
86
+ }
87
+ return success(templates);
88
+ }
89
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"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,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,2DAA2D;YAC3D,2DAA2D;YAC3D,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;gBACpD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,OAAO,CAAC;YACb,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,8BAA8B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { SourceResolverType } from './types.js';
2
+ /**
3
+ * Default cache directory relative to project root.
4
+ */
5
+ export declare const DEFAULT_CACHE_DIR = ".kustodian/templates-cache";
6
+ /**
7
+ * Options for creating a source resolver.
8
+ */
9
+ export interface CreateResolverOptionsType {
10
+ /** Base cache directory (defaults to .kustodian/templates-cache) */
11
+ cache_dir?: string;
12
+ }
13
+ /**
14
+ * Creates a source resolver instance.
15
+ */
16
+ export declare function create_source_resolver(options?: CreateResolverOptionsType): SourceResolverType;
17
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/sources/resolver.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAI9F"}
@@ -0,0 +1,125 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { failure, success } from '../core/index.js';
4
+ import { is_mutable_source } from '../schema/index.js';
5
+ import { create_cache_manager } from './cache/index.js';
6
+ import { get_fetcher_for_source } from './fetchers/index.js';
7
+ /**
8
+ * Default cache directory relative to project root.
9
+ */
10
+ export const DEFAULT_CACHE_DIR = '.kustodian/templates-cache';
11
+ /**
12
+ * Creates a source resolver instance.
13
+ */
14
+ export function create_source_resolver(options) {
15
+ const cache_dir = options?.cache_dir ?? path.join(process.cwd(), DEFAULT_CACHE_DIR);
16
+ const cache_manager = create_cache_manager(cache_dir);
17
+ return new SourceResolver(cache_manager);
18
+ }
19
+ class SourceResolver {
20
+ cache;
21
+ constructor(cache_manager) {
22
+ this.cache = cache_manager;
23
+ }
24
+ async resolve_all(sources, options) {
25
+ const parallel = options?.parallel ?? true;
26
+ if (parallel) {
27
+ const results = await Promise.all(sources.map((source) => this.resolve(source, options)));
28
+ // Check for first failure
29
+ const resolved = [];
30
+ for (const result of results) {
31
+ if (!result.success) {
32
+ return failure(result.error);
33
+ }
34
+ resolved.push(result.value);
35
+ }
36
+ return success(resolved);
37
+ }
38
+ // Sequential execution
39
+ const resolved = [];
40
+ for (const source of sources) {
41
+ const result = await this.resolve(source, options);
42
+ if (!result.success) {
43
+ return failure(result.error);
44
+ }
45
+ resolved.push(result.value);
46
+ }
47
+ return success(resolved);
48
+ }
49
+ async resolve(source, options) {
50
+ const force_refresh = options?.force_refresh ?? false;
51
+ const fetcher = get_fetcher_for_source(source);
52
+ const mutable = is_mutable_source(source);
53
+ // Determine the version to fetch
54
+ const version = this.get_source_version(source);
55
+ // Check cache first (unless force refresh)
56
+ if (!force_refresh) {
57
+ const cached = await this.cache.get(source.name, version);
58
+ if (cached.success && cached.value) {
59
+ return success({
60
+ source,
61
+ fetch_result: {
62
+ path: cached.value.path,
63
+ version: cached.value.version,
64
+ from_cache: true,
65
+ fetched_at: cached.value.fetched_at,
66
+ },
67
+ });
68
+ }
69
+ }
70
+ // Fetch from remote
71
+ const fetch_result = await fetcher.fetch(source, options);
72
+ if (!fetch_result.success) {
73
+ return fetch_result;
74
+ }
75
+ // Store in cache
76
+ const cache_result = await this.cache.put(source.name, fetcher.type, fetch_result.value.version, fetch_result.value.path, mutable, source.ttl);
77
+ if (!cache_result.success) {
78
+ // Log warning but don't fail - we have the content
79
+ console.warn(`Warning: Failed to cache source '${source.name}': ${cache_result.error.message}`);
80
+ }
81
+ // If caching succeeded, use the cached path (which is more stable)
82
+ const final_path = cache_result.success ? cache_result.value.path : fetch_result.value.path;
83
+ // Cleanup temp directory if we successfully cached
84
+ if (cache_result.success && fetch_result.value.path !== cache_result.value.path) {
85
+ await fs.rm(fetch_result.value.path, { recursive: true, force: true }).catch(() => { });
86
+ }
87
+ return success({
88
+ source,
89
+ fetch_result: {
90
+ path: final_path,
91
+ version: fetch_result.value.version,
92
+ from_cache: false,
93
+ fetched_at: fetch_result.value.fetched_at,
94
+ },
95
+ });
96
+ }
97
+ async update_all(sources) {
98
+ return this.resolve_all(sources, { force_refresh: true });
99
+ }
100
+ get_source_version(source) {
101
+ if (source.git) {
102
+ const ref = source.git.ref;
103
+ return ref.tag ?? ref.commit ?? ref.branch ?? 'unknown';
104
+ }
105
+ if (source.http) {
106
+ // Use checksum as version if available, otherwise use URL hash
107
+ return source.http.checksum ?? this.hash_url(source.http.url);
108
+ }
109
+ if (source.oci) {
110
+ return source.oci.digest ?? source.oci.tag ?? 'unknown';
111
+ }
112
+ return 'unknown';
113
+ }
114
+ hash_url(url) {
115
+ // Simple hash for URL-based versioning
116
+ let hash = 0;
117
+ for (let i = 0; i < url.length; i++) {
118
+ const char = url.charCodeAt(i);
119
+ hash = (hash << 5) - hash + char;
120
+ hash = hash & hash;
121
+ }
122
+ return `url-${Math.abs(hash).toString(16)}`;
123
+ }
124
+ }
125
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/sources/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAA4C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAyB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAU9D;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAmC;IACxE,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;IACpF,MAAM,aAAa,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACtD,OAAO,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,cAAc;IACD,KAAK,CAAmB;IAEzC,YAAY,aAA+B;QACzC,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAA6B,EAC7B,OAA6B;QAE7B,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,IAAI,CAAC;QAE3C,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,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,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,SAAS,CAAC;QAC1D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,QAAQ,CAAC,GAAW;QAC1B,uCAAuC;QACvC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;YACjC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,OAAO,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC9C,CAAC;CACF"}
@@ -0,0 +1,151 @@
1
+ import type { KustodianErrorType, ResultType } from '../core/index.js';
2
+ import type { TemplateSourceType } from '../schema/index.js';
3
+ /**
4
+ * Result of a successful fetch operation.
5
+ */
6
+ export interface FetchResultType {
7
+ /** Absolute path to the fetched/extracted templates directory */
8
+ path: string;
9
+ /** Version/ref that was fetched (tag, commit, digest, etc.) */
10
+ version: string;
11
+ /** Whether this result came from cache */
12
+ from_cache: boolean;
13
+ /** Timestamp when this was fetched */
14
+ fetched_at: Date;
15
+ }
16
+ /**
17
+ * Options for fetching sources.
18
+ */
19
+ export interface FetchOptionsType {
20
+ /** Force refresh, ignoring cache */
21
+ force_refresh?: boolean;
22
+ /** Target cache directory (defaults to .kustodian/templates-cache) */
23
+ cache_dir?: string;
24
+ /** Custom timeout in milliseconds */
25
+ timeout?: number;
26
+ }
27
+ /**
28
+ * Version information from a remote source.
29
+ */
30
+ export interface RemoteVersionType {
31
+ /** Version identifier (tag name, commit sha, etc.) */
32
+ version: string;
33
+ /** Content digest if available */
34
+ digest?: string;
35
+ /** Date of the version if available */
36
+ date?: Date;
37
+ }
38
+ /**
39
+ * Cache entry metadata.
40
+ */
41
+ export interface CacheEntryType {
42
+ /** Source name from configuration */
43
+ source_name: string;
44
+ /** Source type: git, http, or oci */
45
+ source_type: 'git' | 'http' | 'oci';
46
+ /** Version/ref that was cached */
47
+ version: string;
48
+ /** Absolute path to cached content */
49
+ path: string;
50
+ /** When this was fetched */
51
+ fetched_at: Date;
52
+ /** When this expires (only for mutable refs) */
53
+ expires_at: Date | null;
54
+ /** Content checksum if available */
55
+ checksum?: string;
56
+ }
57
+ /**
58
+ * Template source fetcher interface.
59
+ * Each source type (git, http, oci) implements this interface.
60
+ */
61
+ export interface SourceFetcherType {
62
+ /** Unique identifier for this fetcher type */
63
+ readonly type: 'git' | 'http' | 'oci';
64
+ /**
65
+ * Fetches templates from the source.
66
+ * Returns path to extracted templates directory.
67
+ */
68
+ fetch(source: TemplateSourceType, options?: FetchOptionsType): Promise<ResultType<FetchResultType, KustodianErrorType>>;
69
+ /**
70
+ * Lists available versions from the remote.
71
+ * For Git: tags and branches
72
+ * For OCI: tags
73
+ * For HTTP: not applicable (returns empty array)
74
+ */
75
+ list_versions(source: TemplateSourceType): Promise<ResultType<RemoteVersionType[], KustodianErrorType>>;
76
+ /**
77
+ * Determines if this source reference is mutable.
78
+ * Mutable refs (branches, 'latest' tag) need TTL-based refresh.
79
+ * Immutable refs (tags, commits, digests) can be cached forever.
80
+ */
81
+ is_mutable(source: TemplateSourceType): boolean;
82
+ }
83
+ /**
84
+ * Cache manager interface.
85
+ */
86
+ export interface CacheManagerType {
87
+ /** Base cache directory */
88
+ readonly cache_dir: string;
89
+ /**
90
+ * Gets a cached entry if valid (not expired for mutable refs).
91
+ */
92
+ get(source_name: string, version: string): Promise<ResultType<CacheEntryType | null, KustodianErrorType>>;
93
+ /**
94
+ * Stores content in cache.
95
+ */
96
+ put(source_name: string, source_type: 'git' | 'http' | 'oci', version: string, content_path: string, mutable: boolean, ttl?: string): Promise<ResultType<CacheEntryType, KustodianErrorType>>;
97
+ /**
98
+ * Invalidates a specific cache entry.
99
+ * If version is omitted, invalidates all versions for the source.
100
+ */
101
+ invalidate(source_name: string, version?: string): Promise<ResultType<void, KustodianErrorType>>;
102
+ /**
103
+ * Clears all expired entries (mutable refs past their TTL).
104
+ * Returns the number of entries removed.
105
+ */
106
+ prune(): Promise<ResultType<number, KustodianErrorType>>;
107
+ /**
108
+ * Lists all cache entries.
109
+ */
110
+ list(): Promise<ResultType<CacheEntryType[], KustodianErrorType>>;
111
+ /**
112
+ * Gets total cache size in bytes.
113
+ */
114
+ size(): Promise<ResultType<number, KustodianErrorType>>;
115
+ /**
116
+ * Clears all cached content.
117
+ */
118
+ clear(): Promise<ResultType<void, KustodianErrorType>>;
119
+ }
120
+ /**
121
+ * Resolved source with fetch result.
122
+ */
123
+ export interface ResolvedSourceType {
124
+ source: TemplateSourceType;
125
+ fetch_result: FetchResultType;
126
+ }
127
+ /**
128
+ * Source resolver options.
129
+ */
130
+ export interface ResolverOptionsType extends FetchOptionsType {
131
+ /** Run fetches in parallel (default: true) */
132
+ parallel?: boolean;
133
+ }
134
+ /**
135
+ * Source resolver interface - main entry point for fetching templates.
136
+ */
137
+ export interface SourceResolverType {
138
+ /**
139
+ * Resolves and fetches all template sources.
140
+ */
141
+ resolve_all(sources: TemplateSourceType[], options?: ResolverOptionsType): Promise<ResultType<ResolvedSourceType[], KustodianErrorType>>;
142
+ /**
143
+ * Resolves and fetches a single source.
144
+ */
145
+ resolve(source: TemplateSourceType, options?: FetchOptionsType): Promise<ResultType<ResolvedSourceType, KustodianErrorType>>;
146
+ /**
147
+ * Force updates all sources (ignores cache).
148
+ */
149
+ update_all(sources: TemplateSourceType[]): Promise<ResultType<ResolvedSourceType[], KustodianErrorType>>;
150
+ }
151
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sources/types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AAE,kBAAkB,CAAC,CAAC,CAAC;IAElE;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAExD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,CACT,OAAO,EAAE,kBAAkB,EAAE,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEjE;;OAEG;IACH,OAAO,CACL,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAE/D;;OAEG;IACH,UAAU,CACR,OAAO,EAAE,kBAAkB,EAAE,GAC5B,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAClE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sources/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "kustodian",
3
+ "version": "1.0.0",
4
+ "description": "A GitOps templating framework for Kubernetes with Flux CD",
5
+ "type": "module",
6
+ "packageManager": "bun@1.3.5",
7
+ "bin": {
8
+ "kustodian": "./dist/cli/bin.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/cli/index.d.ts",
13
+ "import": "./dist/cli/index.js"
14
+ },
15
+ "./core": {
16
+ "types": "./dist/core/index.d.ts",
17
+ "import": "./dist/core/index.js"
18
+ },
19
+ "./schema": {
20
+ "types": "./dist/schema/index.d.ts",
21
+ "import": "./dist/schema/index.js"
22
+ },
23
+ "./k8s": {
24
+ "types": "./dist/k8s/index.d.ts",
25
+ "import": "./dist/k8s/index.js"
26
+ },
27
+ "./loader": {
28
+ "types": "./dist/loader/index.d.ts",
29
+ "import": "./dist/loader/index.js"
30
+ },
31
+ "./nodes": {
32
+ "types": "./dist/nodes/index.d.ts",
33
+ "import": "./dist/nodes/index.js"
34
+ },
35
+ "./plugins": {
36
+ "types": "./dist/plugins/index.d.ts",
37
+ "import": "./dist/plugins/index.js"
38
+ },
39
+ "./generator": {
40
+ "types": "./dist/generator/index.d.ts",
41
+ "import": "./dist/generator/index.js"
42
+ },
43
+ "./registry": {
44
+ "types": "./dist/registry/index.d.ts",
45
+ "import": "./dist/registry/index.js"
46
+ },
47
+ "./sources": {
48
+ "types": "./dist/sources/index.d.ts",
49
+ "import": "./dist/sources/index.js"
50
+ }
51
+ },
52
+ "files": ["dist", "package.json"],
53
+ "workspaces": ["plugins/*"],
54
+ "scripts": {
55
+ "postinstall": "for d in plugins/*/; do mkdir -p \"$d/node_modules\" && rm -rf \"$d/node_modules/kustodian\" && ln -s ../../.. \"$d/node_modules/kustodian\"; done",
56
+ "build": "tsc && turbo run build --filter='./plugins/*'",
57
+ "test": "bun test src/ tests/ plugins/",
58
+ "test:coverage": "bun test src/ tests/ plugins/ --coverage --coverage-reporter=lcov --coverage-dir=coverage",
59
+ "test:e2e": "bun test e2e/",
60
+ "lint": "biome check .",
61
+ "lint:fix": "biome check --write .",
62
+ "fmt": "biome format --write .",
63
+ "typecheck": "tsc --noEmit",
64
+ "clean": "rm -rf dist .turbo coverage && turbo run clean --filter='./plugins/*'",
65
+ "generate-schemas": "bun run scripts/generate-json-schemas.ts"
66
+ },
67
+ "keywords": [
68
+ "kubernetes",
69
+ "gitops",
70
+ "flux",
71
+ "kustomize",
72
+ "templating",
73
+ "k0s",
74
+ "cluster-management"
75
+ ],
76
+ "author": "Luca Silverentand <luca@onezero.company>",
77
+ "license": "MIT",
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "https://github.com/lucasilverentand/kustodian.git"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public",
84
+ "registry": "https://registry.npmjs.org"
85
+ },
86
+ "dependencies": {
87
+ "ora": "^9.0.0",
88
+ "semver": "^7.6.0",
89
+ "yaml": "^2.8.2",
90
+ "zod": "^3.25.30"
91
+ },
92
+ "devDependencies": {
93
+ "@biomejs/biome": "^1.9.4",
94
+ "@types/bun": "^1.2.9",
95
+ "@types/semver": "^7.5.0",
96
+ "lefthook": "^2.0.15",
97
+ "turbo": "^2.7.5",
98
+ "typescript": "^5.8.3",
99
+ "zod-to-json-schema": "^3.25.1"
100
+ }
101
+ }