@reyemtech/nimbus 2.12.5 → 3.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 (276) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/backup/index.d.ts.map +1 -1
  3. package/dist/cjs/backup/index.js +6 -1
  4. package/dist/cjs/backup/index.js.map +1 -1
  5. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
  6. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  7. package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
  8. package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
  9. package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
  10. package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
  11. package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
  12. package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
  13. package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
  14. package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
  15. package/dist/cjs/cli/migrate-cnpg.js +258 -0
  16. package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
  17. package/dist/cjs/cli/migrate-exec.d.ts +45 -0
  18. package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
  19. package/dist/cjs/cli/migrate-exec.js +104 -0
  20. package/dist/cjs/cli/migrate-exec.js.map +1 -0
  21. package/dist/cjs/cli/migrate-psql.d.ts +125 -0
  22. package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
  23. package/dist/cjs/cli/migrate-psql.js +213 -0
  24. package/dist/cjs/cli/migrate-psql.js.map +1 -0
  25. package/dist/cjs/cli/migrate-report.d.ts +27 -0
  26. package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
  27. package/dist/cjs/cli/migrate-report.js +29 -0
  28. package/dist/cjs/cli/migrate-report.js.map +1 -0
  29. package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
  30. package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
  31. package/dist/cjs/cli/migrate-superuser.js +73 -0
  32. package/dist/cjs/cli/migrate-superuser.js.map +1 -0
  33. package/dist/cjs/cli/migrate.d.ts +37 -0
  34. package/dist/cjs/cli/migrate.d.ts.map +1 -0
  35. package/dist/cjs/cli/migrate.js +67 -0
  36. package/dist/cjs/cli/migrate.js.map +1 -0
  37. package/dist/cjs/cli.d.ts +1 -0
  38. package/dist/cjs/cli.d.ts.map +1 -1
  39. package/dist/cjs/cli.js +6 -0
  40. package/dist/cjs/cli.js.map +1 -1
  41. package/dist/cjs/index.d.ts +1 -1
  42. package/dist/cjs/index.d.ts.map +1 -1
  43. package/dist/cjs/index.js.map +1 -1
  44. package/dist/cjs/operator/cnpg-common.d.ts +56 -0
  45. package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
  46. package/dist/cjs/operator/cnpg-common.js +82 -0
  47. package/dist/cjs/operator/cnpg-common.js.map +1 -0
  48. package/dist/cjs/operator/cnpg-database.d.ts +66 -0
  49. package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
  50. package/dist/cjs/operator/cnpg-database.js +296 -0
  51. package/dist/cjs/operator/cnpg-database.js.map +1 -0
  52. package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
  53. package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
  54. package/dist/cjs/operator/cnpg-roles.js +225 -0
  55. package/dist/cjs/operator/cnpg-roles.js.map +1 -0
  56. package/dist/cjs/operator/cnpg.d.ts.map +1 -1
  57. package/dist/cjs/operator/cnpg.js +50 -162
  58. package/dist/cjs/operator/cnpg.js.map +1 -1
  59. package/dist/cjs/operator/connection-uri.d.ts +44 -0
  60. package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
  61. package/dist/cjs/operator/connection-uri.js +49 -0
  62. package/dist/cjs/operator/connection-uri.js.map +1 -0
  63. package/dist/cjs/operator/credentials.d.ts +76 -0
  64. package/dist/cjs/operator/credentials.d.ts.map +1 -0
  65. package/dist/cjs/operator/credentials.js +106 -0
  66. package/dist/cjs/operator/credentials.js.map +1 -0
  67. package/dist/cjs/operator/database-options.d.ts +121 -0
  68. package/dist/cjs/operator/database-options.d.ts.map +1 -0
  69. package/dist/cjs/operator/database-options.js +131 -0
  70. package/dist/cjs/operator/database-options.js.map +1 -0
  71. package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
  72. package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
  73. package/dist/cjs/operator/grants/postgres-job.js +232 -0
  74. package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
  75. package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
  76. package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
  77. package/dist/cjs/operator/grants/postgres-sql.js +305 -0
  78. package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
  79. package/dist/cjs/operator/grants/privileges.d.ts +24 -0
  80. package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
  81. package/dist/cjs/operator/grants/privileges.js +35 -0
  82. package/dist/cjs/operator/grants/privileges.js.map +1 -0
  83. package/dist/cjs/operator/grants/role-config.d.ts +80 -0
  84. package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
  85. package/dist/cjs/operator/grants/role-config.js +134 -0
  86. package/dist/cjs/operator/grants/role-config.js.map +1 -0
  87. package/dist/cjs/operator/index.d.ts +1 -1
  88. package/dist/cjs/operator/index.d.ts.map +1 -1
  89. package/dist/cjs/operator/index.js.map +1 -1
  90. package/dist/cjs/operator/interfaces.d.ts +223 -1
  91. package/dist/cjs/operator/interfaces.d.ts.map +1 -1
  92. package/dist/cjs/operator/interfaces.js.map +1 -1
  93. package/dist/cjs/operator/mariadb-common.d.ts +99 -0
  94. package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
  95. package/dist/cjs/operator/mariadb-common.js +141 -0
  96. package/dist/cjs/operator/mariadb-common.js.map +1 -0
  97. package/dist/cjs/operator/mariadb-database.d.ts +65 -0
  98. package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
  99. package/dist/cjs/operator/mariadb-database.js +285 -0
  100. package/dist/cjs/operator/mariadb-database.js.map +1 -0
  101. package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
  102. package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
  103. package/dist/cjs/operator/mariadb-roles.js +366 -0
  104. package/dist/cjs/operator/mariadb-roles.js.map +1 -0
  105. package/dist/cjs/operator/mariadb.d.ts.map +1 -1
  106. package/dist/cjs/operator/mariadb.js +35 -147
  107. package/dist/cjs/operator/mariadb.js.map +1 -1
  108. package/dist/cjs/operator/neo4j-common.d.ts +62 -0
  109. package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
  110. package/dist/cjs/operator/neo4j-common.js +89 -0
  111. package/dist/cjs/operator/neo4j-common.js.map +1 -0
  112. package/dist/cjs/operator/neo4j-database.d.ts +88 -0
  113. package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
  114. package/dist/cjs/operator/neo4j-database.js +274 -0
  115. package/dist/cjs/operator/neo4j-database.js.map +1 -0
  116. package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
  117. package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
  118. package/dist/cjs/operator/neo4j-roles.js +298 -0
  119. package/dist/cjs/operator/neo4j-roles.js.map +1 -0
  120. package/dist/cjs/operator/neo4j.d.ts.map +1 -1
  121. package/dist/cjs/operator/neo4j.js +32 -132
  122. package/dist/cjs/operator/neo4j.js.map +1 -1
  123. package/dist/cjs/operator/resource-identity.d.ts +170 -0
  124. package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
  125. package/dist/cjs/operator/resource-identity.js +231 -0
  126. package/dist/cjs/operator/resource-identity.js.map +1 -0
  127. package/dist/cjs/operator/role-registry.d.ts +85 -0
  128. package/dist/cjs/operator/role-registry.d.ts.map +1 -0
  129. package/dist/cjs/operator/role-registry.js +72 -0
  130. package/dist/cjs/operator/role-registry.js.map +1 -0
  131. package/dist/cjs/platform/components/image-pruner.d.ts +3 -1
  132. package/dist/cjs/platform/components/image-pruner.d.ts.map +1 -1
  133. package/dist/cjs/platform/components/image-pruner.js +38 -19
  134. package/dist/cjs/platform/components/image-pruner.js.map +1 -1
  135. package/dist/cjs/types/errors.d.ts +3 -0
  136. package/dist/cjs/types/errors.d.ts.map +1 -1
  137. package/dist/cjs/types/errors.js +3 -0
  138. package/dist/cjs/types/errors.js.map +1 -1
  139. package/dist/esm/backup/index.d.ts.map +1 -1
  140. package/dist/esm/backup/index.js +6 -1
  141. package/dist/esm/backup/index.js.map +1 -1
  142. package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
  143. package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  144. package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
  145. package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
  146. package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
  147. package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
  148. package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
  149. package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
  150. package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
  151. package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
  152. package/dist/esm/cli/migrate-cnpg.js +258 -0
  153. package/dist/esm/cli/migrate-cnpg.js.map +1 -0
  154. package/dist/esm/cli/migrate-exec.d.ts +45 -0
  155. package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
  156. package/dist/esm/cli/migrate-exec.js +104 -0
  157. package/dist/esm/cli/migrate-exec.js.map +1 -0
  158. package/dist/esm/cli/migrate-psql.d.ts +125 -0
  159. package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
  160. package/dist/esm/cli/migrate-psql.js +213 -0
  161. package/dist/esm/cli/migrate-psql.js.map +1 -0
  162. package/dist/esm/cli/migrate-report.d.ts +27 -0
  163. package/dist/esm/cli/migrate-report.d.ts.map +1 -0
  164. package/dist/esm/cli/migrate-report.js +29 -0
  165. package/dist/esm/cli/migrate-report.js.map +1 -0
  166. package/dist/esm/cli/migrate-superuser.d.ts +22 -0
  167. package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
  168. package/dist/esm/cli/migrate-superuser.js +73 -0
  169. package/dist/esm/cli/migrate-superuser.js.map +1 -0
  170. package/dist/esm/cli/migrate.d.ts +37 -0
  171. package/dist/esm/cli/migrate.d.ts.map +1 -0
  172. package/dist/esm/cli/migrate.js +67 -0
  173. package/dist/esm/cli/migrate.js.map +1 -0
  174. package/dist/esm/cli.d.ts +1 -0
  175. package/dist/esm/cli.d.ts.map +1 -1
  176. package/dist/esm/cli.js +6 -0
  177. package/dist/esm/cli.js.map +1 -1
  178. package/dist/esm/index.d.ts +1 -1
  179. package/dist/esm/index.d.ts.map +1 -1
  180. package/dist/esm/index.js.map +1 -1
  181. package/dist/esm/operator/cnpg-common.d.ts +56 -0
  182. package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
  183. package/dist/esm/operator/cnpg-common.js +82 -0
  184. package/dist/esm/operator/cnpg-common.js.map +1 -0
  185. package/dist/esm/operator/cnpg-database.d.ts +66 -0
  186. package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
  187. package/dist/esm/operator/cnpg-database.js +296 -0
  188. package/dist/esm/operator/cnpg-database.js.map +1 -0
  189. package/dist/esm/operator/cnpg-roles.d.ts +173 -0
  190. package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
  191. package/dist/esm/operator/cnpg-roles.js +225 -0
  192. package/dist/esm/operator/cnpg-roles.js.map +1 -0
  193. package/dist/esm/operator/cnpg.d.ts.map +1 -1
  194. package/dist/esm/operator/cnpg.js +50 -162
  195. package/dist/esm/operator/cnpg.js.map +1 -1
  196. package/dist/esm/operator/connection-uri.d.ts +44 -0
  197. package/dist/esm/operator/connection-uri.d.ts.map +1 -0
  198. package/dist/esm/operator/connection-uri.js +49 -0
  199. package/dist/esm/operator/connection-uri.js.map +1 -0
  200. package/dist/esm/operator/credentials.d.ts +76 -0
  201. package/dist/esm/operator/credentials.d.ts.map +1 -0
  202. package/dist/esm/operator/credentials.js +106 -0
  203. package/dist/esm/operator/credentials.js.map +1 -0
  204. package/dist/esm/operator/database-options.d.ts +121 -0
  205. package/dist/esm/operator/database-options.d.ts.map +1 -0
  206. package/dist/esm/operator/database-options.js +131 -0
  207. package/dist/esm/operator/database-options.js.map +1 -0
  208. package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
  209. package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
  210. package/dist/esm/operator/grants/postgres-job.js +232 -0
  211. package/dist/esm/operator/grants/postgres-job.js.map +1 -0
  212. package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
  213. package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
  214. package/dist/esm/operator/grants/postgres-sql.js +305 -0
  215. package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
  216. package/dist/esm/operator/grants/privileges.d.ts +24 -0
  217. package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
  218. package/dist/esm/operator/grants/privileges.js +35 -0
  219. package/dist/esm/operator/grants/privileges.js.map +1 -0
  220. package/dist/esm/operator/grants/role-config.d.ts +80 -0
  221. package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
  222. package/dist/esm/operator/grants/role-config.js +134 -0
  223. package/dist/esm/operator/grants/role-config.js.map +1 -0
  224. package/dist/esm/operator/index.d.ts +1 -1
  225. package/dist/esm/operator/index.d.ts.map +1 -1
  226. package/dist/esm/operator/index.js.map +1 -1
  227. package/dist/esm/operator/interfaces.d.ts +223 -1
  228. package/dist/esm/operator/interfaces.d.ts.map +1 -1
  229. package/dist/esm/operator/interfaces.js.map +1 -1
  230. package/dist/esm/operator/mariadb-common.d.ts +99 -0
  231. package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
  232. package/dist/esm/operator/mariadb-common.js +141 -0
  233. package/dist/esm/operator/mariadb-common.js.map +1 -0
  234. package/dist/esm/operator/mariadb-database.d.ts +65 -0
  235. package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
  236. package/dist/esm/operator/mariadb-database.js +285 -0
  237. package/dist/esm/operator/mariadb-database.js.map +1 -0
  238. package/dist/esm/operator/mariadb-roles.d.ts +264 -0
  239. package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
  240. package/dist/esm/operator/mariadb-roles.js +366 -0
  241. package/dist/esm/operator/mariadb-roles.js.map +1 -0
  242. package/dist/esm/operator/mariadb.d.ts.map +1 -1
  243. package/dist/esm/operator/mariadb.js +35 -147
  244. package/dist/esm/operator/mariadb.js.map +1 -1
  245. package/dist/esm/operator/neo4j-common.d.ts +62 -0
  246. package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
  247. package/dist/esm/operator/neo4j-common.js +89 -0
  248. package/dist/esm/operator/neo4j-common.js.map +1 -0
  249. package/dist/esm/operator/neo4j-database.d.ts +88 -0
  250. package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
  251. package/dist/esm/operator/neo4j-database.js +274 -0
  252. package/dist/esm/operator/neo4j-database.js.map +1 -0
  253. package/dist/esm/operator/neo4j-roles.d.ts +203 -0
  254. package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
  255. package/dist/esm/operator/neo4j-roles.js +298 -0
  256. package/dist/esm/operator/neo4j-roles.js.map +1 -0
  257. package/dist/esm/operator/neo4j.d.ts.map +1 -1
  258. package/dist/esm/operator/neo4j.js +32 -132
  259. package/dist/esm/operator/neo4j.js.map +1 -1
  260. package/dist/esm/operator/resource-identity.d.ts +170 -0
  261. package/dist/esm/operator/resource-identity.d.ts.map +1 -0
  262. package/dist/esm/operator/resource-identity.js +231 -0
  263. package/dist/esm/operator/resource-identity.js.map +1 -0
  264. package/dist/esm/operator/role-registry.d.ts +85 -0
  265. package/dist/esm/operator/role-registry.d.ts.map +1 -0
  266. package/dist/esm/operator/role-registry.js +72 -0
  267. package/dist/esm/operator/role-registry.js.map +1 -0
  268. package/dist/esm/platform/components/image-pruner.d.ts +3 -1
  269. package/dist/esm/platform/components/image-pruner.d.ts.map +1 -1
  270. package/dist/esm/platform/components/image-pruner.js +38 -19
  271. package/dist/esm/platform/components/image-pruner.js.map +1 -1
  272. package/dist/esm/types/errors.d.ts +3 -0
  273. package/dist/esm/types/errors.d.ts.map +1 -1
  274. package/dist/esm/types/errors.js +3 -0
  275. package/dist/esm/types/errors.js.map +1 -1
  276. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Percent-encoding for the connection URIs replicated into consuming namespaces.
4
+ *
5
+ * Every backend publishes a `uri` key alongside the separate `username`,
6
+ * `password` and `database` keys, and a URI is a *structured* string: `:`
7
+ * separates the user from the password, `@` separates the userinfo from the
8
+ * host, `/` starts the path, and `?` starts the query. Role names are
9
+ * caller-controlled and the role-name validator rejects only characters that
10
+ * would break out of a database identifier — backtick, quotes, backslash, NUL —
11
+ * so a perfectly legal name like `reporting@corp` or `reader:ro` reaches this
12
+ * layer intact.
13
+ *
14
+ * Interpolated raw, `reporting@corp` turns
15
+ * `postgresql://reporting@corp:pw@host:5432/db` into a URI that every conforming
16
+ * parser reads as user `reporting`, password `corp:pw@host:5432` — wrong
17
+ * credentials against a host that does not exist, from a Secret whose own
18
+ * `username` and `password` keys are perfectly correct. Encoding the components
19
+ * is what keeps the two agreeing.
20
+ *
21
+ * @module operator/connection-uri
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.encodeUriComponentValue = encodeUriComponentValue;
25
+ /**
26
+ * Percent-encode one component of a connection URI.
27
+ *
28
+ * Applied to the username, the password, and the database path segment — never
29
+ * to the host, port, or the URI's own delimiters. The plain `username` /
30
+ * `password` / `database` Secret keys stay raw: they are consumed as literal
31
+ * values, not parsed as a URI, so encoding them would corrupt them.
32
+ *
33
+ * Generated passwords are base64url today and so already URI-safe, but they are
34
+ * encoded anyway rather than resting on that: a future change to the password
35
+ * alphabet must not silently produce mis-parsing URIs.
36
+ *
37
+ * @param value - Raw component value, e.g. a role name or a password
38
+ * @returns The value with every URI-significant character percent-encoded
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * `postgresql://${encodeUriComponentValue("reader:ro")}@host:5432/db`;
43
+ * // → "postgresql://reader%3Aro@host:5432/db"
44
+ * ```
45
+ */
46
+ function encodeUriComponentValue(value) {
47
+ return encodeURIComponent(value);
48
+ }
49
+ //# sourceMappingURL=connection-uri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-uri.js","sourceRoot":"","sources":["../../../src/operator/connection-uri.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAuBH,0DAEC;AAvBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Shared credential handling for database roles across all operator backends.
3
+ *
4
+ * Every backend needs the same cycle: generate a password, store it in a Secret
5
+ * that Pulumi will not rewrite, read it back so the value is stable across
6
+ * deploys, and replicate a connection Secret into consuming namespaces.
7
+ *
8
+ * @module operator/credentials
9
+ */
10
+ import * as k8s from "@pulumi/kubernetes";
11
+ import * as pulumi from "@pulumi/pulumi";
12
+ /** Options for {@link createRoleCredentials}. */
13
+ export interface IRoleCredentialOptions {
14
+ /** Pulumi logical resource name for the Secret. */
15
+ readonly resourceName: string;
16
+ /** Kubernetes Secret name. */
17
+ readonly secretName: string;
18
+ /** Namespace to create the Secret in. */
19
+ readonly namespace: string;
20
+ /**
21
+ * Database username stored alongside the password. Omit to produce a
22
+ * password-only Secret (no `username` key in `stringData`) — MariaDB's
23
+ * primary credential Secret stores only `password` and relies on this.
24
+ */
25
+ readonly username?: string;
26
+ /** Labels applied to the Secret. */
27
+ readonly labels: Record<string, string>;
28
+ /** Kubernetes provider. */
29
+ readonly provider: k8s.Provider;
30
+ /** Resources the Secret must be created after. */
31
+ readonly dependsOn: ReadonlyArray<pulumi.Resource>;
32
+ /** Optional Secret type (e.g. "kubernetes.io/basic-auth"). */
33
+ readonly type?: string;
34
+ }
35
+ /** A stored credential plus a stable read-back of its password. */
36
+ export interface IRoleCredentials {
37
+ readonly userSecret: k8s.core.v1.Secret;
38
+ readonly stablePassword: pulumi.Output<string>;
39
+ readonly secretName: string;
40
+ }
41
+ /**
42
+ * Generate a password, store it, and read it back for stability across deploys.
43
+ *
44
+ * `ignoreChanges` on the stored Secret prevents Pulumi rewriting the password on
45
+ * every run; the read-back is what downstream Secrets consume so the value stays
46
+ * identical once created.
47
+ *
48
+ * @param options - Naming, labels, provider, and dependencies
49
+ * @returns The Secret resource and a stable Output of its password
50
+ */
51
+ export declare function createRoleCredentials(options: IRoleCredentialOptions): IRoleCredentials;
52
+ /** Options for {@link replicateConnectionSecrets}. */
53
+ export interface IReplicationOptions {
54
+ /** Namespaces to replicate into. */
55
+ readonly namespaces: ReadonlyArray<string>;
56
+ /** Pulumi logical resource name prefix. */
57
+ readonly resourcePrefix: string;
58
+ /** Kubernetes Secret name created in each namespace. */
59
+ readonly secretName: string;
60
+ /** Secret payload. */
61
+ readonly stringData: Record<string, pulumi.Input<string>>;
62
+ /** Labels applied to each Secret. */
63
+ readonly labels: Record<string, string>;
64
+ /** Kubernetes provider. */
65
+ readonly provider: k8s.Provider;
66
+ /** Resources each Secret must be created after. */
67
+ readonly dependsOn: ReadonlyArray<pulumi.Resource>;
68
+ }
69
+ /**
70
+ * Create a connection Secret in each target namespace.
71
+ *
72
+ * @param options - Namespaces, payload, labels, and dependencies
73
+ * @returns Map of namespace → created Secret name
74
+ */
75
+ export declare function replicateConnectionSecrets(options: IReplicationOptions): Record<string, pulumi.Output<string>>;
76
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/operator/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAKzC,iDAAiD;AACjD,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnD,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CAmCvF;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,2CAA2C;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sBAAsB;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC;IAChC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAuBvC"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ /**
3
+ * Shared credential handling for database roles across all operator backends.
4
+ *
5
+ * Every backend needs the same cycle: generate a password, store it in a Secret
6
+ * that Pulumi will not rewrite, read it back so the value is stable across
7
+ * deploys, and replicate a connection Secret into consuming namespaces.
8
+ *
9
+ * @module operator/credentials
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.createRoleCredentials = createRoleCredentials;
46
+ exports.replicateConnectionSecrets = replicateConnectionSecrets;
47
+ const crypto = __importStar(require("node:crypto"));
48
+ const k8s = __importStar(require("@pulumi/kubernetes"));
49
+ const pulumi = __importStar(require("@pulumi/pulumi"));
50
+ const ensure_namespace_js_1 = require("../utils/ensure-namespace.js");
51
+ const PASSWORD_BYTES = 24;
52
+ /**
53
+ * Generate a password, store it, and read it back for stability across deploys.
54
+ *
55
+ * `ignoreChanges` on the stored Secret prevents Pulumi rewriting the password on
56
+ * every run; the read-back is what downstream Secrets consume so the value stays
57
+ * identical once created.
58
+ *
59
+ * @param options - Naming, labels, provider, and dependencies
60
+ * @returns The Secret resource and a stable Output of its password
61
+ */
62
+ function createRoleCredentials(options) {
63
+ const generatedPassword = pulumi.secret(crypto.randomBytes(PASSWORD_BYTES).toString("base64url"));
64
+ const userSecret = new k8s.core.v1.Secret(options.resourceName, {
65
+ metadata: {
66
+ name: options.secretName,
67
+ namespace: options.namespace,
68
+ labels: options.labels,
69
+ },
70
+ ...(options.type ? { type: options.type } : {}),
71
+ stringData: {
72
+ ...(options.username ? { username: options.username } : {}),
73
+ password: generatedPassword,
74
+ },
75
+ }, {
76
+ provider: options.provider,
77
+ dependsOn: [...options.dependsOn],
78
+ ignoreChanges: ["data", "stringData"],
79
+ });
80
+ const storedSecret = k8s.core.v1.Secret.get(`${options.resourceName}-read`, pulumi.interpolate `${options.namespace}/${options.secretName}`, { provider: options.provider, dependsOn: [userSecret] });
81
+ const stablePassword = storedSecret.data.apply((d) => Buffer.from(d?.["password"] ?? "", "base64").toString());
82
+ return { userSecret, stablePassword, secretName: options.secretName };
83
+ }
84
+ /**
85
+ * Create a connection Secret in each target namespace.
86
+ *
87
+ * @param options - Namespaces, payload, labels, and dependencies
88
+ * @returns Map of namespace → created Secret name
89
+ */
90
+ function replicateConnectionSecrets(options) {
91
+ const secrets = {};
92
+ for (const targetNs of options.namespaces) {
93
+ const nsResource = (0, ensure_namespace_js_1.ensureNamespace)(targetNs, options.provider);
94
+ new k8s.core.v1.Secret(`${options.resourcePrefix}-${targetNs}`, {
95
+ metadata: {
96
+ name: options.secretName,
97
+ namespace: targetNs,
98
+ labels: options.labels,
99
+ },
100
+ stringData: options.stringData,
101
+ }, { provider: options.provider, dependsOn: [...options.dependsOn, nsResource] });
102
+ secrets[targetNs] = pulumi.output(options.secretName);
103
+ }
104
+ return secrets;
105
+ }
106
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/operator/credentials.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDH,sDAmCC;AA0BD,gEAyBC;AAtID,oDAAsC;AACtC,wDAA0C;AAC1C,uDAAyC;AACzC,sEAA+D;AAE/D,MAAM,cAAc,GAAG,EAAE,CAAC;AAiC1B;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAC,OAA+B;IACnE,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAElG,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CACvC,OAAO,CAAC,YAAY,EACpB;QACE,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO,CAAC,UAAU;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB;QACD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,UAAU,EAAE;YACV,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,QAAQ,EAAE,iBAAiB;SAC5B;KACF,EACD;QACE,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;QACjC,aAAa,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;KACtC,CACF,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CACzC,GAAG,OAAO,CAAC,YAAY,OAAO,EAC9B,MAAM,CAAC,WAAW,CAAA,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,EAC9D,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CACxD,CAAC;IAEF,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CACnD,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CACxD,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;AACxE,CAAC;AAoBD;;;;;GAKG;AACH,SAAgB,0BAA0B,CACxC,OAA4B;IAE5B,MAAM,OAAO,GAA0C,EAAE,CAAC;IAE1D,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,IAAA,qCAAe,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE/D,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CACpB,GAAG,OAAO,CAAC,cAAc,IAAI,QAAQ,EAAE,EACvC;YACE,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO,CAAC,UAAU;gBACxB,SAAS,EAAE,QAAQ;gBACnB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB;YACD,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,EACD,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,CAC9E,CAAC;QAEF,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Guards for {@link IOperatorDatabaseConfig} options an engine cannot honour.
3
+ *
4
+ * The rule this module exists to enforce is the one the rest of the operator
5
+ * module already follows for `owner`, `login: false`, `environments`, and
6
+ * `grants`: an option that cannot be honoured is refused at preview, never
7
+ * accepted and dropped. A silently ignored option is the worst outcome
8
+ * available — the config says one thing, the database does another, and
9
+ * nothing in the Pulumi diff explains the gap.
10
+ *
11
+ * That covers `engineOptions` too: a block addressed to one engine is refused
12
+ * by every other engine rather than ignored. See
13
+ * {@link assertNoForeignEngineOptions}.
14
+ *
15
+ * ## The one deliberate exception: `reclaimPolicy`
16
+ *
17
+ * `reclaimPolicy` is accepted on MariaDB and Neo4j and does nothing there. That
18
+ * is inconsistent with the rule above and is documented rather than fixed,
19
+ * because the rule cannot be applied to it:
20
+ *
21
+ * - **It is defaulted, so it is always "set".** `resolveRoleConfig` fills in
22
+ * `"retain"` when the caller omits it, so by the time any engine could check,
23
+ * there is no way to tell "the user asked for retain" from "the user said
24
+ * nothing". A guard would therefore have to reject every MariaDB and Neo4j
25
+ * database ever declared, including the ones already running. The guards this
26
+ * module does implement all cover options that are genuinely absent by
27
+ * default (`sql` is `undefined` unless asked for).
28
+ * - **Only CloudNativePG consumes it.** It becomes
29
+ * `Database.spec.databaseReclaimPolicy` and
30
+ * `DatabaseRole.spec.databaseRoleReclaimPolicy`. mariadb-operator's nearest
31
+ * equivalent is `spec.cleanupPolicy` on its `Database`/`User`/`Grant` CRs, and
32
+ * Neo4j is provisioned by a `cypher-shell` Job with no CR lifecycle at all.
33
+ * - **Adopting the MariaDB equivalent is not a documentation change.** Setting
34
+ * `cleanupPolicy` on the CRs of databases that already exist would change
35
+ * their deletion semantics on the next apply — a data-loss-shaped change made
36
+ * silently, which is worse than the gap it closes.
37
+ *
38
+ * So on MariaDB and Neo4j the lifecycle of a database, user, or grant is
39
+ * governed by the operator's own default (mariadb-operator retains its managed
40
+ * objects unless `cleanupPolicy` says otherwise; Neo4j has no such notion),
41
+ * not by this field. Nothing is deleted that would otherwise be kept — the
42
+ * exemption costs an unhonoured option, never data.
43
+ *
44
+ * @module operator/database-options
45
+ */
46
+ import type { IDatabaseRoleConfig, IOperatorDatabaseConfig } from "./interfaces.js";
47
+ /**
48
+ * Display names for the engines nimbus provisions databases on.
49
+ *
50
+ * Shared so that an error message naming one engine and a guard keyed on
51
+ * another cannot drift apart.
52
+ */
53
+ export declare const ENGINE_NAMES: {
54
+ /** CloudNativePG, the PostgreSQL operator. */
55
+ readonly CNPG: "CloudNativePG";
56
+ /** mariadb-operator. */
57
+ readonly MARIADB: "MariaDB";
58
+ /** Neo4j Community, provisioned by Helm and a `cypher-shell` Job. */
59
+ readonly NEO4J: "Neo4j";
60
+ };
61
+ /**
62
+ * Name of one `engineOptions` block.
63
+ *
64
+ * Derived from {@link IDatabaseRoleConfig} rather than restated, so adding a
65
+ * block to the public surface without teaching {@link ENGINE_OPTION_OWNERS} who
66
+ * honours it is a compile error rather than a silently unguarded option.
67
+ */
68
+ export type EngineOptionBlock = keyof NonNullable<IDatabaseRoleConfig["engineOptions"]>;
69
+ /** Inputs for {@link assertNoForeignEngineOptions}. */
70
+ export interface IForeignEngineOptionsCheck {
71
+ /** Role the configuration belongs to. */
72
+ readonly roleName: string;
73
+ /** Database the role is being added to. */
74
+ readonly databaseName: string;
75
+ /** Raw `engineOptions` from the role configuration, if any. */
76
+ readonly engineOptions?: IDatabaseRoleConfig["engineOptions"];
77
+ /**
78
+ * The block this engine reads, or omitted when it reads none.
79
+ *
80
+ * Neo4j honours no block at all: it has no operator, no CRs, and nothing in
81
+ * `postgresql` or `mariadb` maps onto `CREATE USER`.
82
+ */
83
+ readonly honoured?: EngineOptionBlock;
84
+ /** Engine name as it appears in the error message; see {@link ENGINE_NAMES}. */
85
+ readonly engine: string;
86
+ }
87
+ /**
88
+ * Reject an `engineOptions` block belonging to a different engine.
89
+ *
90
+ * `engineOptions` is one object carrying a block per engine, so nothing in the
91
+ * type system stops a CloudNativePG role from being handed
92
+ * `engineOptions.mariadb`. Such a role provisioned successfully with the
93
+ * requested host, connection cap, memberships or expiry simply absent — the
94
+ * exact silent-drop this module exists to prevent, and the more misleading for
95
+ * looking deliberate: the caller named an engine, and a *different* engine
96
+ * accepted it.
97
+ *
98
+ * Presence is what is checked, not content: an empty `{}` block still names an
99
+ * engine that will not run this role.
100
+ *
101
+ * @param check - Role, database, raw options, and which block this engine reads
102
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when a block for any
103
+ * other engine is present
104
+ */
105
+ export declare function assertNoForeignEngineOptions(check: IForeignEngineOptionsCheck): void;
106
+ /**
107
+ * Reject `config.sql` on an engine with no path for applying raw SQL.
108
+ *
109
+ * Only CloudNativePG has one: its grant-reconciliation Job already runs `psql`
110
+ * as the database owner, so `sql` rides along in that Job. MariaDB provisions
111
+ * everything through `Database`/`User`/`Grant` CRs and Neo4j through a
112
+ * `cypher-shell` Job that speaks Cypher — neither has anywhere to put a
113
+ * PostgreSQL-flavoured statement list, so the statements would simply never run.
114
+ *
115
+ * @param dbName - Database the configuration belongs to
116
+ * @param config - Raw per-database configuration
117
+ * @param engine - Engine name as it appears in the error message (e.g. "MariaDB")
118
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `sql` is set
119
+ */
120
+ export declare function assertNoSql(dbName: string, config: Pick<IOperatorDatabaseConfig, "sql">, engine: string): void;
121
+ //# sourceMappingURL=database-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-options.d.ts","sourceRoot":"","sources":["../../../src/operator/database-options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB,8CAA8C;;IAE9C,wBAAwB;;IAExB,qEAAqE;;CAE7D,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAAC;AAQxF,uDAAuD;AACvD,MAAM,WAAW,0BAA0B;IACzC,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IAC9D;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,0BAA0B,GAAG,IAAI,CAwBpF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAC5C,MAAM,EAAE,MAAM,GACb,IAAI,CAUN"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ /**
3
+ * Guards for {@link IOperatorDatabaseConfig} options an engine cannot honour.
4
+ *
5
+ * The rule this module exists to enforce is the one the rest of the operator
6
+ * module already follows for `owner`, `login: false`, `environments`, and
7
+ * `grants`: an option that cannot be honoured is refused at preview, never
8
+ * accepted and dropped. A silently ignored option is the worst outcome
9
+ * available — the config says one thing, the database does another, and
10
+ * nothing in the Pulumi diff explains the gap.
11
+ *
12
+ * That covers `engineOptions` too: a block addressed to one engine is refused
13
+ * by every other engine rather than ignored. See
14
+ * {@link assertNoForeignEngineOptions}.
15
+ *
16
+ * ## The one deliberate exception: `reclaimPolicy`
17
+ *
18
+ * `reclaimPolicy` is accepted on MariaDB and Neo4j and does nothing there. That
19
+ * is inconsistent with the rule above and is documented rather than fixed,
20
+ * because the rule cannot be applied to it:
21
+ *
22
+ * - **It is defaulted, so it is always "set".** `resolveRoleConfig` fills in
23
+ * `"retain"` when the caller omits it, so by the time any engine could check,
24
+ * there is no way to tell "the user asked for retain" from "the user said
25
+ * nothing". A guard would therefore have to reject every MariaDB and Neo4j
26
+ * database ever declared, including the ones already running. The guards this
27
+ * module does implement all cover options that are genuinely absent by
28
+ * default (`sql` is `undefined` unless asked for).
29
+ * - **Only CloudNativePG consumes it.** It becomes
30
+ * `Database.spec.databaseReclaimPolicy` and
31
+ * `DatabaseRole.spec.databaseRoleReclaimPolicy`. mariadb-operator's nearest
32
+ * equivalent is `spec.cleanupPolicy` on its `Database`/`User`/`Grant` CRs, and
33
+ * Neo4j is provisioned by a `cypher-shell` Job with no CR lifecycle at all.
34
+ * - **Adopting the MariaDB equivalent is not a documentation change.** Setting
35
+ * `cleanupPolicy` on the CRs of databases that already exist would change
36
+ * their deletion semantics on the next apply — a data-loss-shaped change made
37
+ * silently, which is worse than the gap it closes.
38
+ *
39
+ * So on MariaDB and Neo4j the lifecycle of a database, user, or grant is
40
+ * governed by the operator's own default (mariadb-operator retains its managed
41
+ * objects unless `cleanupPolicy` says otherwise; Neo4j has no such notion),
42
+ * not by this field. Nothing is deleted that would otherwise be kept — the
43
+ * exemption costs an unhonoured option, never data.
44
+ *
45
+ * @module operator/database-options
46
+ */
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.ENGINE_NAMES = void 0;
49
+ exports.assertNoForeignEngineOptions = assertNoForeignEngineOptions;
50
+ exports.assertNoSql = assertNoSql;
51
+ const errors_js_1 = require("../types/errors.js");
52
+ /**
53
+ * Display names for the engines nimbus provisions databases on.
54
+ *
55
+ * Shared so that an error message naming one engine and a guard keyed on
56
+ * another cannot drift apart.
57
+ */
58
+ exports.ENGINE_NAMES = {
59
+ /** CloudNativePG, the PostgreSQL operator. */
60
+ CNPG: "CloudNativePG",
61
+ /** mariadb-operator. */
62
+ MARIADB: "MariaDB",
63
+ /** Neo4j Community, provisioned by Helm and a `cypher-shell` Job. */
64
+ NEO4J: "Neo4j",
65
+ };
66
+ /** The one engine that honours each `engineOptions` block. */
67
+ const ENGINE_OPTION_OWNERS = {
68
+ postgresql: exports.ENGINE_NAMES.CNPG,
69
+ mariadb: exports.ENGINE_NAMES.MARIADB,
70
+ };
71
+ /**
72
+ * Reject an `engineOptions` block belonging to a different engine.
73
+ *
74
+ * `engineOptions` is one object carrying a block per engine, so nothing in the
75
+ * type system stops a CloudNativePG role from being handed
76
+ * `engineOptions.mariadb`. Such a role provisioned successfully with the
77
+ * requested host, connection cap, memberships or expiry simply absent — the
78
+ * exact silent-drop this module exists to prevent, and the more misleading for
79
+ * looking deliberate: the caller named an engine, and a *different* engine
80
+ * accepted it.
81
+ *
82
+ * Presence is what is checked, not content: an empty `{}` block still names an
83
+ * engine that will not run this role.
84
+ *
85
+ * @param check - Role, database, raw options, and which block this engine reads
86
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when a block for any
87
+ * other engine is present
88
+ */
89
+ function assertNoForeignEngineOptions(check) {
90
+ const { roleName, databaseName, engineOptions, honoured, engine } = check;
91
+ if (!engineOptions) {
92
+ return;
93
+ }
94
+ for (const block of Object.keys(ENGINE_OPTION_OWNERS)) {
95
+ if (block === honoured || engineOptions[block] === undefined) {
96
+ continue;
97
+ }
98
+ const owner = ENGINE_OPTION_OWNERS[block];
99
+ const alternative = honoured === undefined
100
+ ? `${engine} honours no engineOptions block at all`
101
+ : `on ${engine} only "engineOptions.${honoured}" is honoured`;
102
+ throw new errors_js_1.AnyCloudError(`Role "${roleName}" on database "${databaseName}" sets ` +
103
+ `"engineOptions.${block}", which only ${owner} honours — ${alternative}, so every ` +
104
+ `option in that block would be silently dropped and the role provisioned without ` +
105
+ `the behaviour the config asks for. Remove "engineOptions.${block}", or add this ` +
106
+ `role to a ${owner} database instead.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
107
+ }
108
+ }
109
+ /**
110
+ * Reject `config.sql` on an engine with no path for applying raw SQL.
111
+ *
112
+ * Only CloudNativePG has one: its grant-reconciliation Job already runs `psql`
113
+ * as the database owner, so `sql` rides along in that Job. MariaDB provisions
114
+ * everything through `Database`/`User`/`Grant` CRs and Neo4j through a
115
+ * `cypher-shell` Job that speaks Cypher — neither has anywhere to put a
116
+ * PostgreSQL-flavoured statement list, so the statements would simply never run.
117
+ *
118
+ * @param dbName - Database the configuration belongs to
119
+ * @param config - Raw per-database configuration
120
+ * @param engine - Engine name as it appears in the error message (e.g. "MariaDB")
121
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `sql` is set
122
+ */
123
+ function assertNoSql(dbName, config, engine) {
124
+ if (config.sql !== undefined) {
125
+ throw new errors_js_1.AnyCloudError(`Database "${dbName}" cannot use "sql" on ${engine} — raw SQL is applied only on ` +
126
+ `CloudNativePG, by the same owner-authenticated psql Job that reconciles grants. ` +
127
+ `${engine} has no equivalent path, so the statements would never run. Remove "sql" ` +
128
+ "and apply the statements from an application migration instead.", errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
129
+ }
130
+ }
131
+ //# sourceMappingURL=database-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-options.js","sourceRoot":"","sources":["../../../src/operator/database-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;;;AAwEH,oEAwBC;AAgBD,kCAcC;AA5HD,kDAAgE;AAGhE;;;;;GAKG;AACU,QAAA,YAAY,GAAG;IAC1B,8CAA8C;IAC9C,IAAI,EAAE,eAAe;IACrB,wBAAwB;IACxB,OAAO,EAAE,SAAS;IAClB,qEAAqE;IACrE,KAAK,EAAE,OAAO;CACN,CAAC;AAWX,8DAA8D;AAC9D,MAAM,oBAAoB,GAAgD;IACxE,UAAU,EAAE,oBAAY,CAAC,IAAI;IAC7B,OAAO,EAAE,oBAAY,CAAC,OAAO;CAC9B,CAAC;AAqBF;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,4BAA4B,CAAC,KAAiC;IAC5E,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC1E,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAwB,EAAE,CAAC;QAC7E,IAAI,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE,CAAC;YAC7D,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,WAAW,GACf,QAAQ,KAAK,SAAS;YACpB,CAAC,CAAC,GAAG,MAAM,wCAAwC;YACnD,CAAC,CAAC,MAAM,MAAM,wBAAwB,QAAQ,eAAe,CAAC;QAClE,MAAM,IAAI,yBAAa,CACrB,SAAS,QAAQ,kBAAkB,YAAY,SAAS;YACtD,kBAAkB,KAAK,iBAAiB,KAAK,cAAc,WAAW,aAAa;YACnF,kFAAkF;YAClF,4DAA4D,KAAK,iBAAiB;YAClF,aAAa,KAAK,oBAAoB,EACxC,uBAAW,CAAC,uBAAuB,CACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,WAAW,CACzB,MAAc,EACd,MAA4C,EAC5C,MAAc;IAEd,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,yBAAa,CACrB,aAAa,MAAM,yBAAyB,MAAM,gCAAgC;YAChF,kFAAkF;YAClF,GAAG,MAAM,2EAA2E;YACpF,iEAAiE,EACnE,uBAAW,CAAC,uBAAuB,CACpC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Applies compiled grant SQL to a CloudNativePG database.
3
+ *
4
+ * CNPG's `Database` and `DatabaseRole` CRDs create databases, roles, and
5
+ * ownership, but cannot express privilege grants — there is no CRD field for
6
+ * "GRANT SELECT ON ALL TABLES IN SCHEMA marts TO reader". This Job closes that
7
+ * gap: it runs `psql` against the cluster, authenticated as the database
8
+ * owner (never superuser), executing SQL compiled by
9
+ * {@link compileGrantSql}.
10
+ *
11
+ * The SQL reaches the container exclusively through a mounted ConfigMap, so
12
+ * no user-controlled value is ever interpolated into `command`. The Job's
13
+ * name embeds a checksum of the cluster, database, role, and compiled SQL, so
14
+ * an unchanged grant spec reuses the same Job (Pulumi diffs it as a no-op)
15
+ * and a changed spec — or the same grants applied to a different database —
16
+ * always produces a new, distinct Job.
17
+ *
18
+ * @module operator/grants/postgres-job
19
+ */
20
+ import * as k8s from "@pulumi/kubernetes";
21
+ import type * as pulumi from "@pulumi/pulumi";
22
+ import type { IDatabaseGrant } from "../interfaces.js";
23
+ /** Options for {@link createPostgresGrantJob}. */
24
+ export interface IGrantJobOptions {
25
+ /** CNPG cluster the database belongs to. */
26
+ readonly clusterName: string;
27
+ /** Database the grants apply to. */
28
+ readonly databaseName: string;
29
+ /** Role receiving the grants. */
30
+ readonly roleName: string;
31
+ /** Database owner; the Job authenticates as this role, never as superuser. */
32
+ readonly ownerName: string;
33
+ /** Secret holding the owner's existing credentials (must expose a `password` key). */
34
+ readonly ownerSecretName: string;
35
+ /**
36
+ * Desired grants, or `undefined` when privileges are not managed for this
37
+ * role.
38
+ *
39
+ * The two are not the same. `undefined` (with no `extraSql`) means there is
40
+ * nothing to apply and no Job is created. An **empty array** means the role
41
+ * should hold no privileges, which is a real reconciliation: the Job runs and
42
+ * {@link compileGrantSql}'s revoke preamble strips everything. Treating `[]`
43
+ * as "nothing to do" would make removing the last grant from a config a
44
+ * silent no-op, leaving the role holding privileges forever.
45
+ */
46
+ readonly grants?: ReadonlyArray<IDatabaseGrant>;
47
+ /** Raw SQL appended after the grants; see {@link compileGrantSql}'s `extraSql`. */
48
+ readonly extraSql?: ReadonlyArray<string>;
49
+ /** Namespace to create the Job and ConfigMap in. */
50
+ readonly namespace: string;
51
+ /** Cluster read-write endpoint the Job connects to. */
52
+ readonly endpoint: pulumi.Output<string>;
53
+ /** PostgreSQL major version, used to select the `psql` client image tag. */
54
+ readonly pgVersion: string;
55
+ /** Labels applied to the Job, its Pod template, and the SQL ConfigMap. */
56
+ readonly labels: Record<string, string>;
57
+ /** Kubernetes provider. */
58
+ readonly provider: k8s.Provider;
59
+ /**
60
+ * Resources the Job and ConfigMap must be created after.
61
+ *
62
+ * Include the previously created grant Job for the **same database** here:
63
+ * that is what serializes this database's grant transactions. See
64
+ * {@link createPostgresGrantJob}.
65
+ */
66
+ readonly dependsOn: pulumi.Resource[];
67
+ }
68
+ /**
69
+ * Create a Job that applies grants and extra SQL to a CNPG-managed database,
70
+ * or nothing at all when there is no SQL to run.
71
+ *
72
+ * The Job authenticates as `options.ownerName` using the password from
73
+ * `options.ownerSecretName`, and executes the compiled SQL with
74
+ * `psql -v ON_ERROR_STOP=1 -f <mounted file>` so a failing statement fails
75
+ * the Job instead of being silently skipped. The SQL itself is mounted from a
76
+ * ConfigMap — it never appears in `command`, so nothing derived from role,
77
+ * schema, or grant data is ever passed as a shell argument.
78
+ *
79
+ * The Job's name is derived from its content (cluster, database, role, and
80
+ * compiled SQL — see {@link deriveJobName}), so a Job that exhausts
81
+ * `backoffLimit` and permanently fails is **not** retried by a later
82
+ * `pulumi up` as long as the grant spec is unchanged: the same input still
83
+ * derives the same name, and Pulumi sees no diff against the existing
84
+ * (failed) Job. Recovering from a permanent failure requires deleting the
85
+ * failed Job manually (e.g. `kubectl delete job <name>`) before re-running
86
+ * Pulumi, so a new Job is created and actually runs.
87
+ *
88
+ * **Callers must serialize the Jobs they create for one database.** Every
89
+ * script revokes and re-grants across all of that database's schemas inside a
90
+ * single transaction, so two Jobs running concurrently against the same
91
+ * database contend for the same `pg_class`/`pg_namespace` rows and one can
92
+ * abort with `tuple concurrently updated`. Combined with the content-addressed
93
+ * name above, a transient collision that exhausts `backoffLimit` becomes a
94
+ * permanent, manually-recoverable failure. This function does not enforce the
95
+ * ordering itself — it has no view of the other Jobs — so the caller chains it,
96
+ * by passing the previously created Job for the same database in
97
+ * {@link IGrantJobOptions.dependsOn}. Jobs for *different* databases need no
98
+ * such chain: they are separate transactions on separate databases.
99
+ *
100
+ * @param options - Cluster, role, owner, grants, and dependencies
101
+ * @returns The Job, or `undefined` when privileges are unmanaged (`grants` is
102
+ * `undefined`) and there is no `extraSql`. An **empty** `grants` array still
103
+ * produces a Job — it means "this role should hold no privileges", and the
104
+ * compiled script revokes them.
105
+ * @throws {AnyCloudError} code `UNSUPPORTED_PRIVILEGE` when a grant lists a
106
+ * privilege {@link compileGrantSql} does not support
107
+ */
108
+ export declare function createPostgresGrantJob(options: IGrantJobOptions): k8s.batch.v1.Job | undefined;
109
+ //# sourceMappingURL=postgres-job.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-job.d.ts","sourceRoot":"","sources":["../../../../src/operator/grants/postgres-job.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAG9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgCvD,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sFAAsF;IACtF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;CACvC;AAqDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,SAAS,CAuE9F"}