prvng_core/nulib/taskservs/generate.nu

82 lines
3.9 KiB
Text
Raw Permalink Normal View History

feat(core): three-layer DAG, unified component arch, commands-registry cache, Nushell 0.112.2 migration - DAG architecture: `dag show/validate/export` (nulib/main_provisioning/dag.nu), config loader (lib_provisioning/config/loader/dag.nu), taskserv dag-executor. Backed by schemas/lib/dag/*.ncl; orchestrator emits NATS events via WorkspaceComposition::into_workflow. See ADR-020, ADR-021. - Unified Component Architecture: components/mod.nu, main_provisioning/ {components,workflow,extensions,ontoref-queries}.nu. Full workflow engine with topological sort and NATS subject emission. Blocks A-H complete (libre-daoshi). - Commands-registry: nulib/commands-registry.ncl (Nickel source, 314 lines) + JSON cache at ~/.cache/provisioning/commands-registry.json rebuilt on source change. cli/provisioning fast-path alias expansion avoids cold Nu startup. ADDING_COMMANDS.md documents new-command workflow. - Platform service manager: service-manager.nu (+573), startup.nu (+611), service-check.nu (+255); autostart/bootstrap/health/target refactored. - Nushell 0.112.2 migration: removed all try/catch and bash redirections; external commands prefixed with ^; type signatures enforced. Driven by scripts/refactor-try-catch{,-simplified}.nu. - TTY stack: removed shlib/*-tty.sh; replaced by cli/tty-dispatch.sh, tty-filter.sh, tty-commands.conf. - New domain modules: images/ (golden image lifecycle), workspace/{state,sync}.nu, main_provisioning/{bootstrap,cluster-deploy,fip,state}.nu, commands/{state, build,integrations/auth,utilities/alias}.nu, platform.nu expanded (+874). - Config loader overhaul: loader/core.nu slimmed (-759), cache/core.nu refactored (-454), removed legacy loaders/file_loader.nu (-330). - Thirteen new provisioning-<domain>.nu top-level modules for bash dispatcher. - Tests: test_workspace_state.nu (+351); updates to test_oci_registry, test_services. - README + CHANGELOG updated.
2026-04-17 04:27:33 +01:00
# REMOVED: use lib_provisioning * - causes circular import
2025-10-07 10:32:04 +01:00
#use ../lib_provisioning/utils/generate.nu *
use utils.nu *
use handlers.nu *
use ../lib_provisioning/utils/ssh.nu *
use ../lib_provisioning/config/accessor.nu *
#use providers/prov_lib/middleware.nu *
# Provider middleware now available through lib_provisioning
# > TaskServs generate
2025-10-07 10:32:04 +01:00
export def "main generate" [
task_name?: string # task in settings
server?: string # Server hostname in settings
...args # Args for generate command
--infra (-i): string # Infra directory
--settings (-s): string # Settings path
2025-10-07 10:32:04 +01:00
--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 generated
--wait (-w) # Wait taskservs to be generated
--select: string # Select with task as option
2025-10-07 10:32:04 +01:00
--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
2025-10-07 10:32:04 +01:00
--metadata # Error with metadata (-xm)
--notitles # not tittles
--helpinfo (-h) # For more details use options "help" (no dashes)
2025-10-07 10:32:04 +01:00
--out: string # Print Output format: json, yaml, text (default)
] {
2025-10-07 10:32:04 +01:00
if ($out | is-not-empty) {
set-provisioning-out $out
set-provisioning-no-terminal true
}
provisioning_init $helpinfo "taskserv generate" ([($task_name | default "") ($server | default "")] | append $args)
if $debug { set-debug-enabled true }
if $metadata { set-metadata-enabled true }
2025-10-07 10:32:04 +01:00
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 {
2025-10-07 10:32:04 +01:00
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 { "" }
2025-10-07 10:32:04 +01:00
let ops = $"((get-provisioning-args)) " | str replace $"($task_name) " "" | str trim
#print "GENEREATE"
2025-10-07 10:32:04 +01:00
# "/wuwei/repo-cnz/src/provisioning/taskservs/oci-reg/generate/defs.toml"
#exit
let run_generate = {
2025-10-07 10:32:04 +01:00
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}
2025-10-07 10:32:04 +01:00
on_taskservs $curr_settings $match_task $match_task_profile $match_server $iptype $check
}
match $task {
"" if $task_name == "h" => {
2025-10-07 10:32:04 +01:00
^$"((get-provisioning-name))" -mod taskserv update help --notitles
},
"" if $task_name == "help" => {
2025-10-07 10:32:04 +01:00
^$"((get-provisioning-name))" -mod taskserv update --help
_print (provisioning_options "update")
},
"g" | "generate" | "" => {
2025-10-07 10:32:04 +01:00
let result = desktop_run_notify $"((get-provisioning-name)) taskservs generate" "-> " $run_generate --timeout 11sec
},
_ => {
if $task_name != "" {_print $"🛑 invalid_option ($task_name)" }
2025-10-07 10:32:04 +01:00
_print $"\nUse (_ansi blue_bold)((get-provisioning-name)) -h(_ansi reset) for help on commands and options"
}
}
2025-10-07 10:32:04 +01:00
# "" | "generate"
#if not $env.PROVISIONING_DEBUG { end_run "" }
}