prvng_core/nulib/taskservs/create.nu
Jesús Pérez 316622a78f
merge(refactor/lazy-loading): ADR-025 lazy-loading complete
557 files merged. Conflicts resolved:
  - CHANGELOG.md: took refactor/lazy-loading (session changelog)
  - versions.ncl: took refactor/lazy-loading (adds typedialog entries)
2026-04-17 23:09:56 +01:00

90 lines
4.7 KiB
Text

# REMOVED: use lib_provisioning * - causes circular import
use utils.nu *
use handlers.nu *
use dag-executor.nu *
use ../lib_provisioning/utils/ssh.nu *
use ../lib_provisioning/config/accessor.nu *
# Provider middleware now available through lib_provisioning
# > TaskServs create
export def "main create" [
task_name?: string # task in settings
server?: string # Server hostname in settings
...args # Args for create command
--infra (-i): string # Infra directory
--settings (-s): string # Settings path
--iptype: string = "public" # Ip type to connect
--outfile (-o): string # Output file
--taskserv_pos (-p): int # Server position in settings
--check (-c) # Only check mode no taskservs will be created
--upload (-u) # Upload scripts to server for inspection (use with --check)
--wait (-w) # Wait taskservs to be created
--select: string # Select with task as option
--reset # Force reinstall: runs kubeadm reset before re-installing (sets CMD_TSK=reinstall)
--cmd: string = "" # Override cmd_task for any taskserv: scripts, config, update, restart, reinstall
--debug (-x) # Use Debug mode
--xm # Debug with PROVISIONING_METADATA
--xc # Debuc for task and services locally PROVISIONING_DEBUG_CHECK
--xr # Debug for remote taskservs PROVISIONING_DEBUG_REMOTE
--xld # Log level with DEBUG PROVISIONING_LOG_LEVEL=debug
--metadata # Error with metadata (-xm)
--notitles # not tittles
--helpinfo (-h) # For more details use options "help" (no dashes)
--out: string # Print Output format: json, yaml, text (default)
] {
if ($out | is-not-empty) {
set-provisioning-out $out
set-provisioning-no-terminal true
}
provisioning_init $helpinfo "taskserv create" ([($task_name | default "") ($server | default "")] | append $args)
if $debug { set-debug-enabled true }
if $metadata { set-metadata-enabled true }
let curr_settings = (find_get_settings --infra $infra --settings $settings)
let task = ((get-provisioning-args) | split row " " | get 0? | default null)
let options = if ($args | length) > 0 {
$args
} else {
let str_task = ((get-provisioning-args) | str replace $"($task) " "" |
str replace $"($task_name) " "" | str replace $"($server) " "")
($str_task | split row "-" | get 0? | default "" | str trim)
}
let other = if ($args | length) > 0 { ($args| skip 1) } else { "" }
let ops = $"((get-provisioning-args)) " | str replace $"($task_name) " "" | str trim
let run_create = {
let curr_settings = (settings_with_env $curr_settings)
set-wk-cnprov $curr_settings.wk_path
let arr_task = if $task_name == null or $task_name == "" or $task_name == "-" { [] } else { $task_name | split row "/" }
let match_task = if ($arr_task | length ) == 0 { "" } else { ($arr_task | get 0? | default null) }
let match_task_profile = if ($arr_task | length ) < 2 { "" } else { ($arr_task | get 1? | default null) }
let match_server = if $server == null or $server == "" { "" } else { $server}
# DAG-aware: resolves cross-formula dependencies automatically.
# Only activates when no specific server is given — with an explicit server
# the user wants a direct targeted install, not full DAG resolution.
if ($match_task | is-not-empty) and ($match_server | is-empty) and ($cmd == "" or $cmd == "install") {
dag-aware-create $curr_settings $match_task $match_server $iptype $check $upload $reset $cmd
} else {
on_taskservs $curr_settings $match_task $match_task_profile $match_server $iptype $check $upload $reset $cmd
}
}
match $task {
"" if $task_name == "h" => {
^$"((get-provisioning-name))" -mod taskserv update help --notitles
},
"" if $task_name == "help" => {
^$"((get-provisioning-name))" -mod taskserv update --help
_print (provisioning_options "update")
},
_ if ($task_name | is-not-empty) and $task_name not-in ["h", "help"] => {
# Called with an explicit taskserv name — run directly regardless of $task
let result = desktop_run_notify $"((get-provisioning-name)) taskservs create" "-> " $run_create --timeout 11sec
},
"c" | "create" | "" => {
let result = desktop_run_notify $"((get-provisioning-name)) taskservs create" "-> " $run_create --timeout 11sec
},
_ => {
_print $"\nUse (_ansi blue_bold)((get-provisioning-name)) -h(_ansi reset) for help on commands and options"
}
}
# "" | "create"
#if not $env.PROVISIONING_DEBUG { end_run "" }
}