refactor: streamline container setup and dependencies
- Remove `xz-utils` from initial package install - Remove password/secret check in `obj_init` - Add on-demand `crun` installation during container create - Import `herorunner_installer` for `crun` setup
This commit is contained in:
@@ -23,9 +23,7 @@ fn upload() ! {
|
||||
|
||||
fn install() ! {
|
||||
console.print_header('install herorunner')
|
||||
osal.package_install('
|
||||
xz-utils
|
||||
crun')!
|
||||
osal.package_install('crun')!
|
||||
|
||||
// osal.exec(
|
||||
// cmd: '
|
||||
|
||||
@@ -18,9 +18,6 @@ pub mut:
|
||||
// your checking & initialization code if needed
|
||||
fn obj_init(mycfg_ HeroRunner) !HeroRunner {
|
||||
mut mycfg := mycfg_
|
||||
if mycfg.password == '' && mycfg.secret == '' {
|
||||
return error('password or secret needs to be filled in for ${mycfg.name}')
|
||||
}
|
||||
return mycfg
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.osal.core as osal
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.installers.virt.herorunner as herorunner_installer
|
||||
import os
|
||||
|
||||
// Updated enum to be more flexible
|
||||
@@ -73,6 +74,12 @@ pub fn (mut self ContainerFactory) new(args ContainerNewArgs) !&Container {
|
||||
// Create container config
|
||||
self.create_container_config(args.name, rootfs_path)!
|
||||
|
||||
// Install crun if not installed
|
||||
if !osal.cmd_exists('crun') {
|
||||
mut herorunner := herorunner_installer.new()!
|
||||
herorunner.install()!
|
||||
}
|
||||
|
||||
// Create container using crun
|
||||
osal.exec(
|
||||
cmd: 'crun create --bundle ${self.base_dir}/configs/${args.name} ${args.name}'
|
||||
|
||||
Reference in New Issue
Block a user