@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
|
@@ -15,6 +15,135 @@ import type { StorageTier } from "../types/storage-tiers";
|
|
|
15
15
|
import type { IExposedService } from "../types";
|
|
16
16
|
/** Per-environment config overrides. Keys are environment names (e.g. "dev", "prod"). */
|
|
17
17
|
export type EnvironmentOverrides<T> = Record<string, Partial<T>>;
|
|
18
|
+
/**
|
|
19
|
+
* End-of-life policy for a declaratively managed database or role.
|
|
20
|
+
*
|
|
21
|
+
* - `"retain"` — the database/role survives deletion of the Kubernetes resource.
|
|
22
|
+
* - `"delete"` — the operator issues `DROP DATABASE` / `DROP ROLE` on deletion.
|
|
23
|
+
*/
|
|
24
|
+
export type ReclaimPolicy = "retain" | "delete";
|
|
25
|
+
/**
|
|
26
|
+
* A privilege grant on a database, portable across engines that model privileges.
|
|
27
|
+
*
|
|
28
|
+
* @example Read-only access to every current and future table in a schema
|
|
29
|
+
* ```typescript
|
|
30
|
+
* { privileges: ["SELECT"], schema: "marts", objects: "all" }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface IDatabaseGrant {
|
|
34
|
+
/**
|
|
35
|
+
* Privileges to grant (e.g. ["SELECT"], ["SELECT", "INSERT"]).
|
|
36
|
+
*
|
|
37
|
+
* On PostgreSQL a grant that includes `INSERT`, `UPDATE`, or
|
|
38
|
+
* `ALL PRIVILEGES` additionally grants `USAGE, SELECT` on **every current
|
|
39
|
+
* and future sequence in the grant's schema**, because inserting into a
|
|
40
|
+
* `serial`/`identity` column calls `nextval()` on a separate object with its
|
|
41
|
+
* own ACL — without it every such `INSERT` fails with
|
|
42
|
+
* `permission denied for sequence`. The sequence grant is schema-wide even
|
|
43
|
+
* when `objects` names a single table: a sequence's link to its table lives
|
|
44
|
+
* in the catalog, and the compiler emits static SQL. Sequence `UPDATE`
|
|
45
|
+
* (`setval()`) is never granted, and correspondingly never revoked.
|
|
46
|
+
*
|
|
47
|
+
* A read-only grant (`SELECT` alone, `DELETE`, `TRUNCATE`, `REFERENCES`,
|
|
48
|
+
* `TRIGGER`) gets no sequence privileges.
|
|
49
|
+
*/
|
|
50
|
+
readonly privileges: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Schema to scope the grant to. PostgreSQL only; ignored by engines without
|
|
53
|
+
* schemas. MariaDB in particular has no schema concept distinct from the
|
|
54
|
+
* database, so this field is dropped there and the grant applies to the
|
|
55
|
+
* database named by the {@link IDatabaseInstance} it was added to.
|
|
56
|
+
*/
|
|
57
|
+
readonly schema?: string;
|
|
58
|
+
/** A specific object name, or every current and future object when "all". Default: "all". */
|
|
59
|
+
readonly objects?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Configuration for a role created via {@link IDatabaseInstance.addRole}. */
|
|
62
|
+
export interface IDatabaseRoleConfig {
|
|
63
|
+
/** Namespaces to replicate the credential Secret into. */
|
|
64
|
+
readonly namespaces?: string[];
|
|
65
|
+
/** Whether the role can log in. Default: true. */
|
|
66
|
+
readonly login?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Privileges this role holds on the owning database.
|
|
69
|
+
*
|
|
70
|
+
* The field has three states, and the difference between the last two
|
|
71
|
+
* matters:
|
|
72
|
+
*
|
|
73
|
+
* - **omitted** — nimbus does not manage this role's privileges. Nothing is
|
|
74
|
+
* granted and, on CloudNativePG, nothing is revoked: whatever the role
|
|
75
|
+
* holds is left exactly as it is.
|
|
76
|
+
* - **`[]`** — this role should hold *no* privileges. This is a real desired
|
|
77
|
+
* state, not an absence of one: on CloudNativePG the reconciling Job still
|
|
78
|
+
* runs and revokes everything the role holds. Removing the last entry from
|
|
79
|
+
* a role's grants therefore actually takes its access away, rather than
|
|
80
|
+
* freezing it at whatever was granted last.
|
|
81
|
+
* - **a non-empty list** — the role holds exactly these privileges; anything
|
|
82
|
+
* else it held is revoked.
|
|
83
|
+
*
|
|
84
|
+
* On MariaDB the first two states coincide, since privileges live in `Grant`
|
|
85
|
+
* CRs the operator deletes (and revokes) when they leave the config. Neo4j
|
|
86
|
+
* Community has no RBAC at all, so any value — including `[]` — throws.
|
|
87
|
+
*/
|
|
88
|
+
readonly grants?: IDatabaseGrant[];
|
|
89
|
+
/**
|
|
90
|
+
* End-of-life policy for the role. Default: `"retain"`.
|
|
91
|
+
*
|
|
92
|
+
* **CloudNativePG only, and — uniquely among this module's engine-specific
|
|
93
|
+
* options — accepted and ignored elsewhere rather than rejected.** On CNPG it
|
|
94
|
+
* becomes `DatabaseRole.spec.databaseRoleReclaimPolicy`. MariaDB and Neo4j
|
|
95
|
+
* drop it: their role lifecycle is governed by the operator's own default
|
|
96
|
+
* (mariadb-operator's `spec.cleanupPolicy`, left unset) instead.
|
|
97
|
+
*
|
|
98
|
+
* Every other unhonourable option throws `UNSUPPORTED_ROLE_OPTION` at preview.
|
|
99
|
+
* This one cannot, because it is defaulted: `resolveRoleConfig` fills in
|
|
100
|
+
* `"retain"`, so it is always "set" and a guard could not distinguish an
|
|
101
|
+
* explicit value from an omitted one without rejecting every MariaDB and
|
|
102
|
+
* Neo4j role that exists. Adopting `cleanupPolicy` instead would change the
|
|
103
|
+
* deletion semantics of already-running CRs on the next apply. The exemption
|
|
104
|
+
* and its reasoning are recorded at the rule's definition site — see the
|
|
105
|
+
* `operator/database-options` module docblock.
|
|
106
|
+
*/
|
|
107
|
+
readonly reclaimPolicy?: ReclaimPolicy;
|
|
108
|
+
/** Engine-specific options that do not port across engines. */
|
|
109
|
+
readonly engineOptions?: {
|
|
110
|
+
readonly postgresql?: {
|
|
111
|
+
/** Existing roles this role becomes a member of (e.g. ["pg_read_all_data"]). */
|
|
112
|
+
readonly inRoles?: string[];
|
|
113
|
+
/** Maximum concurrent connections. Default: unlimited. */
|
|
114
|
+
readonly connectionLimit?: number;
|
|
115
|
+
/** Timestamp after which the password expires. */
|
|
116
|
+
readonly validUntil?: string;
|
|
117
|
+
};
|
|
118
|
+
readonly mariadb?: {
|
|
119
|
+
/**
|
|
120
|
+
* Host pattern the user may connect from. Default: `"%"`.
|
|
121
|
+
*
|
|
122
|
+
* A blank or whitespace-only pattern resolves to the same `"%"` an
|
|
123
|
+
* omitted one does — that is what the account ends up with either way, so
|
|
124
|
+
* it is also the identity nimbus refuses to hand out twice. Two databases
|
|
125
|
+
* asking for `reader` with and without `host: ""` are asking for one
|
|
126
|
+
* MariaDB account, and the second is rejected at preview.
|
|
127
|
+
*/
|
|
128
|
+
readonly host?: string;
|
|
129
|
+
/** Maximum concurrent connections. Default: 100. */
|
|
130
|
+
readonly maxUserConnections?: number;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** A role provisioned within a database. */
|
|
135
|
+
export interface IDatabaseRole {
|
|
136
|
+
/** Role name as it exists in the database engine. */
|
|
137
|
+
readonly name: string;
|
|
138
|
+
/** Database this role was created for. */
|
|
139
|
+
readonly databaseName: string;
|
|
140
|
+
/** Cluster the database belongs to. */
|
|
141
|
+
readonly clusterName: string;
|
|
142
|
+
/** Secrets created in target namespaces (namespace → secret name). */
|
|
143
|
+
readonly secrets: Record<string, pulumi.Output<string>>;
|
|
144
|
+
/** Underlying Pulumi resource for dependency wiring. */
|
|
145
|
+
readonly nativeResource: pulumi.Resource;
|
|
146
|
+
}
|
|
18
147
|
/** Supported Kubernetes database operators. */
|
|
19
148
|
export type OperatorType = "cloudnative-pg" | "mariadb-operator" | "minio" | "neo4j";
|
|
20
149
|
/** Typed constant map for OperatorType string literals. */
|
|
@@ -77,6 +206,17 @@ export interface IOperatorClusterConfig {
|
|
|
77
206
|
readonly parameters?: Record<string, string>;
|
|
78
207
|
/** Resource tags (applied as labels). */
|
|
79
208
|
readonly tags?: Record<string, string>;
|
|
209
|
+
/**
|
|
210
|
+
* Expose a network-reachable superuser and publish its credentials Secret
|
|
211
|
+
* (CloudNativePG only). Default: false.
|
|
212
|
+
*
|
|
213
|
+
* Databases and roles are provisioned through the operator's own `Database`
|
|
214
|
+
* and `DatabaseRole` CRDs, which run inside the instance manager and do not
|
|
215
|
+
* need this. Enable it only when something outside nimbus must connect as
|
|
216
|
+
* `postgres` — turning it off makes CNPG set the superuser password to NULL
|
|
217
|
+
* and delete the `{cluster}-superuser` Secret.
|
|
218
|
+
*/
|
|
219
|
+
readonly superuserAccess?: boolean;
|
|
80
220
|
/** When set, creates separate clusters per environment with {name}-{env} naming. Per-env values override base config. */
|
|
81
221
|
readonly environments?: EnvironmentOverrides<Omit<IOperatorClusterConfig, "environments">>;
|
|
82
222
|
}
|
|
@@ -84,8 +224,62 @@ export interface IOperatorClusterConfig {
|
|
|
84
224
|
export interface IOperatorDatabaseConfig {
|
|
85
225
|
/** Namespaces to replicate the connection secret into. */
|
|
86
226
|
readonly namespaces: string[];
|
|
87
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Database owner/username. Default: same as database name.
|
|
229
|
+
*
|
|
230
|
+
* Honoured by CloudNativePG and Neo4j. **Rejected by MariaDB** unless it
|
|
231
|
+
* equals the database name: mariadb-operator treats `User.spec.name` and
|
|
232
|
+
* `Grant.spec.username` as immutable, so on an existing database honouring it
|
|
233
|
+
* would rename only the replicated connection Secrets and leave applications
|
|
234
|
+
* authenticating as an account that was never created. Use `addRole()` to
|
|
235
|
+
* create additional MariaDB accounts.
|
|
236
|
+
*/
|
|
88
237
|
readonly owner?: string;
|
|
238
|
+
/**
|
|
239
|
+
* What happens to the PostgreSQL database and its owning role when the
|
|
240
|
+
* Kubernetes resources are deleted (CloudNativePG only). Default: `"retain"`.
|
|
241
|
+
*
|
|
242
|
+
* `"retain"` keeps the data, so removing a database from config — or renaming
|
|
243
|
+
* the Pulumi resource — is never destructive. Set `"delete"` only for
|
|
244
|
+
* databases whose lifecycle should genuinely track the config.
|
|
245
|
+
*
|
|
246
|
+
* **On MariaDB and Neo4j this is accepted and ignored, not rejected** — the
|
|
247
|
+
* single deliberate exception to the rule that an option which cannot be
|
|
248
|
+
* honoured throws `UNSUPPORTED_ROLE_OPTION` at preview. It is exempt because
|
|
249
|
+
* it is defaulted (so it is always "set" and no guard could tell an explicit
|
|
250
|
+
* value from an omitted one), because only CloudNativePG consumes it, and
|
|
251
|
+
* because adopting mariadb-operator's `spec.cleanupPolicy` would silently
|
|
252
|
+
* change the deletion semantics of CRs that already exist. There, the
|
|
253
|
+
* database's lifecycle follows the operator's own default instead. See the
|
|
254
|
+
* `operator/database-options` module docblock for the full reasoning.
|
|
255
|
+
*/
|
|
256
|
+
readonly reclaimPolicy?: ReclaimPolicy;
|
|
257
|
+
/**
|
|
258
|
+
* Raw SQL applied to the database as its owner, after the database and owner
|
|
259
|
+
* role exist. Intended for one-off setup a CRD cannot express, such as
|
|
260
|
+
* `CREATE EXTENSION IF NOT EXISTS ...` or seeding a schema.
|
|
261
|
+
*
|
|
262
|
+
* **CloudNativePG only.** It rides along in the same owner-authenticated
|
|
263
|
+
* `psql` Job that reconciles grants; MariaDB (CRs only) and Neo4j (Cypher)
|
|
264
|
+
* have no equivalent path, so both **throw** `UNSUPPORTED_ROLE_OPTION` when
|
|
265
|
+
* this is set rather than accepting statements that would never run.
|
|
266
|
+
*
|
|
267
|
+
* Statements MUST be idempotent — the Job re-runs whenever the content
|
|
268
|
+
* checksum changes, and may be re-applied to a database that already has the
|
|
269
|
+
* result of a previous run.
|
|
270
|
+
*
|
|
271
|
+
* They also run inside the surrounding transaction the applying script opens,
|
|
272
|
+
* not in one of their own, so they must be transaction-safe: statements
|
|
273
|
+
* PostgreSQL refuses inside a transaction block (`CREATE INDEX CONCURRENTLY`,
|
|
274
|
+
* `VACUUM`) will error, and a stray `COMMIT;` closes the transaction early and
|
|
275
|
+
* leaves the script's own trailing `COMMIT;` failing outside any transaction.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* sql: ["CREATE EXTENSION IF NOT EXISTS pgcrypto;"]
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
readonly sql?: string[];
|
|
89
283
|
/** When set, creates separate databases per environment with {dbName}-{env} naming. Per-env values override base config. */
|
|
90
284
|
readonly environments?: EnvironmentOverrides<Omit<IOperatorDatabaseConfig, "environments">>;
|
|
91
285
|
}
|
|
@@ -105,6 +299,34 @@ export interface IDatabaseInstance {
|
|
|
105
299
|
readonly secrets: Record<string, pulumi.Output<string>>;
|
|
106
300
|
/** Underlying Pulumi resource for dependency wiring. */
|
|
107
301
|
readonly nativeResource: pulumi.Resource;
|
|
302
|
+
/**
|
|
303
|
+
* Create an additional role/user on this database with a generated password,
|
|
304
|
+
* replicating a connection Secret into the given namespaces.
|
|
305
|
+
*
|
|
306
|
+
* Implemented by every backend — CloudNativePG, MariaDB, and Neo4j — though
|
|
307
|
+
* not by the same mechanism: CNPG and MariaDB reconcile the account through a
|
|
308
|
+
* CRD, while Neo4j (which has no operator) creates it with a one-shot
|
|
309
|
+
* `cypher-shell` Job. The API is uniform; the guarantees behind it are not.
|
|
310
|
+
*
|
|
311
|
+
* `grants` are reconciled, not merely applied: every privilege the role holds
|
|
312
|
+
* is revoked before the requested grants are re-applied, so removing a grant
|
|
313
|
+
* from config actually removes it — including the last one, since
|
|
314
|
+
* `grants: []` means "hold nothing" rather than "manage nothing" (see
|
|
315
|
+
* {@link IDatabaseRoleConfig.grants}). The database owner is exempt and
|
|
316
|
+
* cannot be passed here at all — an owner's rights over its own objects are
|
|
317
|
+
* ordinary ACL entries, so revoking them would strip the owner's access to
|
|
318
|
+
* the very tables it owns. The owner's role is created by `createDatabase()`.
|
|
319
|
+
*
|
|
320
|
+
* @param name - Role name as it will exist in the database engine
|
|
321
|
+
* @param config - Namespaces, login flag, grants, and engine-specific options
|
|
322
|
+
* @returns The provisioned role with its replicated Secret references
|
|
323
|
+
* @throws {AnyCloudError} with code `UNSUPPORTED_ROLE_OPTION` when `grants` is
|
|
324
|
+
* passed to an engine that cannot express privileges (Neo4j Community),
|
|
325
|
+
* when `login: false` is passed to an engine whose every account is a login
|
|
326
|
+
* account (MariaDB, Neo4j), or when `name` is the database owner's own role
|
|
327
|
+
* name.
|
|
328
|
+
*/
|
|
329
|
+
addRole(name: string, config?: IDatabaseRoleConfig): IDatabaseRole;
|
|
108
330
|
}
|
|
109
331
|
/** A database cluster instance created by an operator. */
|
|
110
332
|
export interface IClusterInstance {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/operator/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;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AAG,YAAY,CAAC;CACvE;AAED,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;IAC1C;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,sBAAsB,GAAG,gBAAgB,CAAC;IAC/E,2FAA2F;IAC3F,aAAa,CACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC,GACtF,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/operator/interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/operator/interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAoJH,2DAA2D;AAC9C,QAAA,cAAc,GAAG;IAC5B,cAAc,EAAE,gBAAyB;IACzC,gBAAgB,EAAE,kBAA2B;IAC7C,KAAK,EAAE,OAAgB;IACvB,KAAK,EAAE,OAAgB;CACe,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants and naming helpers shared by the MariaDB Operator modules.
|
|
3
|
+
*
|
|
4
|
+
* They live here rather than in any one module because `mariadb.ts` (the
|
|
5
|
+
* MariaDB instance), `mariadb-roles.ts` (users, grants, and credentials), and
|
|
6
|
+
* `mariadb-database.ts` (databases) all need them and none of them owns them.
|
|
7
|
+
*
|
|
8
|
+
* @module operator/mariadb-common
|
|
9
|
+
*/
|
|
10
|
+
import { type IRoleRegistry } from "./role-registry.js";
|
|
11
|
+
/** Namespace every MariaDB instance, database, and credential Secret is created in. */
|
|
12
|
+
export declare const DATA_NAMESPACE = "data";
|
|
13
|
+
/** API group and version of every mariadb-operator custom resource. */
|
|
14
|
+
export declare const MARIADB_API_VERSION = "k8s.mariadb.com/v1alpha1";
|
|
15
|
+
/** Kind of the custom resource that owns a MariaDB instance. */
|
|
16
|
+
export declare const MARIADB_KIND = "MariaDB";
|
|
17
|
+
/** Kind of the custom resource that owns a database. */
|
|
18
|
+
export declare const DATABASE_KIND = "Database";
|
|
19
|
+
/** Kind of the custom resource that owns a login account. */
|
|
20
|
+
export declare const USER_KIND = "User";
|
|
21
|
+
/** Kind of the custom resource that owns a privilege grant. */
|
|
22
|
+
export declare const GRANT_KIND = "Grant";
|
|
23
|
+
/** Kind of the custom resource that owns a scheduled backup. */
|
|
24
|
+
export declare const BACKUP_KIND = "Backup";
|
|
25
|
+
/** Host pattern a user may connect from when none is configured. */
|
|
26
|
+
export declare const DEFAULT_GRANT_HOST = "%";
|
|
27
|
+
/** Concurrent connection cap applied to every provisioned user. */
|
|
28
|
+
export declare const DEFAULT_MAX_USER_CONNECTIONS = 100;
|
|
29
|
+
/** `spec.table` value covering every table in the database. */
|
|
30
|
+
export declare const ALL_TABLES = "*";
|
|
31
|
+
/** `IDatabaseGrant.objects` value meaning "every object", not a literal name. */
|
|
32
|
+
export declare const ALL_OBJECTS = "all";
|
|
33
|
+
/** Privilege set granted to a database's owner. */
|
|
34
|
+
export declare const ALL_PRIVILEGES = "ALL PRIVILEGES";
|
|
35
|
+
/**
|
|
36
|
+
* Create the role-identity registry for one MariaDB instance.
|
|
37
|
+
*
|
|
38
|
+
* @param clusterName - MariaDB instance the registry covers
|
|
39
|
+
* @returns A registry that rejects a `user`@`host` pair claimed twice on this instance
|
|
40
|
+
*/
|
|
41
|
+
export declare function createMariadbRoleRegistry(clusterName: string): IRoleRegistry;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a configured host pattern to the value the account will actually have.
|
|
44
|
+
*
|
|
45
|
+
* There is exactly one effective host for any configuration, and everything that
|
|
46
|
+
* identifies the account has to agree on it: the registry key that refuses a
|
|
47
|
+
* duplicate `user`@`host`, the Pulumi logical names derived from that pair, and
|
|
48
|
+
* the `spec.host` written into the `User` and `Grant` CRs. A configured `""`
|
|
49
|
+
* used to survive `?? DEFAULT_GRANT_HOST` — the empty string is not nullish — so
|
|
50
|
+
* it was registered and named as the distinct identity `reader`@`""` while the
|
|
51
|
+
* CRs omitted the field and inherited the operator's own `%` default. Two
|
|
52
|
+
* databases could then claim what MariaDB sees as one account, each pointing it
|
|
53
|
+
* at a different generated password Secret, which is the exact collision the
|
|
54
|
+
* registry exists to prevent.
|
|
55
|
+
*
|
|
56
|
+
* Whitespace-only patterns resolve the same way, and a surrounding-whitespace
|
|
57
|
+
* pattern is trimmed, so `" 10.0.0.1 "` and `"10.0.0.1"` cannot be claimed as
|
|
58
|
+
* two accounts either.
|
|
59
|
+
*
|
|
60
|
+
* @param host - Host pattern as configured, if any
|
|
61
|
+
* @returns The host the account is effectively reachable from, never blank
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* resolveMariadbHost(undefined); // "%"
|
|
66
|
+
* resolveMariadbHost(""); // "%"
|
|
67
|
+
* resolveMariadbHost(" 10.0.0.1 "); // "10.0.0.1"
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveMariadbHost(host: string | undefined): string;
|
|
71
|
+
/**
|
|
72
|
+
* Claim a MariaDB account on an instance.
|
|
73
|
+
*
|
|
74
|
+
* The claim is keyed on the username **and** the host, because that pair is what
|
|
75
|
+
* MariaDB treats as one account: `reader`@`%` and `reader`@`10.0.0.1` are two
|
|
76
|
+
* separate accounts with separate passwords, so both must be allowed.
|
|
77
|
+
*
|
|
78
|
+
* @param registry - The instance's registry
|
|
79
|
+
* @param roleName - Username as it will exist in MariaDB
|
|
80
|
+
* @param host - Effective host pattern, as returned by {@link resolveMariadbHost}
|
|
81
|
+
* @param dbName - Database whose configuration is claiming it
|
|
82
|
+
* @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when the pair is taken
|
|
83
|
+
*/
|
|
84
|
+
export declare function claimMariadbRoleName(registry: IRoleRegistry, roleName: string, host: string, dbName: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Normalize a string into a DNS-1123 subdomain usable as `metadata.name`.
|
|
87
|
+
*
|
|
88
|
+
* Only the Kubernetes object name is sanitized — the MariaDB identifiers in
|
|
89
|
+
* `spec.name` / `spec.username` are passed through verbatim so that CRs adopt
|
|
90
|
+
* databases and users that already exist under their original names.
|
|
91
|
+
*
|
|
92
|
+
* Sanitizing is lossy, so this is not safe for anything that has to identify a
|
|
93
|
+
* resource: see {@link toIdentitySegment}.
|
|
94
|
+
*
|
|
95
|
+
* @param value - Raw name
|
|
96
|
+
* @returns A lowercase, `-`-separated name safe for `metadata.name`
|
|
97
|
+
*/
|
|
98
|
+
export declare function toResourceName(value: string): string;
|
|
99
|
+
//# sourceMappingURL=mariadb-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mariadb-common.d.ts","sourceRoot":"","sources":["../../../src/operator/mariadb-common.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG5E,uFAAuF;AACvF,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,gEAAgE;AAChE,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,wDAAwD;AACxD,eAAO,MAAM,aAAa,aAAa,CAAC;AAExC,6DAA6D;AAC7D,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,+DAA+D;AAC/D,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,gEAAgE;AAChE,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAKtC,mEAAmE;AACnE,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD,+DAA+D;AAC/D,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,iFAAiF;AACjF,eAAO,MAAM,WAAW,QAAQ,CAAC;AAEjC,mDAAmD;AACnD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAe/C;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAM5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,IAAI,CASN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -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,uFAAuF;AAC1E,QAAA,cAAc,GAAG,MAAM,CAAC;AAErC,uEAAuE;AAC1D,QAAA,mBAAmB,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;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"}
|