@reyemtech/nimbus 2.12.6 → 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.
- package/README.md +2 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
- package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
- package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
- package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
- package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
- package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-cnpg.js +258 -0
- package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
- package/dist/cjs/cli/migrate-exec.d.ts +45 -0
- package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-exec.js +104 -0
- package/dist/cjs/cli/migrate-exec.js.map +1 -0
- package/dist/cjs/cli/migrate-psql.d.ts +125 -0
- package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-psql.js +213 -0
- package/dist/cjs/cli/migrate-psql.js.map +1 -0
- package/dist/cjs/cli/migrate-report.d.ts +27 -0
- package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-report.js +29 -0
- package/dist/cjs/cli/migrate-report.js.map +1 -0
- package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
- package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
- package/dist/cjs/cli/migrate-superuser.js +73 -0
- package/dist/cjs/cli/migrate-superuser.js.map +1 -0
- package/dist/cjs/cli/migrate.d.ts +37 -0
- package/dist/cjs/cli/migrate.d.ts.map +1 -0
- package/dist/cjs/cli/migrate.js +67 -0
- package/dist/cjs/cli/migrate.js.map +1 -0
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/cli.d.ts.map +1 -1
- package/dist/cjs/cli.js +6 -0
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/operator/cnpg-common.d.ts +56 -0
- package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-common.js +82 -0
- package/dist/cjs/operator/cnpg-common.js.map +1 -0
- package/dist/cjs/operator/cnpg-database.d.ts +66 -0
- package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-database.js +296 -0
- package/dist/cjs/operator/cnpg-database.js.map +1 -0
- package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
- package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
- package/dist/cjs/operator/cnpg-roles.js +225 -0
- package/dist/cjs/operator/cnpg-roles.js.map +1 -0
- package/dist/cjs/operator/cnpg.d.ts.map +1 -1
- package/dist/cjs/operator/cnpg.js +50 -162
- package/dist/cjs/operator/cnpg.js.map +1 -1
- package/dist/cjs/operator/connection-uri.d.ts +44 -0
- package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
- package/dist/cjs/operator/connection-uri.js +49 -0
- package/dist/cjs/operator/connection-uri.js.map +1 -0
- package/dist/cjs/operator/credentials.d.ts +76 -0
- package/dist/cjs/operator/credentials.d.ts.map +1 -0
- package/dist/cjs/operator/credentials.js +106 -0
- package/dist/cjs/operator/credentials.js.map +1 -0
- package/dist/cjs/operator/database-options.d.ts +121 -0
- package/dist/cjs/operator/database-options.d.ts.map +1 -0
- package/dist/cjs/operator/database-options.js +131 -0
- package/dist/cjs/operator/database-options.js.map +1 -0
- package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
- package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
- package/dist/cjs/operator/grants/postgres-job.js +232 -0
- package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
- package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
- package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
- package/dist/cjs/operator/grants/postgres-sql.js +305 -0
- package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
- package/dist/cjs/operator/grants/privileges.d.ts +24 -0
- package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
- package/dist/cjs/operator/grants/privileges.js +35 -0
- package/dist/cjs/operator/grants/privileges.js.map +1 -0
- package/dist/cjs/operator/grants/role-config.d.ts +80 -0
- package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
- package/dist/cjs/operator/grants/role-config.js +134 -0
- package/dist/cjs/operator/grants/role-config.js.map +1 -0
- package/dist/cjs/operator/index.d.ts +1 -1
- package/dist/cjs/operator/index.d.ts.map +1 -1
- package/dist/cjs/operator/index.js.map +1 -1
- package/dist/cjs/operator/interfaces.d.ts +223 -1
- package/dist/cjs/operator/interfaces.d.ts.map +1 -1
- package/dist/cjs/operator/interfaces.js.map +1 -1
- package/dist/cjs/operator/mariadb-common.d.ts +99 -0
- package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-common.js +141 -0
- package/dist/cjs/operator/mariadb-common.js.map +1 -0
- package/dist/cjs/operator/mariadb-database.d.ts +65 -0
- package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-database.js +285 -0
- package/dist/cjs/operator/mariadb-database.js.map +1 -0
- package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
- package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
- package/dist/cjs/operator/mariadb-roles.js +366 -0
- package/dist/cjs/operator/mariadb-roles.js.map +1 -0
- package/dist/cjs/operator/mariadb.d.ts.map +1 -1
- package/dist/cjs/operator/mariadb.js +35 -147
- package/dist/cjs/operator/mariadb.js.map +1 -1
- package/dist/cjs/operator/neo4j-common.d.ts +62 -0
- package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-common.js +89 -0
- package/dist/cjs/operator/neo4j-common.js.map +1 -0
- package/dist/cjs/operator/neo4j-database.d.ts +88 -0
- package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-database.js +274 -0
- package/dist/cjs/operator/neo4j-database.js.map +1 -0
- package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
- package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
- package/dist/cjs/operator/neo4j-roles.js +298 -0
- package/dist/cjs/operator/neo4j-roles.js.map +1 -0
- package/dist/cjs/operator/neo4j.d.ts.map +1 -1
- package/dist/cjs/operator/neo4j.js +32 -132
- package/dist/cjs/operator/neo4j.js.map +1 -1
- package/dist/cjs/operator/resource-identity.d.ts +170 -0
- package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
- package/dist/cjs/operator/resource-identity.js +231 -0
- package/dist/cjs/operator/resource-identity.js.map +1 -0
- package/dist/cjs/operator/role-registry.d.ts +85 -0
- package/dist/cjs/operator/role-registry.d.ts.map +1 -0
- package/dist/cjs/operator/role-registry.js +72 -0
- package/dist/cjs/operator/role-registry.js.map +1 -0
- package/dist/cjs/types/errors.d.ts +3 -0
- package/dist/cjs/types/errors.d.ts.map +1 -1
- package/dist/cjs/types/errors.js +3 -0
- package/dist/cjs/types/errors.js.map +1 -1
- package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
- package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
- package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
- package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
- package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
- package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
- package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
- package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
- package/dist/esm/cli/migrate-cnpg.js +258 -0
- package/dist/esm/cli/migrate-cnpg.js.map +1 -0
- package/dist/esm/cli/migrate-exec.d.ts +45 -0
- package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
- package/dist/esm/cli/migrate-exec.js +104 -0
- package/dist/esm/cli/migrate-exec.js.map +1 -0
- package/dist/esm/cli/migrate-psql.d.ts +125 -0
- package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
- package/dist/esm/cli/migrate-psql.js +213 -0
- package/dist/esm/cli/migrate-psql.js.map +1 -0
- package/dist/esm/cli/migrate-report.d.ts +27 -0
- package/dist/esm/cli/migrate-report.d.ts.map +1 -0
- package/dist/esm/cli/migrate-report.js +29 -0
- package/dist/esm/cli/migrate-report.js.map +1 -0
- package/dist/esm/cli/migrate-superuser.d.ts +22 -0
- package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
- package/dist/esm/cli/migrate-superuser.js +73 -0
- package/dist/esm/cli/migrate-superuser.js.map +1 -0
- package/dist/esm/cli/migrate.d.ts +37 -0
- package/dist/esm/cli/migrate.d.ts.map +1 -0
- package/dist/esm/cli/migrate.js +67 -0
- package/dist/esm/cli/migrate.js.map +1 -0
- package/dist/esm/cli.d.ts +1 -0
- package/dist/esm/cli.d.ts.map +1 -1
- package/dist/esm/cli.js +6 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operator/cnpg-common.d.ts +56 -0
- package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-common.js +82 -0
- package/dist/esm/operator/cnpg-common.js.map +1 -0
- package/dist/esm/operator/cnpg-database.d.ts +66 -0
- package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-database.js +296 -0
- package/dist/esm/operator/cnpg-database.js.map +1 -0
- package/dist/esm/operator/cnpg-roles.d.ts +173 -0
- package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
- package/dist/esm/operator/cnpg-roles.js +225 -0
- package/dist/esm/operator/cnpg-roles.js.map +1 -0
- package/dist/esm/operator/cnpg.d.ts.map +1 -1
- package/dist/esm/operator/cnpg.js +50 -162
- package/dist/esm/operator/cnpg.js.map +1 -1
- package/dist/esm/operator/connection-uri.d.ts +44 -0
- package/dist/esm/operator/connection-uri.d.ts.map +1 -0
- package/dist/esm/operator/connection-uri.js +49 -0
- package/dist/esm/operator/connection-uri.js.map +1 -0
- package/dist/esm/operator/credentials.d.ts +76 -0
- package/dist/esm/operator/credentials.d.ts.map +1 -0
- package/dist/esm/operator/credentials.js +106 -0
- package/dist/esm/operator/credentials.js.map +1 -0
- package/dist/esm/operator/database-options.d.ts +121 -0
- package/dist/esm/operator/database-options.d.ts.map +1 -0
- package/dist/esm/operator/database-options.js +131 -0
- package/dist/esm/operator/database-options.js.map +1 -0
- package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
- package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
- package/dist/esm/operator/grants/postgres-job.js +232 -0
- package/dist/esm/operator/grants/postgres-job.js.map +1 -0
- package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
- package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
- package/dist/esm/operator/grants/postgres-sql.js +305 -0
- package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
- package/dist/esm/operator/grants/privileges.d.ts +24 -0
- package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
- package/dist/esm/operator/grants/privileges.js +35 -0
- package/dist/esm/operator/grants/privileges.js.map +1 -0
- package/dist/esm/operator/grants/role-config.d.ts +80 -0
- package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
- package/dist/esm/operator/grants/role-config.js +134 -0
- package/dist/esm/operator/grants/role-config.js.map +1 -0
- package/dist/esm/operator/index.d.ts +1 -1
- package/dist/esm/operator/index.d.ts.map +1 -1
- package/dist/esm/operator/index.js.map +1 -1
- package/dist/esm/operator/interfaces.d.ts +223 -1
- package/dist/esm/operator/interfaces.d.ts.map +1 -1
- package/dist/esm/operator/interfaces.js.map +1 -1
- package/dist/esm/operator/mariadb-common.d.ts +99 -0
- package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-common.js +141 -0
- package/dist/esm/operator/mariadb-common.js.map +1 -0
- package/dist/esm/operator/mariadb-database.d.ts +65 -0
- package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-database.js +285 -0
- package/dist/esm/operator/mariadb-database.js.map +1 -0
- package/dist/esm/operator/mariadb-roles.d.ts +264 -0
- package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
- package/dist/esm/operator/mariadb-roles.js +366 -0
- package/dist/esm/operator/mariadb-roles.js.map +1 -0
- package/dist/esm/operator/mariadb.d.ts.map +1 -1
- package/dist/esm/operator/mariadb.js +35 -147
- package/dist/esm/operator/mariadb.js.map +1 -1
- package/dist/esm/operator/neo4j-common.d.ts +62 -0
- package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-common.js +89 -0
- package/dist/esm/operator/neo4j-common.js.map +1 -0
- package/dist/esm/operator/neo4j-database.d.ts +88 -0
- package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-database.js +274 -0
- package/dist/esm/operator/neo4j-database.js.map +1 -0
- package/dist/esm/operator/neo4j-roles.d.ts +203 -0
- package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
- package/dist/esm/operator/neo4j-roles.js +298 -0
- package/dist/esm/operator/neo4j-roles.js.map +1 -0
- package/dist/esm/operator/neo4j.d.ts.map +1 -1
- package/dist/esm/operator/neo4j.js +32 -132
- package/dist/esm/operator/neo4j.js.map +1 -1
- package/dist/esm/operator/resource-identity.d.ts +170 -0
- package/dist/esm/operator/resource-identity.d.ts.map +1 -0
- package/dist/esm/operator/resource-identity.js +231 -0
- package/dist/esm/operator/resource-identity.js.map +1 -0
- package/dist/esm/operator/role-registry.d.ts +85 -0
- package/dist/esm/operator/role-registry.d.ts.map +1 -0
- package/dist/esm/operator/role-registry.js +72 -0
- package/dist/esm/operator/role-registry.js.map +1 -0
- package/dist/esm/types/errors.d.ts +3 -0
- package/dist/esm/types/errors.d.ts.map +1 -1
- package/dist/esm/types/errors.js +3 -0
- package/dist/esm/types/errors.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database ownership parsing for the `nimbus migrate` CNPG check.
|
|
3
|
+
*
|
|
4
|
+
* `Database` adoption issues `ALTER DATABASE … OWNER TO` unconditionally, so
|
|
5
|
+
* that statement is only a no-op when the database's current owner already
|
|
6
|
+
* matches what nimbus assigns. This module parses the database ownership
|
|
7
|
+
* query from `docs/cnpg-declarative-databases.md` (reused verbatim, see
|
|
8
|
+
* {@link DATABASE_OWNERSHIP_QUERY}).
|
|
9
|
+
*
|
|
10
|
+
* The query is run through {@link toJsonRowsQuery} for the reason spelt out in
|
|
11
|
+
* {@link module:cli/migrate-psql}: `psql -tAc` escapes nothing, so a database or
|
|
12
|
+
* owner name containing a `|` split into three fields where two were expected
|
|
13
|
+
* and the row was silently dropped — from the check whose job is to notice that
|
|
14
|
+
* exact database. Rows that still cannot be read come back as warnings.
|
|
15
|
+
*
|
|
16
|
+
* @module cli/migrate-cnpg-ownership
|
|
17
|
+
*/
|
|
18
|
+
/** Databases that are not created by `createDatabase()` and have no owner convention to check. */
|
|
19
|
+
export declare const SYSTEM_DATABASE_NAMES: readonly string[];
|
|
20
|
+
/** Database ownership query from `docs/cnpg-declarative-databases.md`. */
|
|
21
|
+
export declare const DATABASE_OWNERSHIP_QUERY = "SELECT d.datname, pg_get_userbyid(d.datdba) AS owner\nFROM pg_database d WHERE NOT d.datistemplate ORDER BY 1";
|
|
22
|
+
/** {@link DATABASE_OWNERSHIP_QUERY} as the JSON document {@link parseDatabaseRows} reads. */
|
|
23
|
+
export declare const DATABASE_OWNERSHIP_JSON_QUERY: string;
|
|
24
|
+
/** One row of {@link DATABASE_OWNERSHIP_QUERY}, parsed and typed. */
|
|
25
|
+
export interface IParsedDatabaseRow {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly owner: string;
|
|
28
|
+
}
|
|
29
|
+
/** Parsed databases, plus a warning for every row that could not be read. */
|
|
30
|
+
export interface IDatabaseRowsResult {
|
|
31
|
+
/** Rows that parsed cleanly. */
|
|
32
|
+
readonly databases: ReadonlyArray<IParsedDatabaseRow>;
|
|
33
|
+
/** One line per unreadable row; never empty when a row was skipped. */
|
|
34
|
+
readonly warnings: ReadonlyArray<string>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse every row returned by {@link DATABASE_OWNERSHIP_JSON_QUERY}.
|
|
38
|
+
*
|
|
39
|
+
* @param stdout - Raw `psql -tAc` output of the JSON-wrapped query
|
|
40
|
+
* @returns The databases that parsed, and a warning for every row that did not
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseDatabaseRows(stdout: string): IDatabaseRowsResult;
|
|
43
|
+
//# sourceMappingURL=migrate-cnpg-ownership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-cnpg-ownership.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-cnpg-ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,kGAAkG;AAClG,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAiB,CAAC;AAErE,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,kHACmB,CAAC;AAEzD,6FAA6F;AAC7F,eAAO,MAAM,6BAA6B,QAA4C,CAAC;AAWvF,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACtD,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CA2BrE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database ownership parsing for the `nimbus migrate` CNPG check.
|
|
4
|
+
*
|
|
5
|
+
* `Database` adoption issues `ALTER DATABASE … OWNER TO` unconditionally, so
|
|
6
|
+
* that statement is only a no-op when the database's current owner already
|
|
7
|
+
* matches what nimbus assigns. This module parses the database ownership
|
|
8
|
+
* query from `docs/cnpg-declarative-databases.md` (reused verbatim, see
|
|
9
|
+
* {@link DATABASE_OWNERSHIP_QUERY}).
|
|
10
|
+
*
|
|
11
|
+
* The query is run through {@link toJsonRowsQuery} for the reason spelt out in
|
|
12
|
+
* {@link module:cli/migrate-psql}: `psql -tAc` escapes nothing, so a database or
|
|
13
|
+
* owner name containing a `|` split into three fields where two were expected
|
|
14
|
+
* and the row was silently dropped — from the check whose job is to notice that
|
|
15
|
+
* exact database. Rows that still cannot be read come back as warnings.
|
|
16
|
+
*
|
|
17
|
+
* @module cli/migrate-cnpg-ownership
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.DATABASE_OWNERSHIP_JSON_QUERY = exports.DATABASE_OWNERSHIP_QUERY = exports.SYSTEM_DATABASE_NAMES = void 0;
|
|
21
|
+
exports.parseDatabaseRows = parseDatabaseRows;
|
|
22
|
+
const migrate_psql_js_1 = require("./migrate-psql.js");
|
|
23
|
+
/** Databases that are not created by `createDatabase()` and have no owner convention to check. */
|
|
24
|
+
exports.SYSTEM_DATABASE_NAMES = ["postgres"];
|
|
25
|
+
/** Database ownership query from `docs/cnpg-declarative-databases.md`. */
|
|
26
|
+
exports.DATABASE_OWNERSHIP_QUERY = `SELECT d.datname, pg_get_userbyid(d.datdba) AS owner
|
|
27
|
+
FROM pg_database d WHERE NOT d.datistemplate ORDER BY 1`;
|
|
28
|
+
/** {@link DATABASE_OWNERSHIP_QUERY} as the JSON document {@link parseDatabaseRows} reads. */
|
|
29
|
+
exports.DATABASE_OWNERSHIP_JSON_QUERY = (0, migrate_psql_js_1.toJsonRowsQuery)(exports.DATABASE_OWNERSHIP_QUERY);
|
|
30
|
+
/** What this query reads, named in warnings. */
|
|
31
|
+
const SUBJECT = "pg_database";
|
|
32
|
+
/** Columns {@link DATABASE_OWNERSHIP_QUERY} returns, by the name `row_to_json` gives them. */
|
|
33
|
+
const DATABASE_COLUMNS = {
|
|
34
|
+
NAME: "datname",
|
|
35
|
+
OWNER: "owner",
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Parse every row returned by {@link DATABASE_OWNERSHIP_JSON_QUERY}.
|
|
39
|
+
*
|
|
40
|
+
* @param stdout - Raw `psql -tAc` output of the JSON-wrapped query
|
|
41
|
+
* @returns The databases that parsed, and a warning for every row that did not
|
|
42
|
+
*/
|
|
43
|
+
function parseDatabaseRows(stdout) {
|
|
44
|
+
const parsed = (0, migrate_psql_js_1.parseJsonRows)(stdout, SUBJECT);
|
|
45
|
+
const databases = [];
|
|
46
|
+
const warnings = [...parsed.warnings];
|
|
47
|
+
parsed.rows.forEach((row, index) => {
|
|
48
|
+
const name = (0, migrate_psql_js_1.readString)(row, DATABASE_COLUMNS.NAME);
|
|
49
|
+
const owner = (0, migrate_psql_js_1.readString)(row, DATABASE_COLUMNS.OWNER);
|
|
50
|
+
if (name === undefined || owner === undefined) {
|
|
51
|
+
const columns = [
|
|
52
|
+
[DATABASE_COLUMNS.NAME, name],
|
|
53
|
+
[DATABASE_COLUMNS.OWNER, owner],
|
|
54
|
+
]
|
|
55
|
+
.filter(([, value]) => value === undefined)
|
|
56
|
+
.map(([column]) => column)
|
|
57
|
+
.join(", ");
|
|
58
|
+
const where = name === undefined ? `${SUBJECT} row ${index + 1}` : `database "${name}"`;
|
|
59
|
+
warnings.push(`${where}: could not read ${columns} from the ${SUBJECT} query output, so this ` +
|
|
60
|
+
"database's ownership was NOT checked.");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
databases.push({ name, owner });
|
|
64
|
+
});
|
|
65
|
+
return { databases, warnings };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=migrate-cnpg-ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-cnpg-ownership.js","sourceRoot":"","sources":["../../../src/cli/migrate-cnpg-ownership.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AA2CH,8CA2BC;AApED,uDAA+E;AAE/E,kGAAkG;AACrF,QAAA,qBAAqB,GAAsB,CAAC,UAAU,CAAC,CAAC;AAErE,0EAA0E;AAC7D,QAAA,wBAAwB,GAAG;wDACgB,CAAC;AAEzD,6FAA6F;AAChF,QAAA,6BAA6B,GAAG,IAAA,iCAAe,EAAC,gCAAwB,CAAC,CAAC;AAEvF,gDAAgD;AAChD,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,8FAA8F;AAC9F,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,OAAO;CACN,CAAC;AAgBX;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,MAAM,MAAM,GAAG,IAAA,+BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ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
|
|
3
|
+
*
|
|
4
|
+
* `DatabaseRole` adoption ALTERs an existing role to match the manifest,
|
|
5
|
+
* forcing attributes the manifest omits back to their defaults. nimbus's
|
|
6
|
+
* manifest sets only `login: true`, so every other attribute must already sit
|
|
7
|
+
* at the PostgreSQL default for adoption to be a no-op. This module parses the
|
|
8
|
+
* `pg_roles` query from `docs/cnpg-declarative-databases.md` (reused verbatim,
|
|
9
|
+
* see {@link ROLE_ATTRIBUTES_QUERY}) and flags rows that deviate.
|
|
10
|
+
*
|
|
11
|
+
* The baseline covers every attribute `DatabaseRole.spec` can express, not the
|
|
12
|
+
* subset that is easy to query. Checking fewer is the same false all-clear as
|
|
13
|
+
* skipping a row: `replication`, `validUntil` and `comment` were missing, so a
|
|
14
|
+
* role carrying `REPLICATION` or a finite `VALID UNTIL` was reported as sitting
|
|
15
|
+
* on the baseline and then had exactly that stripped on the first reconcile.
|
|
16
|
+
* Every field of the CRD's `spec` that maps onto a role attribute is read here;
|
|
17
|
+
* the ones that do not (`cluster`, `name`, `ensure`, `databaseRoleReclaimPolicy`,
|
|
18
|
+
* `clientCertificate`) name or govern the CR rather than the role, and
|
|
19
|
+
* `passwordSecret` carries the password migration re-applies deliberately.
|
|
20
|
+
*
|
|
21
|
+
* The query is run through {@link toJsonRowsQuery} rather than read as `psql`'s
|
|
22
|
+
* pipe-delimited output: a role name may contain a `|`, and psql escapes
|
|
23
|
+
* nothing, so such a row parsed as ten fields instead of nine and was discarded.
|
|
24
|
+
* The check then reported that every role matched the baseline while having
|
|
25
|
+
* skipped precisely the role whose attributes adoption would reset. Nothing is
|
|
26
|
+
* dropped now — a row that still cannot be read is returned as a warning.
|
|
27
|
+
*
|
|
28
|
+
* @module cli/migrate-cnpg-roles
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Operator-managed roles that intentionally do not follow the nimbus baseline
|
|
32
|
+
* (e.g. `postgres` is a superuser by definition). Excluded from role deviation
|
|
33
|
+
* reporting so the check only flags roles nimbus actually provisions.
|
|
34
|
+
*/
|
|
35
|
+
export declare const BUILTIN_ROLE_NAMES: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* `pg_roles` query from `docs/cnpg-declarative-databases.md`, reused verbatim so this
|
|
38
|
+
* check and the documented manual procedure never drift apart.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ROLE_ATTRIBUTES_QUERY = "SELECT r.rolname, r.rolcanlogin, r.rolsuper, r.rolcreatedb, r.rolcreaterole,\n r.rolinherit, r.rolconnlimit, r.rolbypassrls, r.rolreplication, r.rolvaliduntil,\n shobj_description(r.oid, 'pg_authid') AS rolcomment,\n coalesce(array_agg(m.rolname) FILTER (WHERE m.rolname IS NOT NULL), '{}') AS memberof\nFROM pg_roles r\nLEFT JOIN pg_auth_members am ON am.member = r.oid\nLEFT JOIN pg_roles m ON m.oid = am.roleid\nWHERE r.rolname NOT LIKE 'pg\\_%'\nGROUP BY 1,2,3,4,5,6,7,8,9,10,11 ORDER BY 1";
|
|
41
|
+
/** {@link ROLE_ATTRIBUTES_QUERY} as the JSON document {@link parseRoleRows} reads. */
|
|
42
|
+
export declare const ROLE_ATTRIBUTES_JSON_QUERY: string;
|
|
43
|
+
/** One row of {@link ROLE_ATTRIBUTES_QUERY}, parsed and typed. */
|
|
44
|
+
export interface IParsedRoleRow {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly canLogin: boolean;
|
|
47
|
+
readonly isSuperuser: boolean;
|
|
48
|
+
readonly canCreateDb: boolean;
|
|
49
|
+
readonly canCreateRole: boolean;
|
|
50
|
+
readonly inherits: boolean;
|
|
51
|
+
readonly connectionLimit: number;
|
|
52
|
+
readonly bypassesRls: boolean;
|
|
53
|
+
readonly canReplicate: boolean;
|
|
54
|
+
/** Password expiry, or null when the password never expires. */
|
|
55
|
+
readonly validUntil: string | null;
|
|
56
|
+
/** Role comment, or null when the role carries none. */
|
|
57
|
+
readonly comment: string | null;
|
|
58
|
+
readonly memberOf: ReadonlyArray<string>;
|
|
59
|
+
}
|
|
60
|
+
/** Parsed roles, plus a warning for every row that could not be read. */
|
|
61
|
+
export interface IRoleRowsResult {
|
|
62
|
+
/** Rows that parsed cleanly. */
|
|
63
|
+
readonly roles: ReadonlyArray<IParsedRoleRow>;
|
|
64
|
+
/** One line per unreadable row; never empty when a row was skipped. */
|
|
65
|
+
readonly warnings: ReadonlyArray<string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parse every row returned by {@link ROLE_ATTRIBUTES_JSON_QUERY}.
|
|
69
|
+
*
|
|
70
|
+
* @param stdout - Raw `psql -tAc` output of the JSON-wrapped query
|
|
71
|
+
* @returns The roles that parsed, and a warning for every row that did not
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseRoleRows(stdout: string): IRoleRowsResult;
|
|
74
|
+
/**
|
|
75
|
+
* Whether `DatabaseRole` adoption would leave this role's attributes alone.
|
|
76
|
+
*
|
|
77
|
+
* Every attribute `DatabaseRole.spec` can express is compared, because adoption
|
|
78
|
+
* resets each one the manifest omits — checking a subset reports roles as safe
|
|
79
|
+
* that adoption is about to change. See {@link BASELINE_ATTRIBUTES}.
|
|
80
|
+
*
|
|
81
|
+
* @param role - Parsed role row
|
|
82
|
+
* @returns True when every attribute matches the baseline
|
|
83
|
+
*/
|
|
84
|
+
export declare function roleMatchesBaseline(role: IParsedRoleRow): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Describe how a role's attributes deviate from the nimbus baseline, for report output.
|
|
87
|
+
*
|
|
88
|
+
* @param role - Parsed role row that failed {@link roleMatchesBaseline}
|
|
89
|
+
* @returns A one-line, human-readable description of the deviation
|
|
90
|
+
*/
|
|
91
|
+
export declare function describeRoleDeviation(role: IParsedRoleRow): string;
|
|
92
|
+
//# sourceMappingURL=migrate-cnpg-roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-cnpg-roles.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-cnpg-roles.ts"],"names":[],"mapp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AG,OAAO,CAcjE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAKlE"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Role attribute baseline and parsing for the `nimbus migrate` CNPG check.
|
|
4
|
+
*
|
|
5
|
+
* `DatabaseRole` adoption ALTERs an existing role to match the manifest,
|
|
6
|
+
* forcing attributes the manifest omits back to their defaults. nimbus's
|
|
7
|
+
* manifest sets only `login: true`, so every other attribute must already sit
|
|
8
|
+
* at the PostgreSQL default for adoption to be a no-op. This module parses the
|
|
9
|
+
* `pg_roles` query from `docs/cnpg-declarative-databases.md` (reused verbatim,
|
|
10
|
+
* see {@link ROLE_ATTRIBUTES_QUERY}) and flags rows that deviate.
|
|
11
|
+
*
|
|
12
|
+
* The baseline covers every attribute `DatabaseRole.spec` can express, not the
|
|
13
|
+
* subset that is easy to query. Checking fewer is the same false all-clear as
|
|
14
|
+
* skipping a row: `replication`, `validUntil` and `comment` were missing, so a
|
|
15
|
+
* role carrying `REPLICATION` or a finite `VALID UNTIL` was reported as sitting
|
|
16
|
+
* on the baseline and then had exactly that stripped on the first reconcile.
|
|
17
|
+
* Every field of the CRD's `spec` that maps onto a role attribute is read here;
|
|
18
|
+
* the ones that do not (`cluster`, `name`, `ensure`, `databaseRoleReclaimPolicy`,
|
|
19
|
+
* `clientCertificate`) name or govern the CR rather than the role, and
|
|
20
|
+
* `passwordSecret` carries the password migration re-applies deliberately.
|
|
21
|
+
*
|
|
22
|
+
* The query is run through {@link toJsonRowsQuery} rather than read as `psql`'s
|
|
23
|
+
* pipe-delimited output: a role name may contain a `|`, and psql escapes
|
|
24
|
+
* nothing, so such a row parsed as ten fields instead of nine and was discarded.
|
|
25
|
+
* The check then reported that every role matched the baseline while having
|
|
26
|
+
* skipped precisely the role whose attributes adoption would reset. Nothing is
|
|
27
|
+
* dropped now — a row that still cannot be read is returned as a warning.
|
|
28
|
+
*
|
|
29
|
+
* @module cli/migrate-cnpg-roles
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ROLE_ATTRIBUTES_JSON_QUERY = exports.ROLE_ATTRIBUTES_QUERY = exports.BUILTIN_ROLE_NAMES = void 0;
|
|
33
|
+
exports.parseRoleRows = parseRoleRows;
|
|
34
|
+
exports.roleMatchesBaseline = roleMatchesBaseline;
|
|
35
|
+
exports.describeRoleDeviation = describeRoleDeviation;
|
|
36
|
+
const migrate_psql_js_1 = require("./migrate-psql.js");
|
|
37
|
+
/**
|
|
38
|
+
* Operator-managed roles that intentionally do not follow the nimbus baseline
|
|
39
|
+
* (e.g. `postgres` is a superuser by definition). Excluded from role deviation
|
|
40
|
+
* reporting so the check only flags roles nimbus actually provisions.
|
|
41
|
+
*/
|
|
42
|
+
exports.BUILTIN_ROLE_NAMES = [
|
|
43
|
+
"postgres",
|
|
44
|
+
"streaming_replica",
|
|
45
|
+
"cnpg_pooler_pgbouncer",
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* `pg_roles` query from `docs/cnpg-declarative-databases.md`, reused verbatim so this
|
|
49
|
+
* check and the documented manual procedure never drift apart.
|
|
50
|
+
*/
|
|
51
|
+
exports.ROLE_ATTRIBUTES_QUERY = `SELECT r.rolname, r.rolcanlogin, r.rolsuper, r.rolcreatedb, r.rolcreaterole,
|
|
52
|
+
r.rolinherit, r.rolconnlimit, r.rolbypassrls, r.rolreplication, r.rolvaliduntil,
|
|
53
|
+
shobj_description(r.oid, 'pg_authid') AS rolcomment,
|
|
54
|
+
coalesce(array_agg(m.rolname) FILTER (WHERE m.rolname IS NOT NULL), '{}') AS memberof
|
|
55
|
+
FROM pg_roles r
|
|
56
|
+
LEFT JOIN pg_auth_members am ON am.member = r.oid
|
|
57
|
+
LEFT JOIN pg_roles m ON m.oid = am.roleid
|
|
58
|
+
WHERE r.rolname NOT LIKE 'pg\\_%'
|
|
59
|
+
GROUP BY 1,2,3,4,5,6,7,8,9,10,11 ORDER BY 1`;
|
|
60
|
+
/** {@link ROLE_ATTRIBUTES_QUERY} as the JSON document {@link parseRoleRows} reads. */
|
|
61
|
+
exports.ROLE_ATTRIBUTES_JSON_QUERY = (0, migrate_psql_js_1.toJsonRowsQuery)(exports.ROLE_ATTRIBUTES_QUERY);
|
|
62
|
+
/** What this query reads, named in warnings. */
|
|
63
|
+
const SUBJECT = "pg_roles";
|
|
64
|
+
/** Columns {@link ROLE_ATTRIBUTES_QUERY} returns, by the name `row_to_json` gives them. */
|
|
65
|
+
const ROLE_COLUMNS = {
|
|
66
|
+
NAME: "rolname",
|
|
67
|
+
CAN_LOGIN: "rolcanlogin",
|
|
68
|
+
IS_SUPERUSER: "rolsuper",
|
|
69
|
+
CAN_CREATE_DB: "rolcreatedb",
|
|
70
|
+
CAN_CREATE_ROLE: "rolcreaterole",
|
|
71
|
+
INHERITS: "rolinherit",
|
|
72
|
+
CONNECTION_LIMIT: "rolconnlimit",
|
|
73
|
+
BYPASSES_RLS: "rolbypassrls",
|
|
74
|
+
CAN_REPLICATE: "rolreplication",
|
|
75
|
+
VALID_UNTIL: "rolvaliduntil",
|
|
76
|
+
COMMENT: "rolcomment",
|
|
77
|
+
MEMBER_OF: "memberof",
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* PostgreSQL's other spelling of "this password never expires".
|
|
81
|
+
*
|
|
82
|
+
* `ALTER ROLE` cannot set `VALID UNTIL NULL`, so CNPG writes `infinity` when the
|
|
83
|
+
* manifest omits `validUntil`. A role already carrying `infinity` is therefore
|
|
84
|
+
* on the baseline just as surely as one carrying NULL.
|
|
85
|
+
*/
|
|
86
|
+
const INFINITE_VALID_UNTIL = "infinity";
|
|
87
|
+
/** How a password with no expiry is rendered in a deviation line. */
|
|
88
|
+
const NEVER_EXPIRES = "(never)";
|
|
89
|
+
/** How a role with no comment is rendered in a deviation line. */
|
|
90
|
+
const NO_COMMENT = "(none)";
|
|
91
|
+
/** Longest role comment echoed back in a deviation line. */
|
|
92
|
+
const MAX_COMMENT_LENGTH = 60;
|
|
93
|
+
/**
|
|
94
|
+
* The attribute set `DatabaseRole` adoption leaves untouched.
|
|
95
|
+
*
|
|
96
|
+
* Both the baseline check and the deviation message are derived from this one
|
|
97
|
+
* value, so the message can never describe a baseline the check does not apply.
|
|
98
|
+
*/
|
|
99
|
+
const BASELINE_ATTRIBUTES = {
|
|
100
|
+
canLogin: true,
|
|
101
|
+
isSuperuser: false,
|
|
102
|
+
canCreateDb: false,
|
|
103
|
+
canCreateRole: false,
|
|
104
|
+
inherits: true,
|
|
105
|
+
connectionLimit: -1,
|
|
106
|
+
bypassesRls: false,
|
|
107
|
+
canReplicate: false,
|
|
108
|
+
validUntil: null,
|
|
109
|
+
comment: null,
|
|
110
|
+
memberOf: [],
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Render a boolean back into psql's `t`/`f` notation for report output.
|
|
114
|
+
*
|
|
115
|
+
* @param value - Boolean to render
|
|
116
|
+
* @returns "t" or "f"
|
|
117
|
+
*/
|
|
118
|
+
function toPsqlBoolean(value) {
|
|
119
|
+
return value ? "t" : "f";
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Render role memberships the way psql prints a `text[]`, for report output.
|
|
123
|
+
*
|
|
124
|
+
* @param memberOf - Roles this role is a member of
|
|
125
|
+
* @returns The memberships in `{a,b}` form
|
|
126
|
+
*/
|
|
127
|
+
function toPsqlArray(memberOf) {
|
|
128
|
+
return `{${memberOf.join(",")}}`;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Whether a role's password expiry is the one adoption would leave alone.
|
|
132
|
+
*
|
|
133
|
+
* @param validUntil - `rolvaliduntil`, or null for a SQL NULL
|
|
134
|
+
* @returns True when the password never expires
|
|
135
|
+
*/
|
|
136
|
+
function hasNoPasswordExpiry(validUntil) {
|
|
137
|
+
return validUntil === null || validUntil.trim().toLowerCase() === INFINITE_VALID_UNTIL;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether a role carries no comment for adoption to clear.
|
|
141
|
+
*
|
|
142
|
+
* An empty comment and no comment at all are indistinguishable to the operator,
|
|
143
|
+
* which reads both as the empty string, so both sit on the baseline.
|
|
144
|
+
*
|
|
145
|
+
* @param comment - `rolcomment`, or null for a SQL NULL
|
|
146
|
+
* @returns True when the role has nothing adoption would overwrite
|
|
147
|
+
*/
|
|
148
|
+
function hasNoComment(comment) {
|
|
149
|
+
return comment === null || comment === "";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Render a password expiry for report output.
|
|
153
|
+
*
|
|
154
|
+
* A password that never expires reads as {@link NEVER_EXPIRES} whichever way
|
|
155
|
+
* PostgreSQL spells it, so a role on the baseline renders identically to the
|
|
156
|
+
* baseline rather than as a deviation with the same meaning.
|
|
157
|
+
*
|
|
158
|
+
* @param validUntil - `rolvaliduntil`, or null for a SQL NULL
|
|
159
|
+
* @returns The expiry, or a phrase saying there is none
|
|
160
|
+
*/
|
|
161
|
+
function toReportedValidUntil(validUntil) {
|
|
162
|
+
// The null test is redundant against hasNoPasswordExpiry and kept because it
|
|
163
|
+
// is what narrows the type of the value returned below.
|
|
164
|
+
if (validUntil === null || hasNoPasswordExpiry(validUntil)) {
|
|
165
|
+
return NEVER_EXPIRES;
|
|
166
|
+
}
|
|
167
|
+
return validUntil;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Render a role comment for report output.
|
|
171
|
+
*
|
|
172
|
+
* A comment is free text an operator wrote: it may be long and may contain
|
|
173
|
+
* newlines, and a deviation line is one line, so it is collapsed and truncated.
|
|
174
|
+
*
|
|
175
|
+
* @param comment - `rolcomment`, or null for a SQL NULL
|
|
176
|
+
* @returns The quoted comment, or a phrase saying there is none
|
|
177
|
+
*/
|
|
178
|
+
function toReportedComment(comment) {
|
|
179
|
+
if (comment === null || comment === "") {
|
|
180
|
+
return NO_COMMENT;
|
|
181
|
+
}
|
|
182
|
+
const oneLine = comment.replace(/\s+/g, " ").trim();
|
|
183
|
+
const shortened = oneLine.length > MAX_COMMENT_LENGTH ? `${oneLine.slice(0, MAX_COMMENT_LENGTH)}…` : oneLine;
|
|
184
|
+
return `"${shortened}"`;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Render one role's attributes in the compact form the report prints.
|
|
188
|
+
*
|
|
189
|
+
* @param attributes - A parsed role's attributes, or {@link BASELINE_ATTRIBUTES}
|
|
190
|
+
* @returns A single line of `key=value` pairs
|
|
191
|
+
*/
|
|
192
|
+
function describeAttributes(attributes) {
|
|
193
|
+
return (`login=${toPsqlBoolean(attributes.canLogin)} super=${toPsqlBoolean(attributes.isSuperuser)} ` +
|
|
194
|
+
`createdb=${toPsqlBoolean(attributes.canCreateDb)} ` +
|
|
195
|
+
`createrole=${toPsqlBoolean(attributes.canCreateRole)} ` +
|
|
196
|
+
`inherit=${toPsqlBoolean(attributes.inherits)} connlimit=${attributes.connectionLimit} ` +
|
|
197
|
+
`bypassrls=${toPsqlBoolean(attributes.bypassesRls)} ` +
|
|
198
|
+
`replication=${toPsqlBoolean(attributes.canReplicate)} ` +
|
|
199
|
+
`validuntil=${toReportedValidUntil(attributes.validUntil)} ` +
|
|
200
|
+
`comment=${toReportedComment(attributes.comment)} memberof=${toPsqlArray(attributes.memberOf)}`);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Name a row in a warning, using its role name when that much was readable.
|
|
204
|
+
*
|
|
205
|
+
* @param index - Zero-based position in the result
|
|
206
|
+
* @param name - Role name, when it could be read
|
|
207
|
+
* @returns A phrase identifying the row to an operator
|
|
208
|
+
*/
|
|
209
|
+
function describeRow(index, name) {
|
|
210
|
+
return name === undefined ? `${SUBJECT} row ${index + 1}` : `role "${name}"`;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Parse one row of {@link ROLE_ATTRIBUTES_QUERY}.
|
|
214
|
+
*
|
|
215
|
+
* @param row - One object from the query's JSON output
|
|
216
|
+
* @param index - Zero-based position in the result, for the warning
|
|
217
|
+
* @returns The parsed row, or a warning naming the row and its bad columns
|
|
218
|
+
*/
|
|
219
|
+
function parseRoleRow(row, index) {
|
|
220
|
+
const name = (0, migrate_psql_js_1.readString)(row, ROLE_COLUMNS.NAME);
|
|
221
|
+
const canLogin = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.CAN_LOGIN);
|
|
222
|
+
const isSuperuser = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.IS_SUPERUSER);
|
|
223
|
+
const canCreateDb = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.CAN_CREATE_DB);
|
|
224
|
+
const canCreateRole = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.CAN_CREATE_ROLE);
|
|
225
|
+
const inherits = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.INHERITS);
|
|
226
|
+
const connectionLimit = (0, migrate_psql_js_1.readNumber)(row, ROLE_COLUMNS.CONNECTION_LIMIT);
|
|
227
|
+
const bypassesRls = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.BYPASSES_RLS);
|
|
228
|
+
const canReplicate = (0, migrate_psql_js_1.readBoolean)(row, ROLE_COLUMNS.CAN_REPLICATE);
|
|
229
|
+
const validUntil = (0, migrate_psql_js_1.readNullableString)(row, ROLE_COLUMNS.VALID_UNTIL);
|
|
230
|
+
const comment = (0, migrate_psql_js_1.readNullableString)(row, ROLE_COLUMNS.COMMENT);
|
|
231
|
+
const memberOf = (0, migrate_psql_js_1.readStringArray)(row, ROLE_COLUMNS.MEMBER_OF);
|
|
232
|
+
const unreadable = [
|
|
233
|
+
[ROLE_COLUMNS.NAME, name],
|
|
234
|
+
[ROLE_COLUMNS.CAN_LOGIN, canLogin],
|
|
235
|
+
[ROLE_COLUMNS.IS_SUPERUSER, isSuperuser],
|
|
236
|
+
[ROLE_COLUMNS.CAN_CREATE_DB, canCreateDb],
|
|
237
|
+
[ROLE_COLUMNS.CAN_CREATE_ROLE, canCreateRole],
|
|
238
|
+
[ROLE_COLUMNS.INHERITS, inherits],
|
|
239
|
+
[ROLE_COLUMNS.CONNECTION_LIMIT, connectionLimit],
|
|
240
|
+
[ROLE_COLUMNS.BYPASSES_RLS, bypassesRls],
|
|
241
|
+
[ROLE_COLUMNS.CAN_REPLICATE, canReplicate],
|
|
242
|
+
[ROLE_COLUMNS.VALID_UNTIL, validUntil],
|
|
243
|
+
[ROLE_COLUMNS.COMMENT, comment],
|
|
244
|
+
[ROLE_COLUMNS.MEMBER_OF, memberOf],
|
|
245
|
+
];
|
|
246
|
+
if (name === undefined ||
|
|
247
|
+
canLogin === undefined ||
|
|
248
|
+
isSuperuser === undefined ||
|
|
249
|
+
canCreateDb === undefined ||
|
|
250
|
+
canCreateRole === undefined ||
|
|
251
|
+
inherits === undefined ||
|
|
252
|
+
connectionLimit === undefined ||
|
|
253
|
+
bypassesRls === undefined ||
|
|
254
|
+
canReplicate === undefined ||
|
|
255
|
+
validUntil === undefined ||
|
|
256
|
+
comment === undefined ||
|
|
257
|
+
memberOf === undefined) {
|
|
258
|
+
const columns = unreadable
|
|
259
|
+
.filter(([, value]) => value === undefined)
|
|
260
|
+
.map(([column]) => column)
|
|
261
|
+
.join(", ");
|
|
262
|
+
return {
|
|
263
|
+
warning: `${describeRow(index, name)}: could not read ${columns} from the ${SUBJECT} query ` +
|
|
264
|
+
"output, so this role was NOT checked against the adoption baseline.",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
role: {
|
|
269
|
+
name,
|
|
270
|
+
canLogin,
|
|
271
|
+
isSuperuser,
|
|
272
|
+
canCreateDb,
|
|
273
|
+
canCreateRole,
|
|
274
|
+
inherits,
|
|
275
|
+
connectionLimit,
|
|
276
|
+
bypassesRls,
|
|
277
|
+
canReplicate,
|
|
278
|
+
validUntil,
|
|
279
|
+
comment,
|
|
280
|
+
memberOf,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Parse every row returned by {@link ROLE_ATTRIBUTES_JSON_QUERY}.
|
|
286
|
+
*
|
|
287
|
+
* @param stdout - Raw `psql -tAc` output of the JSON-wrapped query
|
|
288
|
+
* @returns The roles that parsed, and a warning for every row that did not
|
|
289
|
+
*/
|
|
290
|
+
function parseRoleRows(stdout) {
|
|
291
|
+
const parsed = (0, migrate_psql_js_1.parseJsonRows)(stdout, SUBJECT);
|
|
292
|
+
const roles = [];
|
|
293
|
+
const warnings = [...parsed.warnings];
|
|
294
|
+
parsed.rows.forEach((row, index) => {
|
|
295
|
+
const outcome = parseRoleRow(row, index);
|
|
296
|
+
if ("role" in outcome) {
|
|
297
|
+
roles.push(outcome.role);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
warnings.push(outcome.warning);
|
|
301
|
+
});
|
|
302
|
+
return { roles, warnings };
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Whether `DatabaseRole` adoption would leave this role's attributes alone.
|
|
306
|
+
*
|
|
307
|
+
* Every attribute `DatabaseRole.spec` can express is compared, because adoption
|
|
308
|
+
* resets each one the manifest omits — checking a subset reports roles as safe
|
|
309
|
+
* that adoption is about to change. See {@link BASELINE_ATTRIBUTES}.
|
|
310
|
+
*
|
|
311
|
+
* @param role - Parsed role row
|
|
312
|
+
* @returns True when every attribute matches the baseline
|
|
313
|
+
*/
|
|
314
|
+
function roleMatchesBaseline(role) {
|
|
315
|
+
return (role.canLogin === BASELINE_ATTRIBUTES.canLogin &&
|
|
316
|
+
role.isSuperuser === BASELINE_ATTRIBUTES.isSuperuser &&
|
|
317
|
+
role.canCreateDb === BASELINE_ATTRIBUTES.canCreateDb &&
|
|
318
|
+
role.canCreateRole === BASELINE_ATTRIBUTES.canCreateRole &&
|
|
319
|
+
role.inherits === BASELINE_ATTRIBUTES.inherits &&
|
|
320
|
+
role.connectionLimit === BASELINE_ATTRIBUTES.connectionLimit &&
|
|
321
|
+
role.bypassesRls === BASELINE_ATTRIBUTES.bypassesRls &&
|
|
322
|
+
role.canReplicate === BASELINE_ATTRIBUTES.canReplicate &&
|
|
323
|
+
hasNoPasswordExpiry(role.validUntil) &&
|
|
324
|
+
hasNoComment(role.comment) &&
|
|
325
|
+
role.memberOf.length === 0);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Describe how a role's attributes deviate from the nimbus baseline, for report output.
|
|
329
|
+
*
|
|
330
|
+
* @param role - Parsed role row that failed {@link roleMatchesBaseline}
|
|
331
|
+
* @returns A one-line, human-readable description of the deviation
|
|
332
|
+
*/
|
|
333
|
+
function describeRoleDeviation(role) {
|
|
334
|
+
return (`role "${role.name}": ${describeAttributes(role)} ` +
|
|
335
|
+
`(baseline: ${describeAttributes(BASELINE_ATTRIBUTES)})`);
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=migrate-cnpg-roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-cnpg-roles.js","sourceRoot":"","sources":["../../../src/cli/migrate-cnpg-roles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAqUH,sCAeC;AAYD,kDAcC;AAQD,sDAKC;AAzXD,uDAQ2B;AAE3B;;;;GAIG;AACU,QAAA,kBAAkB,GAAsB;IACnD,UAAU;IACV,mBAAmB;IACnB,uBAAuB;CACxB,CAAC;AAEF;;;GAGG;AACU,QAAA,qBAAqB,GAAG;;;;;;;;4CAQO,CAAC;AAE7C,sFAAsF;AACzE,QAAA,0BAA0B,GAAG,IAAA,iCAAe,EAAC,6BAAqB,CAAC,CAAC;AAEjF,gDAAgD;AAChD,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,2FAA2F;AAC3F,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,aAAa;IACxB,YAAY,EAAE,UA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;IACtD,OAAO,CACL,IAAI,CAAC,QAAQ,KAAK,mBAAmB,CAAC,QAAQ;QAC9C,IAAI,CAAC,WAAW,KAAK,mBAAmB,CAAC,WAAW;QACpD,IAAI,CAAC,WAAW,KAAK,mBAAmB,CAAC,WAAW;QACpD,IAAI,CAAC,aAAa,KAAK,mBAAmB,CAAC,aAAa;QACxD,IAAI,CAAC,QAAQ,KAAK,mBAAmB,CAAC,QAAQ;QAC9C,IAAI,CAAC,eAAe,KAAK,mBAAmB,CAAC,eAAe;QAC5D,IAAI,CAAC,WAAW,KAAK,mBAAmB,CAAC,WAAW;QACpD,IAAI,CAAC,YAAY,KAAK,mBAAmB,CAAC,YAAY;QACtD,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC;QACpC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,IAAoB;IACxD,OAAO,CACL,SAAS,IAAI,CAAC,IAAI,MAAM,kBAAkB,CAAC,IAAI,CAAC,GAAG;QACnD,cAAc,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,CACzD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CNPG-specific checks for `nimbus migrate`: CRD presence, role attributes,
|
|
3
|
+
* and database ownership.
|
|
4
|
+
*
|
|
5
|
+
* @module cli/migrate-cnpg
|
|
6
|
+
*/
|
|
7
|
+
import type { ISectionResult } from "./migrate-report.js";
|
|
8
|
+
/** CRD name backing the `Database` custom resource. */
|
|
9
|
+
export declare const CNPG_DATABASE_CRD_NAME = "databases.postgresql.cnpg.io";
|
|
10
|
+
/** CRD name backing the `DatabaseRole` custom resource. */
|
|
11
|
+
export declare const CNPG_DATABASE_ROLE_CRD_NAME = "databaseroles.postgresql.cnpg.io";
|
|
12
|
+
/** Outcome of {@link checkCnpgCrds}. */
|
|
13
|
+
export interface ICrdCheckOutcome {
|
|
14
|
+
readonly section: ISectionResult;
|
|
15
|
+
readonly clusterReachable: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check that both CNPG CRDs required by the declarative path exist.
|
|
19
|
+
*
|
|
20
|
+
* @returns The section result plus whether the cluster was reachable, so
|
|
21
|
+
* downstream checks know whether to attempt a `kubectl exec`
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkCnpgCrds(): ICrdCheckOutcome;
|
|
24
|
+
/** Role attribute and database ownership section results for one migrate run. */
|
|
25
|
+
export interface IClusterSections {
|
|
26
|
+
readonly roleSection: ISectionResult;
|
|
27
|
+
readonly ownershipSection: ISectionResult;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check every nimbus-managed CNPG cluster's role attributes and database
|
|
31
|
+
* ownership against the baseline that makes `Database`/`DatabaseRole`
|
|
32
|
+
* adoption a no-op.
|
|
33
|
+
*
|
|
34
|
+
* @param clusterReachable - Whether {@link checkCnpgCrds} could reach the cluster
|
|
35
|
+
* @returns Section results for role attributes and database ownership
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkClusterState(clusterReachable: boolean): IClusterSections;
|
|
38
|
+
//# sourceMappingURL=migrate-cnpg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-cnpg.d.ts","sourceRoot":"","sources":["../../../src/cli/migrate-cnpg.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAc1D,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AACrE,2DAA2D;AAC3D,eAAO,MAAM,2BAA2B,qCAAqC,CAAC;AAE9E,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CA0DhD;AA4DD,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC;CAC3C;AAkBD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,CA6H7E"}
|