- Added a Buildah installer to the project. - The installer can install and remove Buildah. - Updated the installer to use the latest Buildah version. Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com> Co-authored-by: mariobassem <mariobassem12@gmail.com>
75 lines
1.6 KiB
V
75 lines
1.6 KiB
V
module buildah
|
|
|
|
import freeflowuniverse.herolib.core.base
|
|
import freeflowuniverse.herolib.core.playbook
|
|
import freeflowuniverse.herolib.ui.console
|
|
import freeflowuniverse.herolib.sysadmin.startupmanager
|
|
import freeflowuniverse.herolib.osal.zinit
|
|
import time
|
|
|
|
__global (
|
|
buildah_global map[string]&BuildahInstaller
|
|
buildah_default string
|
|
)
|
|
|
|
/////////FACTORY
|
|
|
|
@[params]
|
|
pub struct ArgsGet {
|
|
pub mut:
|
|
name string
|
|
}
|
|
|
|
pub fn get(args_ ArgsGet) !&BuildahInstaller {
|
|
return &BuildahInstaller{}
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
|
|
// unknown
|
|
// screen
|
|
// zinit
|
|
// tmux
|
|
// systemd
|
|
match cat {
|
|
.zinit {
|
|
console.print_debug('startupmanager: zinit')
|
|
return startupmanager.get(cat: .zinit)!
|
|
}
|
|
.systemd {
|
|
console.print_debug('startupmanager: systemd')
|
|
return startupmanager.get(cat: .systemd)!
|
|
}
|
|
else {
|
|
console.print_debug('startupmanager: auto')
|
|
return startupmanager.get()!
|
|
}
|
|
}
|
|
}
|
|
|
|
@[params]
|
|
pub struct InstallArgs {
|
|
pub mut:
|
|
reset bool
|
|
}
|
|
|
|
pub fn (mut self BuildahInstaller) install(args InstallArgs) ! {
|
|
switch(self.name)
|
|
if args.reset || (!installed()!) {
|
|
install()!
|
|
}
|
|
}
|
|
|
|
pub fn (mut self BuildahInstaller) destroy() ! {
|
|
switch(self.name)
|
|
destroy()!
|
|
}
|
|
|
|
// switch instance to be used for buildah
|
|
pub fn switch(name string) {
|
|
buildah_default = name
|
|
}
|