refactor: remove unused imports
- Remove unused imports from postgresql and podman modules. Co-authored-by: mariobassem <mariobassem12@gmail.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
module postgresql
|
||||
|
||||
// import freeflowuniverse.herolib.osal
|
||||
// import freeflowuniverse.herolib.ui.console
|
||||
// import freeflowuniverse.herolib.installers.virt.docker
|
||||
|
||||
// pub fn requirements() ! {
|
||||
// if !osal.done_exists('postgres_install') {
|
||||
// panic('to implement, check is ubuntu and then install, for now only ubuntu')
|
||||
// osal.package_install('libpq-dev,postgresql-client')!
|
||||
// osal.done_set('postgres_install', 'OK')!
|
||||
// console.print_header('postgresql installed')
|
||||
// } else {
|
||||
// console.print_header('postgresql already installed')
|
||||
// }
|
||||
// }
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
```bash
|
||||
brew install postgresql
|
||||
brew services start postgresql
|
||||
psql postgres -c "CREATE ROLE postgres WITH LOGIN SUPERUSER PASSWORD 'mypasswd';"
|
||||
psql -U postgres
|
||||
```
|
||||
|
||||
@@ -2,7 +2,6 @@ module postgresql
|
||||
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
|
||||
@@ -20,16 +19,15 @@ fn install_() ! {
|
||||
fn startupcmd() ![]zinit.ZProcessNewArgs {
|
||||
mut cfg := get()!
|
||||
mut res := []zinit.ZProcessNewArgs{}
|
||||
db_user := 'root'
|
||||
cmd := "
|
||||
mkdir -p ${cfg.path}
|
||||
podman run --name ${cfg.name} -e POSTGRES_USER=${db_user} -e POSTGRES_PASSWORD=\"${cfg.passwd}\" -v ${cfg.path}:/var/lib/postgresql/data -p 5432:5432 --health-cmd=\"pg_isready -U ${db_user}\" postgres:latest
|
||||
mkdir -p ${cfg.volume_path}
|
||||
podman run --name ${cfg.name} -e POSTGRES_USER=${cfg.user} -e POSTGRES_PASSWORD=\"${cfg.password}\" -v ${cfg.volume_path}:/var/lib/postgresql/data -p ${cfg.port}:5432 --health-cmd=\"pg_isready -U ${cfg.user}\" postgres:latest
|
||||
"
|
||||
|
||||
res << zinit.ZProcessNewArgs{
|
||||
name: 'postgresql'
|
||||
cmd: cmd
|
||||
workdir: cfg.path
|
||||
workdir: cfg.volume_path
|
||||
startuptype: .zinit
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -1,63 +1,50 @@
|
||||
module postgresql
|
||||
|
||||
import freeflowuniverse.herolib.data.paramsparser
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.crystallib.data.paramsparser
|
||||
import os
|
||||
|
||||
pub const version = '0.0.0'
|
||||
pub const version = '1.14.3'
|
||||
const singleton = true
|
||||
const default = true
|
||||
|
||||
pub fn heroscript_default() !string {
|
||||
heroscript := "
|
||||
!!postgresql.configure
|
||||
name:'default'
|
||||
passwd:'mysecret'
|
||||
path:''
|
||||
name:'postgresql'
|
||||
user: 'postgres'
|
||||
password: 'postgres'
|
||||
host: 'localhost'
|
||||
port: 5432
|
||||
volume_path:'/var/lib/postgresql/data'
|
||||
"
|
||||
return heroscript
|
||||
}
|
||||
|
||||
pub struct Postgresql {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
path string
|
||||
passwd string
|
||||
container_id string
|
||||
name string = 'default'
|
||||
user string = 'postgres'
|
||||
password string = 'postgres'
|
||||
host string = 'localhost'
|
||||
volume_path string = '/var/lib/postgresql/data'
|
||||
port int = 5432
|
||||
}
|
||||
|
||||
fn cfg_play(p paramsparser.Params) !Postgresql {
|
||||
mut mycfg := Postgresql{
|
||||
name: p.get_default('name', 'default')!
|
||||
passwd: p.get('passwd')!
|
||||
path: p.get_default('path', '')!
|
||||
name: p.get_default('name', 'default')!
|
||||
username: p.get_default('user', 'postgres')!
|
||||
password: p.get_default('password', 'postgres')!
|
||||
host: p.get_default('host', 'localhost')!
|
||||
port: p.get_int_default('port', 5432)!
|
||||
volume_path: p.get_default('path', '/var/lib/postgresql/data')!
|
||||
}
|
||||
return mycfg
|
||||
}
|
||||
|
||||
fn obj_init(obj_ Postgresql) !Postgresql {
|
||||
mut obj := obj_
|
||||
if obj.path == '' {
|
||||
if core.is_linux()! {
|
||||
obj.path = '/data/postgresql/${obj.name}'
|
||||
} else {
|
||||
obj.path = '${os.home_dir()}/hero/var/postgresql/${obj.name}'
|
||||
}
|
||||
}
|
||||
osal.dir_ensure(obj.path)!
|
||||
return obj
|
||||
}
|
||||
|
||||
// called before start if done
|
||||
fn configure() ! {
|
||||
// t2 := $tmpl('templates/pg_hba.conf')
|
||||
// mut p2 := server.path_config.file_get_new('pg_hba.conf')!
|
||||
// p2.write(t2)!
|
||||
|
||||
// mut t3 := $tmpl('templates/postgresql.conf')
|
||||
// t3 = t3.replace('@@', '$') // to fix templating issues
|
||||
// mut p3 := server.path_config.file_get_new('postgresql.conf')!
|
||||
// p3.write(t3)!
|
||||
}
|
||||
fn configure() ! {}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
module podman
|
||||
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.sysadmin.startupmanager
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import time
|
||||
|
||||
__global (
|
||||
podman_global map[string]&PodmanInstaller
|
||||
|
||||
Reference in New Issue
Block a user