@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.
- package/README.md +2 -0
- package/dist/cjs/backup/index.d.ts.map +1 -1
- package/dist/cjs/backup/index.js +6 -1
- package/dist/cjs/backup/index.js.map +1 -1
- 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/platform/components/image-pruner.d.ts +3 -1
- package/dist/cjs/platform/components/image-pruner.d.ts.map +1 -1
- package/dist/cjs/platform/components/image-pruner.js +38 -19
- package/dist/cjs/platform/components/image-pruner.js.map +1 -1
- 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/backup/index.d.ts.map +1 -1
- package/dist/esm/backup/index.js +6 -1
- package/dist/esm/backup/index.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/platform/components/image-pruner.d.ts +3 -1
- package/dist/esm/platform/components/image-pruner.d.ts.map +1 -1
- package/dist/esm/platform/components/image-pruner.js +38 -19
- package/dist/esm/platform/components/image-pruner.js.map +1 -1
- 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,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Constants and naming helpers shared by the MariaDB Operator modules.
|
|
4
|
+
*
|
|
5
|
+
* They live here rather than in any one module because `mariadb.ts` (the
|
|
6
|
+
* MariaDB instance), `mariadb-roles.ts` (users, grants, and credentials), and
|
|
7
|
+
* `mariadb-database.ts` (databases) all need them and none of them owns them.
|
|
8
|
+
*
|
|
9
|
+
* @module operator/mariadb-common
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ALL_PRIVILEGES = exports.ALL_OBJECTS = exports.ALL_TABLES = exports.DEFAULT_MAX_USER_CONNECTIONS = exports.DEFAULT_GRANT_HOST = exports.BACKUP_KIND = exports.GRANT_KIND = exports.USER_KIND = exports.DATABASE_KIND = exports.MARIADB_KIND = exports.MARIADB_API_VERSION = exports.DATA_NAMESPACE = void 0;
|
|
13
|
+
exports.createMariadbRoleRegistry = createMariadbRoleRegistry;
|
|
14
|
+
exports.resolveMariadbHost = resolveMariadbHost;
|
|
15
|
+
exports.claimMariadbRoleName = claimMariadbRoleName;
|
|
16
|
+
exports.toResourceName = toResourceName;
|
|
17
|
+
const role_registry_js_1 = require("./role-registry.js");
|
|
18
|
+
const resource_identity_js_1 = require("./resource-identity.js");
|
|
19
|
+
/** Namespace every MariaDB instance, database, and credential Secret is created in. */
|
|
20
|
+
exports.DATA_NAMESPACE = "data";
|
|
21
|
+
/** API group and version of every mariadb-operator custom resource. */
|
|
22
|
+
exports.MARIADB_API_VERSION = "k8s.mariadb.com/v1alpha1";
|
|
23
|
+
/** Kind of the custom resource that owns a MariaDB instance. */
|
|
24
|
+
exports.MARIADB_KIND = "MariaDB";
|
|
25
|
+
/** Kind of the custom resource that owns a database. */
|
|
26
|
+
exports.DATABASE_KIND = "Database";
|
|
27
|
+
/** Kind of the custom resource that owns a login account. */
|
|
28
|
+
exports.USER_KIND = "User";
|
|
29
|
+
/** Kind of the custom resource that owns a privilege grant. */
|
|
30
|
+
exports.GRANT_KIND = "Grant";
|
|
31
|
+
/** Kind of the custom resource that owns a scheduled backup. */
|
|
32
|
+
exports.BACKUP_KIND = "Backup";
|
|
33
|
+
/** Host pattern a user may connect from when none is configured. */
|
|
34
|
+
exports.DEFAULT_GRANT_HOST = "%";
|
|
35
|
+
/** Matches a host pattern holding nothing but whitespace, the empty string included. */
|
|
36
|
+
const BLANK_HOST = /^\s*$/;
|
|
37
|
+
/** Concurrent connection cap applied to every provisioned user. */
|
|
38
|
+
exports.DEFAULT_MAX_USER_CONNECTIONS = 100;
|
|
39
|
+
/** `spec.table` value covering every table in the database. */
|
|
40
|
+
exports.ALL_TABLES = "*";
|
|
41
|
+
/** `IDatabaseGrant.objects` value meaning "every object", not a literal name. */
|
|
42
|
+
exports.ALL_OBJECTS = "all";
|
|
43
|
+
/** Privilege set granted to a database's owner. */
|
|
44
|
+
exports.ALL_PRIVILEGES = "ALL PRIVILEGES";
|
|
45
|
+
/** What a MariaDB account's identity is global to. */
|
|
46
|
+
const MARIADB_ROLE_SCOPE_NOUN = "instance";
|
|
47
|
+
/** Why a duplicate MariaDB `user`@`host` pair cannot be waved through. */
|
|
48
|
+
const MARIADB_ROLE_SCOPE_EXPLANATION = "MariaDB accounts are instance-global, not database-scoped: one account serves " +
|
|
49
|
+
"every database on the instance, and its identity is the username and host " +
|
|
50
|
+
"together. Two User CRs naming the same pair would each point at a different " +
|
|
51
|
+
"generated password Secret, and the operator would reconcile the account's " +
|
|
52
|
+
"password back and forth between them, until at least one database's replicated " +
|
|
53
|
+
"connection Secrets stopped authenticating. Their Pulumi logical names differ, so " +
|
|
54
|
+
"`pulumi preview` cannot see the clash.";
|
|
55
|
+
/**
|
|
56
|
+
* Create the role-identity registry for one MariaDB instance.
|
|
57
|
+
*
|
|
58
|
+
* @param clusterName - MariaDB instance the registry covers
|
|
59
|
+
* @returns A registry that rejects a `user`@`host` pair claimed twice on this instance
|
|
60
|
+
*/
|
|
61
|
+
function createMariadbRoleRegistry(clusterName) {
|
|
62
|
+
return (0, role_registry_js_1.createRoleRegistry)({
|
|
63
|
+
clusterName,
|
|
64
|
+
scopeNoun: MARIADB_ROLE_SCOPE_NOUN,
|
|
65
|
+
scopeExplanation: MARIADB_ROLE_SCOPE_EXPLANATION,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a configured host pattern to the value the account will actually have.
|
|
70
|
+
*
|
|
71
|
+
* There is exactly one effective host for any configuration, and everything that
|
|
72
|
+
* identifies the account has to agree on it: the registry key that refuses a
|
|
73
|
+
* duplicate `user`@`host`, the Pulumi logical names derived from that pair, and
|
|
74
|
+
* the `spec.host` written into the `User` and `Grant` CRs. A configured `""`
|
|
75
|
+
* used to survive `?? DEFAULT_GRANT_HOST` — the empty string is not nullish — so
|
|
76
|
+
* it was registered and named as the distinct identity `reader`@`""` while the
|
|
77
|
+
* CRs omitted the field and inherited the operator's own `%` default. Two
|
|
78
|
+
* databases could then claim what MariaDB sees as one account, each pointing it
|
|
79
|
+
* at a different generated password Secret, which is the exact collision the
|
|
80
|
+
* registry exists to prevent.
|
|
81
|
+
*
|
|
82
|
+
* Whitespace-only patterns resolve the same way, and a surrounding-whitespace
|
|
83
|
+
* pattern is trimmed, so `" 10.0.0.1 "` and `"10.0.0.1"` cannot be claimed as
|
|
84
|
+
* two accounts either.
|
|
85
|
+
*
|
|
86
|
+
* @param host - Host pattern as configured, if any
|
|
87
|
+
* @returns The host the account is effectively reachable from, never blank
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* resolveMariadbHost(undefined); // "%"
|
|
92
|
+
* resolveMariadbHost(""); // "%"
|
|
93
|
+
* resolveMariadbHost(" 10.0.0.1 "); // "10.0.0.1"
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
function resolveMariadbHost(host) {
|
|
97
|
+
if (host === undefined || BLANK_HOST.test(host)) {
|
|
98
|
+
return exports.DEFAULT_GRANT_HOST;
|
|
99
|
+
}
|
|
100
|
+
return host.trim();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Claim a MariaDB account on an instance.
|
|
104
|
+
*
|
|
105
|
+
* The claim is keyed on the username **and** the host, because that pair is what
|
|
106
|
+
* MariaDB treats as one account: `reader`@`%` and `reader`@`10.0.0.1` are two
|
|
107
|
+
* separate accounts with separate passwords, so both must be allowed.
|
|
108
|
+
*
|
|
109
|
+
* @param registry - The instance's registry
|
|
110
|
+
* @param roleName - Username as it will exist in MariaDB
|
|
111
|
+
* @param host - Effective host pattern, as returned by {@link resolveMariadbHost}
|
|
112
|
+
* @param dbName - Database whose configuration is claiming it
|
|
113
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when the pair is taken
|
|
114
|
+
*/
|
|
115
|
+
function claimMariadbRoleName(registry, roleName, host, dbName) {
|
|
116
|
+
registry.claim({
|
|
117
|
+
// Serialized rather than joined on "@": a role name may itself contain one
|
|
118
|
+
// (the name validator permits it), and `a@b`@`c` must not collide with
|
|
119
|
+
// `a`@`b@c`.
|
|
120
|
+
identity: JSON.stringify([roleName, host]),
|
|
121
|
+
label: `"${roleName}"@"${host}"`,
|
|
122
|
+
databaseName: dbName,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Normalize a string into a DNS-1123 subdomain usable as `metadata.name`.
|
|
127
|
+
*
|
|
128
|
+
* Only the Kubernetes object name is sanitized — the MariaDB identifiers in
|
|
129
|
+
* `spec.name` / `spec.username` are passed through verbatim so that CRs adopt
|
|
130
|
+
* databases and users that already exist under their original names.
|
|
131
|
+
*
|
|
132
|
+
* Sanitizing is lossy, so this is not safe for anything that has to identify a
|
|
133
|
+
* resource: see {@link toIdentitySegment}.
|
|
134
|
+
*
|
|
135
|
+
* @param value - Raw name
|
|
136
|
+
* @returns A lowercase, `-`-separated name safe for `metadata.name`
|
|
137
|
+
*/
|
|
138
|
+
function toResourceName(value) {
|
|
139
|
+
return (0, resource_identity_js_1.toDnsSegment)(value);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=mariadb-common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mariadb-common.js","sourceRoot":"","sources":["../../../src/operator/mariadb-common.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA+DH,8DAMC;AA8BD,gDAKC;AAeD,oDAcC;AAeD,wCAEC;AApJD,yDAA4E;AAC5E,iEAAsD;AAEtD,uFAAu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AkB,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,oBAAoB,CAClC,QAAuB,EACvB,QAAgB,EAChB,IAAY,EACZ,MAAc;IAEd,QAAQ,CAAC,KAAK,CAAC;QACb,2EAA2E;QAC3E,uEAAuE;QACvE,aAAa;QACb,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC1C,KAAK,EAAE,IAAI,QAAQ,MAAM,IAAI,GAAG;QAChC,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,IAAA,mCAAY,EAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Databases inside a MariaDB Operator instance.
|
|
3
|
+
*
|
|
4
|
+
* Provisioning is fully declarative: a `Database` CR owns the database, a
|
|
5
|
+
* `User` CR owns each login account and its password, and a `Grant` CR owns
|
|
6
|
+
* each privilege set. Unlike CloudNativePG — where privileges have no CRD
|
|
7
|
+
* equivalent and are applied by a `psql` Job — nothing here executes SQL, which
|
|
8
|
+
* is also why `config.sql` throws rather than being dropped. The operator
|
|
9
|
+
* reconciles all three kinds continuously, so drift is corrected rather than
|
|
10
|
+
* silently persisting.
|
|
11
|
+
*
|
|
12
|
+
* @module operator/mariadb-database
|
|
13
|
+
*/
|
|
14
|
+
import * as k8s from "@pulumi/kubernetes";
|
|
15
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
16
|
+
import type { IRoleRegistry } from "./role-registry.js";
|
|
17
|
+
import type { IDatabaseInstance, IOperatorDatabaseConfig } from "./interfaces.js";
|
|
18
|
+
/** Inputs for {@link createSingleMariadbDatabaseInstance}. */
|
|
19
|
+
export interface IMariadbDatabaseOptions {
|
|
20
|
+
/** MariaDB instance the database is created on. */
|
|
21
|
+
readonly clusterName: string;
|
|
22
|
+
/** Database name, passed to MariaDB verbatim. */
|
|
23
|
+
readonly dbName: string;
|
|
24
|
+
/** Per-database configuration, with environments already resolved away. */
|
|
25
|
+
readonly config: Omit<IOperatorDatabaseConfig, "environments">;
|
|
26
|
+
/** Instance endpoint. */
|
|
27
|
+
readonly endpoint: pulumi.Output<string>;
|
|
28
|
+
/** Instance port. */
|
|
29
|
+
readonly port: pulumi.Output<number>;
|
|
30
|
+
/** The `MariaDB` CR. */
|
|
31
|
+
readonly mariadb: k8s.apiextensions.CustomResource;
|
|
32
|
+
/**
|
|
33
|
+
* Account identities already claimed on this instance, shared by every
|
|
34
|
+
* database on it.
|
|
35
|
+
*
|
|
36
|
+
* MariaDB accounts are instance-global, so this cannot be per-database: see
|
|
37
|
+
* {@link IRoleRegistry}.
|
|
38
|
+
*/
|
|
39
|
+
readonly roleRegistry: IRoleRegistry;
|
|
40
|
+
/** Kubernetes provider. */
|
|
41
|
+
readonly provider: k8s.Provider;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a single database instance within a MariaDB instance.
|
|
45
|
+
*
|
|
46
|
+
* The owner is granted `ALL PRIVILEGES` on the database with `GRANT OPTION`,
|
|
47
|
+
* and its connection details are replicated into the configured namespaces.
|
|
48
|
+
* Additional roles are added afterwards via the returned `addRole()`.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Instance, database name, configuration, and provider
|
|
51
|
+
* @returns The database instance, with `addRole()` bound to it
|
|
52
|
+
* @throws {AnyCloudError} code `INVALID_GRANT` when a role's grant lists no privileges
|
|
53
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_PRIVILEGE` when a role's grant names
|
|
54
|
+
* a privilege a database-scoped MariaDB `GRANT` cannot carry
|
|
55
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `dbName` is blank
|
|
56
|
+
* or `addRole()` is called with a blank name, when `config.sql` is
|
|
57
|
+
* set (MariaDB runs no SQL), when `config.owner` is set to anything but the
|
|
58
|
+
* database name, when `addRole()` is called with the database owner's own
|
|
59
|
+
* name, when `addRole()` is called with a `user`@`host` pair any other
|
|
60
|
+
* database on the same instance has already claimed, when `addRole()` is
|
|
61
|
+
* passed `login: false`, or when it is passed an `engineOptions` block
|
|
62
|
+
* belonging to another engine
|
|
63
|
+
*/
|
|
64
|
+
export declare function createSingleMariadbDatabaseInstance(options: IMariadbDatabaseOptions): IDatabaseInstance;
|
|
65
|
+
//# sourceMappingURL=mariadb-database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mariadb-database.d.ts","sourceRoot":"","sources":["../../../src/operator/mariadb-database.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAwBzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EAGjB,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AAezB,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;IAC/D,yBAAyB;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrC,wBAAwB;IACxB,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC;IACnD;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,2BAA2B;IAC3B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,uBAAuB,GAC/B,iBAAiB,CAoOnB"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Databases inside a MariaDB Operator instance.
|
|
4
|
+
*
|
|
5
|
+
* Provisioning is fully declarative: a `Database` CR owns the database, a
|
|
6
|
+
* `User` CR owns each login account and its password, and a `Grant` CR owns
|
|
7
|
+
* each privilege set. Unlike CloudNativePG — where privileges have no CRD
|
|
8
|
+
* equivalent and are applied by a `psql` Job — nothing here executes SQL, which
|
|
9
|
+
* is also why `config.sql` throws rather than being dropped. The operator
|
|
10
|
+
* reconciles all three kinds continuously, so drift is corrected rather than
|
|
11
|
+
* silently persisting.
|
|
12
|
+
*
|
|
13
|
+
* @module operator/mariadb-database
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.createSingleMariadbDatabaseInstance = createSingleMariadbDatabaseInstance;
|
|
50
|
+
const k8s = __importStar(require("@pulumi/kubernetes"));
|
|
51
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
52
|
+
const mariadb_common_js_1 = require("./mariadb-common.js");
|
|
53
|
+
const mariadb_roles_js_1 = require("./mariadb-roles.js");
|
|
54
|
+
const role_config_js_1 = require("./grants/role-config.js");
|
|
55
|
+
const database_options_js_1 = require("./database-options.js");
|
|
56
|
+
const errors_js_1 = require("../types/errors.js");
|
|
57
|
+
/** Label marking every object this module creates as nimbus-managed. */
|
|
58
|
+
const MANAGED_BY_LABEL = "app.kubernetes.io/managed-by";
|
|
59
|
+
/** Value of {@link MANAGED_BY_LABEL}. */
|
|
60
|
+
const MANAGED_BY_VALUE = "nimbus";
|
|
61
|
+
/** Character set every provisioned database is created with. */
|
|
62
|
+
const DEFAULT_CHARACTER_SET = "utf8mb4";
|
|
63
|
+
/** Collation every provisioned database is created with. */
|
|
64
|
+
const DEFAULT_COLLATION = "utf8mb4_unicode_ci";
|
|
65
|
+
/** Field of the `Database` CR that mariadb-operator rejects updates to. */
|
|
66
|
+
const DATABASE_IMMUTABLE_FIELDS = ["spec.name"];
|
|
67
|
+
/** Engine name used in errors about options MariaDB cannot honour. */
|
|
68
|
+
const MARIADB_ENGINE_NAME = database_options_js_1.ENGINE_NAMES.MARIADB;
|
|
69
|
+
/**
|
|
70
|
+
* Create a single database instance within a MariaDB instance.
|
|
71
|
+
*
|
|
72
|
+
* The owner is granted `ALL PRIVILEGES` on the database with `GRANT OPTION`,
|
|
73
|
+
* and its connection details are replicated into the configured namespaces.
|
|
74
|
+
* Additional roles are added afterwards via the returned `addRole()`.
|
|
75
|
+
*
|
|
76
|
+
* @param options - Instance, database name, configuration, and provider
|
|
77
|
+
* @returns The database instance, with `addRole()` bound to it
|
|
78
|
+
* @throws {AnyCloudError} code `INVALID_GRANT` when a role's grant lists no privileges
|
|
79
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_PRIVILEGE` when a role's grant names
|
|
80
|
+
* a privilege a database-scoped MariaDB `GRANT` cannot carry
|
|
81
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `dbName` is blank
|
|
82
|
+
* or `addRole()` is called with a blank name, when `config.sql` is
|
|
83
|
+
* set (MariaDB runs no SQL), when `config.owner` is set to anything but the
|
|
84
|
+
* database name, when `addRole()` is called with the database owner's own
|
|
85
|
+
* name, when `addRole()` is called with a `user`@`host` pair any other
|
|
86
|
+
* database on the same instance has already claimed, when `addRole()` is
|
|
87
|
+
* passed `login: false`, or when it is passed an `engineOptions` block
|
|
88
|
+
* belonging to another engine
|
|
89
|
+
*/
|
|
90
|
+
function createSingleMariadbDatabaseInstance(options) {
|
|
91
|
+
const { clusterName, dbName, config, endpoint, port, mariadb, provider } = options;
|
|
92
|
+
const { roleRegistry } = options;
|
|
93
|
+
(0, role_config_js_1.assertValidDatabaseName)(dbName);
|
|
94
|
+
// Nothing here executes SQL — provisioning is CRs all the way down — so
|
|
95
|
+
// `sql` is refused rather than dropped on the floor.
|
|
96
|
+
(0, database_options_js_1.assertNoSql)(dbName, config, MARIADB_ENGINE_NAME);
|
|
97
|
+
// MariaDB cannot honour `owner`, and rejects it rather than ignoring it.
|
|
98
|
+
//
|
|
99
|
+
// The live `User` and `Grant` CRs carry `ignoreChanges` on `spec.name` /
|
|
100
|
+
// `spec.username` because mariadb-operator's webhook refuses updates to them.
|
|
101
|
+
// `ignoreChanges` suppresses diffs only on resources that already exist, so
|
|
102
|
+
// honouring `owner` would in fact work on a greenfield stack and break only on
|
|
103
|
+
// upgrade: the existing account would stay named after the database while
|
|
104
|
+
// `username` and `uri` flipped in every already-replicated connection Secret,
|
|
105
|
+
// leaving applications authenticating as a user that was never created. An
|
|
106
|
+
// option whose correctness depends on how old the stack is, is worse than one
|
|
107
|
+
// that is refused outright — so this fails at preview, before anything is
|
|
108
|
+
// registered. The owner's username is always the database name.
|
|
109
|
+
if (config.owner !== undefined && config.owner !== dbName) {
|
|
110
|
+
throw new errors_js_1.AnyCloudError(`Database "${dbName}" cannot set owner "${config.owner}" on MariaDB — the owner is ` +
|
|
111
|
+
`always the database name. mariadb-operator treats User.spec.name and ` +
|
|
112
|
+
`Grant.spec.username as immutable, so an owner that differs would rename only the ` +
|
|
113
|
+
`replicated connection Secrets. Remove "owner", or use addRole("${config.owner}") ` +
|
|
114
|
+
`to create it as an additional role.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
|
|
115
|
+
}
|
|
116
|
+
const username = dbName;
|
|
117
|
+
(0, role_config_js_1.assertValidRoleName)(username, dbName);
|
|
118
|
+
// The owner's CRs omit `spec.host` and rely on the operator's own default,
|
|
119
|
+
// which is DEFAULT_GRANT_HOST — so that is the host its account effectively
|
|
120
|
+
// has, and the host it must claim. Claiming it matters because a later
|
|
121
|
+
// addRole() on a *different* database could otherwise take the same pair.
|
|
122
|
+
(0, mariadb_common_js_1.claimMariadbRoleName)(roleRegistry, username, mariadb_common_js_1.DEFAULT_GRANT_HOST, dbName);
|
|
123
|
+
const labels = {
|
|
124
|
+
[MANAGED_BY_LABEL]: MANAGED_BY_VALUE,
|
|
125
|
+
"nimbus/cluster": clusterName,
|
|
126
|
+
"nimbus/database": dbName,
|
|
127
|
+
};
|
|
128
|
+
const ownerNaming = (0, mariadb_roles_js_1.ownerRoleNaming)(clusterName, dbName);
|
|
129
|
+
const ownerConfig = (0, role_config_js_1.resolveRoleConfig)({ namespaces: config.namespaces, login: true });
|
|
130
|
+
// Database CR: owns the database itself. `spec.name` is the raw MariaDB
|
|
131
|
+
// identifier so the CR adopts a database created under that exact name.
|
|
132
|
+
const database = new k8s.apiextensions.CustomResource(`${clusterName}-${dbName}-database`, {
|
|
133
|
+
apiVersion: mariadb_common_js_1.MARIADB_API_VERSION,
|
|
134
|
+
kind: mariadb_common_js_1.DATABASE_KIND,
|
|
135
|
+
metadata: {
|
|
136
|
+
name: `${clusterName}-${dbName}`,
|
|
137
|
+
namespace: mariadb_common_js_1.DATA_NAMESPACE,
|
|
138
|
+
labels,
|
|
139
|
+
},
|
|
140
|
+
spec: {
|
|
141
|
+
mariaDbRef: { name: clusterName },
|
|
142
|
+
name: dbName,
|
|
143
|
+
characterSet: DEFAULT_CHARACTER_SET,
|
|
144
|
+
collate: DEFAULT_COLLATION,
|
|
145
|
+
},
|
|
146
|
+
}, { provider, dependsOn: [mariadb], ignoreChanges: DATABASE_IMMUTABLE_FIELDS });
|
|
147
|
+
// The owner's User and Grant CRs deliberately omit `spec.host`: the live
|
|
148
|
+
// objects were created without it and rely on the operator's own default, so
|
|
149
|
+
// writing it explicitly would diff an immutable field on every existing stack.
|
|
150
|
+
const owner = (0, mariadb_roles_js_1.provisionMariadbRole)({
|
|
151
|
+
clusterName,
|
|
152
|
+
dbName,
|
|
153
|
+
roleName: username,
|
|
154
|
+
naming: ownerNaming,
|
|
155
|
+
grants: [mariadb_roles_js_1.OWNER_GRANT],
|
|
156
|
+
labels,
|
|
157
|
+
mariadb,
|
|
158
|
+
database,
|
|
159
|
+
provider,
|
|
160
|
+
});
|
|
161
|
+
const secrets = (0, mariadb_roles_js_1.replicateMariadbConnectionSecrets)({
|
|
162
|
+
naming: ownerNaming,
|
|
163
|
+
namespaces: ownerConfig.namespaces,
|
|
164
|
+
dbName,
|
|
165
|
+
username,
|
|
166
|
+
password: owner.credentials.stablePassword,
|
|
167
|
+
endpoint,
|
|
168
|
+
port,
|
|
169
|
+
labels,
|
|
170
|
+
provider,
|
|
171
|
+
dependsOn: owner.grants,
|
|
172
|
+
});
|
|
173
|
+
return {
|
|
174
|
+
name: dbName,
|
|
175
|
+
clusterName,
|
|
176
|
+
host: endpoint,
|
|
177
|
+
port,
|
|
178
|
+
database: pulumi.output(dbName),
|
|
179
|
+
secrets,
|
|
180
|
+
nativeResource: database,
|
|
181
|
+
addRole(roleName, roleConfig) {
|
|
182
|
+
(0, role_config_js_1.assertValidRoleName)(roleName, dbName);
|
|
183
|
+
// The owner already has a User CR from createDatabase(). Adding it again
|
|
184
|
+
// would create a SECOND CR for the same MariaDB account, bound to a
|
|
185
|
+
// different password Secret, and the two would then reconcile that
|
|
186
|
+
// account's password against each other indefinitely — leaving the
|
|
187
|
+
// owner's replicated connection Secrets holding a credential that no
|
|
188
|
+
// longer authenticates. The two CRs have different Pulumi logical names,
|
|
189
|
+
// so `pulumi preview` sees no conflict and this fails only in production.
|
|
190
|
+
if (roleName === username) {
|
|
191
|
+
throw new errors_js_1.AnyCloudError(`Role "${roleName}" is the owner of database "${dbName}" and is created by ` +
|
|
192
|
+
`createDatabase(); it cannot be added again. Use a different role name — on ` +
|
|
193
|
+
`MariaDB the owner is always the database name.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
|
|
194
|
+
}
|
|
195
|
+
const resolved = (0, role_config_js_1.resolveRoleConfig)(roleConfig);
|
|
196
|
+
// Every MariaDB account is a login account — `CREATE USER` has no
|
|
197
|
+
// non-login form. Honouring `login: false` by ignoring it would hand back
|
|
198
|
+
// a role that can log in when the caller asked for one that cannot.
|
|
199
|
+
if (!resolved.login) {
|
|
200
|
+
throw new errors_js_1.AnyCloudError(`Role "${roleName}" cannot be created with login: false on MariaDB — every ` +
|
|
201
|
+
`MariaDB user is a login account. Omit "login", or grant no privileges instead.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
|
|
202
|
+
}
|
|
203
|
+
// A `postgresql` block here names an engine that will never run this
|
|
204
|
+
// role, so its memberships, connection cap and expiry would be dropped
|
|
205
|
+
// while the role provisioned as if they had been applied.
|
|
206
|
+
(0, database_options_js_1.assertNoForeignEngineOptions)({
|
|
207
|
+
roleName,
|
|
208
|
+
databaseName: dbName,
|
|
209
|
+
engineOptions: roleConfig?.engineOptions,
|
|
210
|
+
honoured: "mariadb",
|
|
211
|
+
engine: MARIADB_ENGINE_NAME,
|
|
212
|
+
});
|
|
213
|
+
const mariadbOptions = roleConfig?.engineOptions?.mariadb;
|
|
214
|
+
// Resolved once, here, and used for the registry claim, the naming
|
|
215
|
+
// identity, and `spec.host` alike. A configured `""` is not nullish, so it
|
|
216
|
+
// used to reach all three as itself while the CRs — which omitted a falsy
|
|
217
|
+
// host — inherited the operator's `%` default: a second database could
|
|
218
|
+
// then claim `reader`@`%` for what MariaDB sees as the same account. See
|
|
219
|
+
// {@link resolveMariadbHost}.
|
|
220
|
+
const host = (0, mariadb_common_js_1.resolveMariadbHost)(mariadbOptions?.host);
|
|
221
|
+
// Translated before the claim below, not where the CRs are built, because
|
|
222
|
+
// this throws: a privilege MariaDB cannot carry in a database-scoped
|
|
223
|
+
// GRANT is rejected here. Claiming first and translating afterwards left
|
|
224
|
+
// the account claimed for a role that was never provisioned, so a caller
|
|
225
|
+
// who fixed the privilege and retried in the same program run was refused
|
|
226
|
+
// as a duplicate.
|
|
227
|
+
//
|
|
228
|
+
// `grants: []` and an omitted `grants` both come to the same thing on
|
|
229
|
+
// MariaDB: no `Grant` CRs. Removing a grant from config deletes its CR and
|
|
230
|
+
// mariadb-operator issues the `REVOKE`, so the revoke semantics
|
|
231
|
+
// `grants: []` asks for are what the declarative path already gives.
|
|
232
|
+
const grants = (0, mariadb_roles_js_1.toMariadbGrants)(resolved.grants ?? []);
|
|
233
|
+
// Same hazard one scope wider: the check above only sees this database's
|
|
234
|
+
// own owner, while this `user`@`host` pair may already belong to a sibling
|
|
235
|
+
// database on the same instance — the same account, since MariaDB has only
|
|
236
|
+
// one. The registry is what notices. A different host is a different
|
|
237
|
+
// account, and stays allowed.
|
|
238
|
+
//
|
|
239
|
+
// Claimed after every rejecting guard, not before them, so a call they
|
|
240
|
+
// reject leaves no claim behind.
|
|
241
|
+
(0, mariadb_common_js_1.claimMariadbRoleName)(roleRegistry, roleName, host, dbName);
|
|
242
|
+
// Named for the `user`@`host` pair the claim above was made on, not for
|
|
243
|
+
// the username: the registry lets one username exist on two hosts because
|
|
244
|
+
// MariaDB does, and names derived from the username alone would then
|
|
245
|
+
// register the second account under the first's logical names.
|
|
246
|
+
const naming = (0, mariadb_roles_js_1.additionalRoleNaming)(clusterName, dbName, roleName, host);
|
|
247
|
+
const provisioned = (0, mariadb_roles_js_1.provisionMariadbRole)({
|
|
248
|
+
clusterName,
|
|
249
|
+
dbName,
|
|
250
|
+
roleName,
|
|
251
|
+
naming,
|
|
252
|
+
grants,
|
|
253
|
+
host,
|
|
254
|
+
maxUserConnections: mariadbOptions?.maxUserConnections,
|
|
255
|
+
labels,
|
|
256
|
+
mariadb,
|
|
257
|
+
database,
|
|
258
|
+
provider,
|
|
259
|
+
});
|
|
260
|
+
// The connection Secret waits on every Grant CR so a consumer cannot read
|
|
261
|
+
// working credentials, connect, and hit permission errors before the
|
|
262
|
+
// privileges have landed. A role with no grants waits on the User CR.
|
|
263
|
+
const roleSecrets = (0, mariadb_roles_js_1.replicateMariadbConnectionSecrets)({
|
|
264
|
+
naming,
|
|
265
|
+
namespaces: resolved.namespaces,
|
|
266
|
+
dbName,
|
|
267
|
+
username: roleName,
|
|
268
|
+
password: provisioned.credentials.stablePassword,
|
|
269
|
+
endpoint,
|
|
270
|
+
port,
|
|
271
|
+
labels,
|
|
272
|
+
provider,
|
|
273
|
+
dependsOn: provisioned.grants.length > 0 ? provisioned.grants : [database, provisioned.user],
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
name: roleName,
|
|
277
|
+
databaseName: dbName,
|
|
278
|
+
clusterName,
|
|
279
|
+
secrets: roleSecrets,
|
|
280
|
+
nativeResource: provisioned.user,
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=mariadb-database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mariadb-database.js","sourceRoot":"","sources":["../../../src/operator/mariadb-database.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FH,kFAsOC;AAnUD,wDAA0C;AAC1C,uDAAyC;AACzC,2DAO6B;AAC7B,yDAO4B;AAC5B,4DAIiC;AACjC,+DAAgG;AAChG,kDAAgE;AAShE,wEAAwE;AACxE,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,yCAAyC;AACzC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,gEAAgE;AAChE,MAAM,qBAAqB,GAAG,SAAS,CAAC;AACxC,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,2EAA2E;AAC3E,MAAM,yBAAyB,GAAG,CAAC,WAAW,CAAC,CAAC;AAChD,sEAAsE;AACtE,MAAM,mBAAmB,GAAG,kCAAY,CAAC,OAAO,CAAC;AA4BjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,mCAAmC,CACjD,OAAgC;IAEhC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EA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