This commit is contained in:
2025-08-16 07:31:32 +02:00
parent 6732928156
commit 27bc172257
15 changed files with 845 additions and 267 deletions

View File

@@ -80,8 +80,6 @@ pub fn (mut self Context) redis() !&redisclient.Redis {
pub fn (mut self Context) save() ! {
jsonargs := json.encode_pretty(self.config)
mut r := self.redis()!
// console.print_debug("save")
// console.print_debug(jsonargs)
r.set('context:config', jsonargs)!
}
@@ -89,8 +87,6 @@ pub fn (mut self Context) save() ! {
pub fn (mut self Context) load() ! {
mut r := self.redis()!
d := r.get('context:config')!
// console.print_debug("load")
// console.print_debug(d)
if d.len > 0 {
self.config = json.decode(ContextConfig, d)!
}
@@ -130,38 +126,37 @@ pub fn (mut self Context) db_config_get() !dbfs.DB {
return dbc.db_get_create(name: 'config', withkeys: true)!
}
pub fn (mut self Context) hero_config_set(cat string, name string, content_ string) ! {
mut content := texttools.dedent(content_)
content = rootpath.shell_expansion(content)
path := '${self.path()!.path}/${cat}/${name}.hero'
mut config_file := pathlib.get_file(path: path,create: true)!
config_file.write(content)!
}
// pub fn (mut self Context) hero_config_set(cat string, name string, content_ string) ! {
// mut content := texttools.dedent(content_)
// content = rootpath.shell_expansion(content)
// path := '${self.path()!.path}/${cat}/${name}.json'
// mut config_file := pathlib.get_file(path: path,create: true)!
// config_file.write(content)!
// }
pub fn (mut self Context) hero_config_delete(cat string, name string) ! {
path := '${self.path()!.path}/${cat}/${name}.hero'
mut config_file := pathlib.get_file(path: path)!
config_file.delete()!
}
// pub fn (mut self Context) hero_config_delete(cat string, name string) ! {
// path := '${self.path()!.path}/${cat}/${name}.json'
// mut config_file := pathlib.get_file(path: path)!
// config_file.delete()!
// }
pub fn (mut self Context) hero_config_exists(cat string, name string) bool {
path := '${os.home_dir()}/hero/context/${self.config.name}/${cat}/${name}.hero'
return os.exists(path)
}
// pub fn (mut self Context) hero_config_exists(cat string, name string) bool {
// path := '${os.home_dir()}/hero/context/${self.config.name}/${cat}/${name}.json'
// return os.exists(path)
// }
pub fn (mut self Context) hero_config_get(cat string, name string) !string {
path := '${self.path()!.path}/${cat}/${name}.hero'
mut config_file := pathlib.get_file(path: path, create: false)!
return config_file.read()!
}
// pub fn (mut self Context) hero_config_get(cat string, name string) !string {
// path := '${self.path()!.path}/${cat}/${name}.json'
// mut config_file := pathlib.get_file(path: path, create: false)!
// return config_file.read()!
// }
pub fn (mut self Context) hero_config_list(cat string) ![]string {
path := '${self.path()!.path}/${cat}/*.hero'
mut config_files := os.ls(path)!
println(config_files)
$dbg;
return config_files
}
// pub fn (mut self Context) hero_config_list(cat string) ![]string {
// path := '${self.path()!.path}/${cat}'
// mut config_files := os.ls(path)!
// config_files = config_files.filter(it.ends_with('.json').map(it.split('.')[0] or {panic("bug")})
// return config_files
// }
pub fn (mut self Context) secret_encrypt(txt string) !string {

View File

@@ -11,6 +11,11 @@ import os
// -------------------------------------------------------------------
fn play_core(mut plbook PlayBook) ! {
if plbook.exists(filter: 'play.')==false && plbook.exists(filter: 'play.')==false && plbook.exists(filter: 'core.')==false{
return
}
// ----------------------------------------------------------------
// 1. Include handling (play include / echo)
// ----------------------------------------------------------------

View File

@@ -11,6 +11,11 @@ import freeflowuniverse.herolib.ui.console // For verbose error reporting
// ---------------------------------------------------------------
fn play_git(mut plbook PlayBook) ! {
if plbook.exists(filter: 'git.')==false{
return
}
mut gs := gittools.new()!
define_actions := plbook.find(filter: 'git.define')!

View File

@@ -5,6 +5,12 @@ import freeflowuniverse.herolib.core.playbook { PlayBook }
// import os
fn play_luadns(mut plbook PlayBook) ! {
if plbook.exists(filter: 'luadns.')==false{
return
}
// Variables below are not used, commenting them out
// mut buildroot := '${os.home_dir()}/hero/var/mdbuild'
// mut publishroot := '${os.home_dir()}/hero/www/info'

View File

@@ -4,6 +4,12 @@ import freeflowuniverse.herolib.osal.sshagent
import freeflowuniverse.herolib.core.playbook { PlayBook }
fn play_ssh(mut plbook PlayBook) ! {
if plbook.exists(filter: 'sshagent.')==false{
return
}
mut agent := sshagent.new()!
for mut action in plbook.find(filter: 'sshagent.*')! {
mut p := action.params