refactor: regenerate tfgrid3deployer client code

This commit is contained in:
2025-01-15 12:57:49 +02:00
parent b87185adb3
commit babb114bcb
2 changed files with 13 additions and 18 deletions

View File

@@ -13,7 +13,7 @@ __global (
@[params]
pub struct ArgsGet {
pub mut:
name string = 'default'
name string
}
fn args_get(args_ ArgsGet) ArgsGet {
@@ -30,16 +30,18 @@ fn args_get(args_ ArgsGet) ArgsGet {
pub fn get(args_ ArgsGet) !&TFGridDeployer {
mut args := args_get(args_)
if args.name !in tfgrid3deployer_global {
if !config_exists() {
if default {
config_save()!
if args.name == 'default' {
if !config_exists(args) {
if default {
config_save(args)!
}
}
config_load(args)!
}
config_load()!
}
return tfgrid3deployer_global[args.name] or {
println(tfgrid3deployer_global)
panic('bug in get from factory: ')
panic('could not get config for tfgrid3deployer with name:${args.name}')
}
}
@@ -64,22 +66,16 @@ fn config_save(args_ ArgsGet) ! {
fn set(o TFGridDeployer) ! {
mut o2 := obj_init(o)!
tfgrid3deployer_global['default'] = &o2
tfgrid3deployer_global[o.name] = &o2
tfgrid3deployer_default = o.name
}
@[params]
pub struct PlayArgs {
pub mut:
name string = 'default'
heroscript string // if filled in then plbook will be made out of it
plbook ?playbook.PlayBook
reset bool
start bool
stop bool
restart bool
delete bool
configure bool // make sure there is at least one installed
}
pub fn play(args_ PlayArgs) ! {
@@ -94,8 +90,7 @@ pub fn play(args_ PlayArgs) ! {
if install_actions.len > 0 {
for install_action in install_actions {
mut p := install_action.params
mycfg := cfg_play(p)!
set(mycfg)!
cfg_play(p)!
}
}
}

View File

@@ -39,7 +39,7 @@ pub mut:
network Network
}
fn cfg_play(p paramsparser.Params) !TFGridDeployer {
fn cfg_play(p paramsparser.Params) ! {
network_str := p.get_default('network', 'main')!
network := match network_str {
'dev' { Network.dev }
@@ -53,7 +53,7 @@ fn cfg_play(p paramsparser.Params) !TFGridDeployer {
mnemonic: p.get_default('mnemonic', '')!
network: network
}
return mycfg
set(mycfg)!
}
fn obj_init(obj_ TFGridDeployer) !TFGridDeployer {