refactor: standardize imports and clean up commented code across modules

This commit is contained in:
2025-01-03 00:29:37 +02:00
parent 4c01c88b85
commit a19480ecfd
17 changed files with 86 additions and 73 deletions

View File

@@ -88,12 +88,12 @@ fn cmd_bootstrap_execute(cmd Command) ! {
} else {
base.install(reset: reset)!
}
base.bash_installers_package()!
// base.bash_installers_package()!
} else {
mut b := builder.new()!
mut n := b.node_new(ipaddr: address)!
if develop {
n.crystal_install(reset: reset)!
// n.crystal_install(reset: reset)!
n.hero_install()!
n.dagu_install()!
} else {

View File

@@ -116,9 +116,8 @@ pub fn play_mdbook(mut plbook playbook.PlayBook) ! {
mut mdbooks := mdbook.get()!
mut cfg := mdbooks.config()!
cfg.path_build = buildroot
cfg.path_publish = publishroot
mdbooks.path_build = buildroot
mdbooks.path_publish = publishroot
mdbooks.generate(
name: name

View File

@@ -1,49 +1,50 @@
module playcmds
import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.threefold.grid
import freeflowuniverse.herolib.threefold.tfrobot
import os
// import freeflowuniverse.herolib.threefold.grid
// import freeflowuniverse.herolib.threefold.tfrobot
// import os
pub fn play_threefold(mut plbook playbook.PlayBook) ! {
mut config_actions := plbook.find(filter: 'threefold.configure')!
panic('fix tfrobot module')
// mut config_actions := plbook.find(filter: 'threefold.configure')!
mnemonics_ := os.getenv_opt('TFGRID_MNEMONIC') or { '' }
mut ssh_key := os.getenv_opt('SSH_KEY') or { '' }
// mnemonics_ := os.getenv_opt('TFGRID_MNEMONIC') or { '' }
// mut ssh_key := os.getenv_opt('SSH_KEY') or { '' }
tfrobot.configure('play', network: 'main', mnemonics: mnemonics_)!
// tfrobot.configure('play', network: 'main', mnemonics: mnemonics_)!
mut robot := tfrobot.get('play')!
// mut robot := tfrobot.get('play')!
if config_actions.len > 1 {
return error('can only have 1 config action for threefold')
} else if config_actions.len == 1 {
mut a := config_actions[0]
mut p := a.params
mut network := p.get_default('network', 'main')!
mnemonics := p.get_default('mnemonics', '')!
ssh_key = p.get_default('ssh_key', '')!
// if config_actions.len > 1 {
// return error('can only have 1 config action for threefold')
// } else if config_actions.len == 1 {
// mut a := config_actions[0]
// mut p := a.params
// mut network := p.get_default('network', 'main')!
// mnemonics := p.get_default('mnemonics', '')!
// ssh_key = p.get_default('ssh_key', '')!
network = network.to_lower()
// network = network.to_lower()
// mnemonics string
// network string = 'main'
tfrobot.configure('play', network: network, mnemonics: mnemonics)!
// // mnemonics string
// // network string = 'main'
// tfrobot.configure('play', network: network, mnemonics: mnemonics)!
robot = tfrobot.get('play')!
// robot = tfrobot.get('play')!
config_actions[0].done = true
}
cfg := robot.config()!
if cfg.mnemonics == '' {
return error('TFGRID_MNEMONIC should be specified as env variable')
}
// config_actions[0].done = true
// }
// cfg := robot.config()!
// if cfg.mnemonics == '' {
// return error('TFGRID_MNEMONIC should be specified as env variable')
// }
if ssh_key == '' {
return error('SSHKey should be specified as env variable')
}
// if ssh_key == '' {
// return error('SSHKey should be specified as env variable')
// }
panic('implement')
// panic('implement')
// for mut action in plbook.find(filter: 'threefold.deploy_vm')! {
// mut p := action.params

View File

@@ -1,6 +1,7 @@
module zinit
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.osal.zinit
@@ -30,7 +31,7 @@ fn installed() !bool {
fn install() ! {
console.print_header('install zinit')
if !osal.is_linux() {
if !core.is_linux()! {
return error('only support linux for now')
}
@@ -53,7 +54,7 @@ fn install() ! {
}
fn build() ! {
if !osal.is_linux() {
if !core.is_linux()! {
return error('only support linux for now')
}
@@ -94,9 +95,9 @@ fn ulist_get() !ulist.UList {
fn upload() ! {
}
fn startupcmd() ![]ZProcessNewArgs {
fn startupcmd() ![]zinit.ZProcessNewArgs {
mut res := []zinit.ZProcessNewArgs{}
res << ZProcessNewArgs{
res << zinit.ZProcessNewArgs{
name: 'zinit'
cmd: '/usr/local/bin/zinit init'
startuptype: .systemd

View File

@@ -28,7 +28,7 @@ pub fn get(args_ ArgsGet) !&Zinit {
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
fn startupmanager_get(cat StartupManagerType) !startupmanager.StartupManager {
fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
// unknown
// screen
// zinit

View File

@@ -3,10 +3,10 @@ module installers
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.installers.develapps.vscode
import freeflowuniverse.herolib.installers.develapps.chrome
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
import freeflowuniverse.herolib.installers.virt.buildah as buildah_installer
// import freeflowuniverse.herolib.installers.virt.podman as podman_installer
// import freeflowuniverse.herolib.installers.virt.buildah as buildah_installer
import freeflowuniverse.herolib.installers.virt.lima
import freeflowuniverse.herolib.installers.net.mycelium
// import freeflowuniverse.herolib.installers.net.mycelium
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.installers.lang.rust
import freeflowuniverse.herolib.installers.lang.golang
@@ -14,15 +14,15 @@ import freeflowuniverse.herolib.installers.lang.vlang
import freeflowuniverse.herolib.installers.lang.herolib
import freeflowuniverse.herolib.installers.lang.nodejs
import freeflowuniverse.herolib.installers.lang.python
import freeflowuniverse.herolib.installers.web.zola
// import freeflowuniverse.herolib.installers.web.zola
import freeflowuniverse.herolib.installers.web.tailwind
// import freeflowuniverse.herolib.installers.hero.heroweb
// import freeflowuniverse.herolib.installers.hero.herodev
import freeflowuniverse.herolib.installers.sysadmintools.daguserver
import freeflowuniverse.herolib.installers.sysadmintools.rclone
import freeflowuniverse.herolib.installers.sysadmintools.prometheus
import freeflowuniverse.herolib.installers.sysadmintools.grafana
import freeflowuniverse.herolib.installers.sysadmintools.fungistor
// import freeflowuniverse.herolib.installers.sysadmintools.prometheus
// import freeflowuniverse.herolib.installers.sysadmintools.grafana
// import freeflowuniverse.herolib.installers.sysadmintools.fungistor
import freeflowuniverse.herolib.installers.sysadmintools.garage_s3
import freeflowuniverse.herolib.installers.infra.zinit
@@ -118,17 +118,17 @@ pub fn install_multi(args_ InstallArgs) ! {
'chrome' {
chrome.install(reset: args.reset, uninstall: args.uninstall)!
}
'mycelium' {
mycelium.install(reset: args.reset)!
mycelium.start()!
}
// 'mycelium' {
// mycelium.install(reset: args.reset)!
// mycelium.start()!
// }
'garage_s3' {
mut garages3 := garage_s3.get()!
garages3.install(reset: args.reset)!
}
'fungistor' {
fungistor.install(reset: args.reset)!
}
// 'fungistor' {
// fungistor.install(reset: args.reset)!
// }
'lima' {
lima.install_(reset: args.reset, uninstall: args.uninstall)!
}
@@ -142,12 +142,12 @@ pub fn install_multi(args_ InstallArgs) ! {
// podman_installer0.install()!
// buildah_installer0.install()!
// }
'prometheus' {
prometheus.install(reset: args.reset)!
}
'grafana' {
grafana.install(reset: args.reset)!
}
// 'prometheus' {
// prometheus.install(reset: args.reset)!
// }
// 'grafana' {
// grafana.install(reset: args.reset)!
// }
'vscode' {
vscode.install(reset: args.reset)!
}
@@ -170,10 +170,10 @@ pub fn install_multi(args_ InstallArgs) ! {
dserver.restart()!
// mut dagucl:=dserver.client()!
}
'zola' {
mut i2 := zola.get()!
i2.install()! // will also install tailwind
}
// 'zola' {
// mut i2 := zola.get()!
// i2.install()! // will also install tailwind
// }
'tailwind' {
mut i := tailwind.get()!
i.install()!

View File

@@ -1,6 +1,7 @@
module mycelium
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.installers.lang.rust
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
@@ -64,9 +65,9 @@ pub fn installss(args_ InstallArgs) ! {
)!
}
if args.restart {
stop()!
}
// if args.restart {
// stop()!
// }
start()!
console.print_debug('install mycelium ok')

View File

@@ -1,6 +1,7 @@
module fungistor
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import os

View File

@@ -1,6 +1,7 @@
module grafana
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib

View File

@@ -1,6 +1,7 @@
module prometheus
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib

View File

@@ -1,6 +1,7 @@
module prometheus
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib

View File

@@ -1,6 +1,7 @@
module prometheus
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core.pathlib

View File

@@ -1,6 +1,7 @@
module tfrobot
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.installers.lang.golang
import freeflowuniverse.herolib.develop.gittools
@@ -34,7 +35,7 @@ pub fn install_(args_ InstallArgs) ! {
if args.reset {
console.print_header('install tfrobot')
build()!
build_()!
}
}

View File

@@ -1,6 +1,7 @@
module lima
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
@@ -51,7 +52,7 @@ pub fn install_(args_ InstallArgs) ! {
if args.reset {
console.print_header('install lima')
qemu.install()!
qemu.install_()!
mut url := ''
mut dest_on_os := '${os.home_dir()}/hero'
if core.is_linux_arm()! {

View File

@@ -1,6 +1,7 @@
module podman
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.installers.lang.golang
@@ -77,8 +78,8 @@ fn build_() ! {
// mut installer := get()!
// https://podman.io/docs/installation#building-from-source
if core.platform() != .ubuntu && core.platform() != .arch {
platform := core.platform()!
if platform != .ubuntu && platform != .arch {
return error('only support ubuntu and arch for now')
}
mut g := golang.get()!

View File

@@ -1,6 +1,7 @@
module qemu
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
@@ -44,7 +45,8 @@ pub fn install_(args_ InstallArgs) ! {
console.print_header('install libvirt & qemu')
base.install()!
if core.platform()! in [.arch, .ubuntu] {
platform := core.platform()!
if platform in [.arch, .ubuntu] {
osal.package_install('qemu,libvirt,qemu-common,qemu-img,qemu-system-arm,qemu-system-x86,qemu-tools,libguestfs')!
osal.exec(cmd: 'systemctl start libvirtd && systemctl enable libvirtd')!
} else {

View File

@@ -1,6 +1,7 @@
module zola
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.installers.base