From a19480ecfd262f5f2975328ad025bda52e33aa79 Mon Sep 17 00:00:00 2001 From: mariobassem Date: Fri, 3 Jan 2025 00:29:37 +0200 Subject: [PATCH] refactor: standardize imports and clean up commented code across modules --- lib/core/herocmds/bootstrap.v | 4 +- lib/core/playcmds/play_mdbook.v | 5 +- lib/core/playcmds/play_threefold.v | 63 ++++++++++--------- lib/installers/infra/zinit/zinit_actions.v | 9 +-- lib/installers/infra/zinit/zinit_factory_.v | 2 +- lib/installers/install_multi.v | 48 +++++++------- lib/installers/net/mycelium/mycelium.v | 7 ++- .../sysadmintools/fungistor/fungistor.v | 1 + .../sysadmintools/grafana/grafana.v | 1 + .../prometheus/alertmanager_installer.v | 1 + .../sysadmintools/prometheus/node_exporter.v | 1 + .../sysadmintools/prometheus/prom2json.v | 1 + lib/installers/threefold/tfrobot/tfrobot.v | 3 +- lib/installers/virt/lima/lima.v | 3 +- lib/installers/virt/podman/podman_actions.v | 5 +- lib/installers/virt/qemu/qemu_install.v | 4 +- lib/installers/web/zola/zola_actions.v | 1 + 17 files changed, 86 insertions(+), 73 deletions(-) diff --git a/lib/core/herocmds/bootstrap.v b/lib/core/herocmds/bootstrap.v index e6f70595..72ad5ff9 100644 --- a/lib/core/herocmds/bootstrap.v +++ b/lib/core/herocmds/bootstrap.v @@ -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 { diff --git a/lib/core/playcmds/play_mdbook.v b/lib/core/playcmds/play_mdbook.v index 8f3227de..a463cf45 100644 --- a/lib/core/playcmds/play_mdbook.v +++ b/lib/core/playcmds/play_mdbook.v @@ -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 diff --git a/lib/core/playcmds/play_threefold.v b/lib/core/playcmds/play_threefold.v index 41c36925..89e215af 100644 --- a/lib/core/playcmds/play_threefold.v +++ b/lib/core/playcmds/play_threefold.v @@ -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 diff --git a/lib/installers/infra/zinit/zinit_actions.v b/lib/installers/infra/zinit/zinit_actions.v index d3574c3f..1b0758cf 100644 --- a/lib/installers/infra/zinit/zinit_actions.v +++ b/lib/installers/infra/zinit/zinit_actions.v @@ -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 diff --git a/lib/installers/infra/zinit/zinit_factory_.v b/lib/installers/infra/zinit/zinit_factory_.v index 6f71996c..49e9cf6b 100644 --- a/lib/installers/infra/zinit/zinit_factory_.v +++ b/lib/installers/infra/zinit/zinit_factory_.v @@ -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 diff --git a/lib/installers/install_multi.v b/lib/installers/install_multi.v index a6300d13..f1fdc192 100644 --- a/lib/installers/install_multi.v +++ b/lib/installers/install_multi.v @@ -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()! diff --git a/lib/installers/net/mycelium/mycelium.v b/lib/installers/net/mycelium/mycelium.v index 007eeea3..a11d8aa2 100644 --- a/lib/installers/net/mycelium/mycelium.v +++ b/lib/installers/net/mycelium/mycelium.v @@ -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') diff --git a/lib/installers/sysadmintools/fungistor/fungistor.v b/lib/installers/sysadmintools/fungistor/fungistor.v index 67b28698..ccaa324a 100644 --- a/lib/installers/sysadmintools/fungistor/fungistor.v +++ b/lib/installers/sysadmintools/fungistor/fungistor.v @@ -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 diff --git a/lib/installers/sysadmintools/grafana/grafana.v b/lib/installers/sysadmintools/grafana/grafana.v index 3d0781db..dc85adc7 100644 --- a/lib/installers/sysadmintools/grafana/grafana.v +++ b/lib/installers/sysadmintools/grafana/grafana.v @@ -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 diff --git a/lib/installers/sysadmintools/prometheus/alertmanager_installer.v b/lib/installers/sysadmintools/prometheus/alertmanager_installer.v index a267662e..cdf7a950 100644 --- a/lib/installers/sysadmintools/prometheus/alertmanager_installer.v +++ b/lib/installers/sysadmintools/prometheus/alertmanager_installer.v @@ -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 diff --git a/lib/installers/sysadmintools/prometheus/node_exporter.v b/lib/installers/sysadmintools/prometheus/node_exporter.v index a409fca3..98f5e486 100644 --- a/lib/installers/sysadmintools/prometheus/node_exporter.v +++ b/lib/installers/sysadmintools/prometheus/node_exporter.v @@ -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 diff --git a/lib/installers/sysadmintools/prometheus/prom2json.v b/lib/installers/sysadmintools/prometheus/prom2json.v index 482e5478..3495462b 100644 --- a/lib/installers/sysadmintools/prometheus/prom2json.v +++ b/lib/installers/sysadmintools/prometheus/prom2json.v @@ -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 diff --git a/lib/installers/threefold/tfrobot/tfrobot.v b/lib/installers/threefold/tfrobot/tfrobot.v index 1fcdf443..68d017a4 100644 --- a/lib/installers/threefold/tfrobot/tfrobot.v +++ b/lib/installers/threefold/tfrobot/tfrobot.v @@ -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_()! } } diff --git a/lib/installers/virt/lima/lima.v b/lib/installers/virt/lima/lima.v index ecf59237..4e4cc725 100644 --- a/lib/installers/virt/lima/lima.v +++ b/lib/installers/virt/lima/lima.v @@ -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()! { diff --git a/lib/installers/virt/podman/podman_actions.v b/lib/installers/virt/podman/podman_actions.v index 61a42da2..28e14f8e 100644 --- a/lib/installers/virt/podman/podman_actions.v +++ b/lib/installers/virt/podman/podman_actions.v @@ -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()! diff --git a/lib/installers/virt/qemu/qemu_install.v b/lib/installers/virt/qemu/qemu_install.v index d44020ec..52766995 100644 --- a/lib/installers/virt/qemu/qemu_install.v +++ b/lib/installers/virt/qemu/qemu_install.v @@ -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 { diff --git a/lib/installers/web/zola/zola_actions.v b/lib/installers/web/zola/zola_actions.v index c9dd2175..71cd422e 100644 --- a/lib/installers/web/zola/zola_actions.v +++ b/lib/installers/web/zola/zola_actions.v @@ -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