Skip to content

Commit

Permalink
fix(postgres): Fix postgresql url
Browse files Browse the repository at this point in the history
  • Loading branch information
syfxlin committed Oct 27, 2024
1 parent a26e98b commit 3b5e93b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/core/mongo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class MongoPlugin implements DepkerPlugin {

const database = name;
const username = name;
const password = generator.generate();
const password = generator.generate(20, true, true, false);

await this.exec(`
use ${database};
Expand Down Expand Up @@ -354,7 +354,7 @@ export class MongoPlugin implements DepkerPlugin {
const config = await this.depker.config.service<MongoServiceConfig>(MongoPlugin.NAME);
if (!config.username || !config.password) {
config.username = "root";
config.password = generator.generate();
config.password = generator.generate(20, true, true, false);
await this.depker.config.service(MongoPlugin.NAME, () => config);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/mysql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class MysqlPlugin implements DepkerPlugin {

const database = name;
const username = name;
const password = generator.generate();
const password = generator.generate(20, true, true, false);

await this.exec([
`DROP USER IF EXISTS ${username}`,
Expand Down Expand Up @@ -341,7 +341,7 @@ export class MysqlPlugin implements DepkerPlugin {
const config = await this.depker.config.service<MysqlServiceConfig>(MysqlPlugin.NAME);
if (!config.username || !config.password) {
config.username = "root";
config.password = generator.generate();
config.password = generator.generate(20, true, true, false);
await this.depker.config.service(MysqlPlugin.NAME, () => config);
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/postgres/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class PostgresPlugin implements DepkerPlugin {
value.PGSQL_NAME = database;
value.PGSQL_USER = username;
value.PGSQL_PASS = password;
value.PGSQL_URL = `postgresql://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}`;
value.PGSQL_URL = `postgres://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}?sslmode=disable`;
return value;
});
}
Expand Down Expand Up @@ -216,7 +216,7 @@ export class PostgresPlugin implements DepkerPlugin {

const database = name;
const username = name;
const password = generator.generate();
const password = generator.generate(20, true, true, false);

await this.exec([
`DROP USER IF EXISTS ${username}`,
Expand Down Expand Up @@ -260,7 +260,7 @@ export class PostgresPlugin implements DepkerPlugin {
value.PGSQL_NAME = name;
value.PGSQL_USER = config.username;
value.PGSQL_PASS = config.password;
value.PGSQL_URL = `postgresql://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}`;
value.PGSQL_URL = `postgres://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}?sslmode=disable`;
return value;
} else if (config.databases?.[name]) {
const value: Record<string, any> = {};
Expand All @@ -269,7 +269,7 @@ export class PostgresPlugin implements DepkerPlugin {
value.PGSQL_NAME = name;
value.PGSQL_USER = config.databases[name].username;
value.PGSQL_PASS = config.databases[name].password;
value.PGSQL_URL = `postgresql://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}`;
value.PGSQL_URL = `postgres://${value.PGSQL_USER}:${value.PGSQL_PASS}@${value.PGSQL_HOST}:${value.PGSQL_PORT}/${value.PGSQL_NAME}?sslmode=disable`;
return value;
} else {
throw new Error(`PostgreSQL database is not configured with name: ${name}`);
Expand Down Expand Up @@ -327,7 +327,7 @@ export class PostgresPlugin implements DepkerPlugin {
const config = await this.depker.config.service<PostgresServiceConfig>(PostgresPlugin.NAME);
if (!config.username || !config.password) {
config.username = "postgres";
config.password = generator.generate();
config.password = generator.generate(20, true, true, false);
await this.depker.config.service(PostgresPlugin.NAME, () => config);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/redis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class RedisPlugin implements DepkerPlugin {
}

const username = name;
const password = generator.generate();
const password = generator.generate(20, true, true, false);
await this.exec(`ACL SETUSER ${username} on allkeys allchannels allcommands >'${password}'`);

config.databases = config.databases ?? {};
Expand Down Expand Up @@ -330,7 +330,7 @@ export class RedisPlugin implements DepkerPlugin {
const config = await this.depker.config.service<RedisServiceConfig>(RedisPlugin.NAME);
if (!config.username || !config.password) {
config.username = "default";
config.password = generator.generate();
config.password = generator.generate(20, true, true, false);
await this.depker.config.service(RedisPlugin.NAME, () => config);
}

Expand Down

0 comments on commit 3b5e93b

Please sign in to comment.