refactor: Update PostgreSQL installer
- Updated PostgreSQL installer to use volume path instead of server path. - Updated connection string to include user, password, host, and port. - Updated import statements to use herolib instead of crystallib. - Updated readme files to reflect changes. Co-authored-by: mariobeh <mariobassem12@gmail.com>
This commit is contained in:
@@ -8,15 +8,15 @@ import os
|
||||
import net
|
||||
|
||||
pub fn (mut server Postgresql) path_config() !pathlib.Path {
|
||||
return pathlib.get_dir(path: '${server.path}/config', create: true)!
|
||||
return pathlib.get_dir(path: '${server.volume_path}/config', create: true)!
|
||||
}
|
||||
|
||||
pub fn (mut server Postgresql) path_data() !pathlib.Path {
|
||||
return pathlib.get_dir(path: '${server.path}/data', create: true)!
|
||||
return pathlib.get_dir(path: '${server.volume_path}/data', create: true)!
|
||||
}
|
||||
|
||||
pub fn (mut server Postgresql) path_export() !pathlib.Path {
|
||||
return pathlib.get_dir(path: '${server.path}/exports', create: true)!
|
||||
return pathlib.get_dir(path: '${server.volume_path}/exports', create: true)!
|
||||
}
|
||||
|
||||
fn is_port_open(host string, port int) bool {
|
||||
@@ -30,7 +30,7 @@ pub fn (mut server Postgresql) db() !pg.DB {
|
||||
return error('PostgreSQL is not listening on port 5432')
|
||||
}
|
||||
|
||||
conn_string := 'postgresql://root:${server.passwd}@localhost:5432/postgres?connect_timeout=5'
|
||||
conn_string := 'postgresql://${server.user}:${server.password}@${server.host}:${server.port}/postgres?connect_timeout=5'
|
||||
mut db := pg.connect_with_conninfo(conn_string)!
|
||||
// console.print_header("Database connected: ${db}")
|
||||
return db
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module postgresql
|
||||
|
||||
import freeflowuniverse.crystallib.data.paramsparser
|
||||
import os
|
||||
import freeflowuniverse.herolib.data.paramsparser
|
||||
|
||||
pub const version = '1.14.3'
|
||||
const singleton = true
|
||||
@@ -22,18 +21,19 @@ pub fn heroscript_default() !string {
|
||||
|
||||
pub struct Postgresql {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
user string = 'postgres'
|
||||
password string = 'postgres'
|
||||
host string = 'localhost'
|
||||
volume_path string = '/var/lib/postgresql/data'
|
||||
port int = 5432
|
||||
name string = 'default'
|
||||
user string = 'postgres'
|
||||
password string = 'postgres'
|
||||
host string = 'localhost'
|
||||
volume_path string = '/var/lib/postgresql/data'
|
||||
port int = 5432
|
||||
container_id string
|
||||
}
|
||||
|
||||
fn cfg_play(p paramsparser.Params) !Postgresql {
|
||||
mut mycfg := Postgresql{
|
||||
name: p.get_default('name', 'default')!
|
||||
username: p.get_default('user', 'postgres')!
|
||||
user: p.get_default('user', 'postgres')!
|
||||
password: p.get_default('password', 'postgres')!
|
||||
host: p.get_default('host', 'localhost')!
|
||||
port: p.get_int_default('port', 5432)!
|
||||
|
||||
@@ -8,7 +8,7 @@ To get started
|
||||
|
||||
|
||||
|
||||
import freeflowuniverse.crystallib.installers.something. postgresql
|
||||
import freeflowuniverse.herolib.installers.something. postgresql
|
||||
|
||||
mut installer:= postgresql.get()!
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ To get started
|
||||
|
||||
|
||||
|
||||
import freeflowuniverse.crystallib.installers.something. gitea
|
||||
import freeflowuniverse.herolib.installers.something. gitea
|
||||
|
||||
mut installer:= gitea.get()!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user