mirror of
https://github.com/morten-olsen/homelab-operator.git
synced 2026-02-08 01:36:28 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddb3c79657 | ||
|
|
47cf43b44e |
@@ -37,8 +37,8 @@ class GenerateSecretResource extends CustomResource<typeof generateSecretSpecSch
|
||||
const current = decodeSecret(this.#secretResource.data) || {};
|
||||
|
||||
const expected = {
|
||||
...current,
|
||||
...secrets,
|
||||
...current,
|
||||
};
|
||||
|
||||
if (!isDeepSubset(current, expected)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ const postgresDatabaseSecretSchema = z.object({
|
||||
port: z.string(),
|
||||
user: z.string(),
|
||||
password: z.string(),
|
||||
database: z.string().optional(),
|
||||
});
|
||||
|
||||
const postgresDatabaseConnectionSecretSchema = z.object({
|
||||
|
||||
@@ -95,6 +95,7 @@ class PostgresDatabaseResource extends CustomResource<typeof postgresDatabaseSpe
|
||||
port: serverSecretData.data.port,
|
||||
user: this.#userName,
|
||||
database: this.#dbName,
|
||||
...databaseSecretData.data,
|
||||
};
|
||||
|
||||
if (!isDeepSubset(databaseSecretData.data, expectedSecret)) {
|
||||
@@ -132,7 +133,7 @@ class PostgresDatabaseResource extends CustomResource<typeof postgresDatabaseSpe
|
||||
};
|
||||
}
|
||||
|
||||
const secretData = postgresDatabaseConnectionSecretSchema.safeParse(decodeSecret(this.#serverSecret.current?.data));
|
||||
const secretData = postgresDatabaseConnectionSecretSchema.safeParse(decodeSecret(this.#databaseSecret.data));
|
||||
if (!secretData.success || !secretData.data) {
|
||||
return {
|
||||
ready: false,
|
||||
@@ -145,6 +146,7 @@ class PostgresDatabaseResource extends CustomResource<typeof postgresDatabaseSpe
|
||||
const database = postgresService.get({
|
||||
...connectionSecretData.data,
|
||||
port: connectionSecretData.data.port ? Number(connectionSecretData.data.port) : 5432,
|
||||
database: connectionSecretData.data.database,
|
||||
});
|
||||
await database.upsertRole({
|
||||
name: secretData.data.user,
|
||||
|
||||
@@ -10,6 +10,7 @@ type PostgresInstanceOptions = {
|
||||
port?: number;
|
||||
user: string;
|
||||
password: string;
|
||||
database?: string;
|
||||
};
|
||||
|
||||
class PostgresInstance {
|
||||
@@ -23,6 +24,7 @@ class PostgresInstance {
|
||||
user: process.env.FORCE_PG_USER ?? options.user,
|
||||
password: process.env.FORCE_PG_PASSWORD ?? options.password,
|
||||
port: process.env.FORCE_PG_PORT ? parseInt(process.env.FORCE_PG_PORT) : options.port,
|
||||
database: options.database,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user