prvng_core/nulib/provisioning taskserv
Jesús Pérez 894046ef5a
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

122 lines
4.4 KiB
Text
Executable file

#!/usr/bin/env nu
# Info: Script to run Provisioning
# Author: JesusPerezLorenzo
# Release: 1.0.4
# Date: 6-2-2024
#use std # assert
use std log
use lib_provisioning *
use env.nu *
use taskservs *
# - > TaskServs Help
export def "main help" [
--src: string = ""
--notitles # not tittles
] {
if $notitles == null or not $notitles { show_titles }
^($env.PROVISIONING_NAME) "-mod" "taskserv" "--help"
_print (provisioning_options $src)
if not $env.PROVISIONING_DEBUG { end_run "" }
}
# > Task and Services for servers
def main [
...args: string # Other options, use help to get info
--iptype: string = "public" # Ip type to connect
-v # Show version
--version (-V) # Show version with title
--info (-I) # Show Info with title
--about (-a) # Show About
--infra (-i): string # Infra directory
--settings (-s): string # Settings path
--serverpos (-p): int # Server position in settings
--check (-c) # Only check mode no servers will be created
--yes (-y) # Confirm task
--wait (-w) # Wait servers to be created
--select: string # Select with taskservice as option
--onsel: string # On selection: e (edit) | v (view) | l (list)
--debug (-x) # Use Debug mode
--xm # Debug with PROVISIONING_METADATA
--xc # Debuc for taskservice and services locally PROVISIONING_DEBUG_CHECK
--xr # Debug for remote servers PROVISIONING_DEBUG_REMOTE
--xld # Log level with DEBUG PROVISIONING_LOG_LEVEL=debug
--nc # Not clean working settings
--metadata # Error with metadata (-xm)
--notitles # Do not show banner titles
--helpinfo (-h) # For more details use options "help" (no dashes)
--out: string # Print Output format: json, yaml, text (default)
]: nothing -> nothing {
if ($out | is-not-empty) {
$env.PROVISIONING_OUT = $out
$env.PROVISIONING_NO_TERMINAL = true
}
provisioning_init $helpinfo "taskserv" $args
if $version or $v { ^$env.PROVISIONING_NAME -v ; exit }
if $info { ^$env.PROVISIONING_NAME -i ; exit }
if $about {
#use defs/about.nu [ about_info ]
_print (get_about_info)
exit
}
if $debug { $env.PROVISIONING_DEBUG = true }
let use_debug = if $debug or $env.PROVISIONING_DEBUG { "-x" } else { "" }
if $metadata { $env.PROVISIONING_METADATA = true }
# for $arg in $args { print $arg }
let task = if ($args | length) > 0 { ($args| get 0) } else { "" }
let ops = if ($args | length) > 1 { ($args | skip 1 | str join " ") } else { "" }
print $"---TASK ($task)"
exit 1
exec ($env.PROVISIONING_NAME) $use_debug "-mod" "taskserv" "create" ...($ops | split row " ") --notitles
if not $env.PROVISIONING_DEBUG { end_run "" }
}
# export def use_match [task: string ops: string infra: string settings: record ] {
# match $task {
# "h" | "help" => {
# # Redirect to main categorized help system
# exec ($env.PROVISIONING_NAME) "help" "infrastructure" "--notitles"
# },
# "sed" => {
# if $ops == "" {
# (throw-error $"🛑 No file found" $"for (_ansi yellow_bold)sops(_ansi reset) edit")
# exit 1
# } else if ($ops | path exists) == false {
# (throw-error $"🛑 No file (_ansi green_italic)($ops)(_ansi reset) found" $"for (_ansi yellow_bold)sops(_ansi reset) edit")
# exit 1
# }
# if $env.PROVISIONING_SOPS? == null {
# let curr_settings = (find_get_settings --infra $infra --settings $settings)
# $env.CURRENT_INFRA_PATH = $"($curr_settings.infra_path)/($curr_settings.infra)"
# use sops_env.nu
# }
# #use sops on_sops
# on_sops "sed" $ops
# },
# "c" | "create" => {
# exec ($env.PROVISIONING_NAME) $use_debug "-mod" "taskserv" "create" ...($ops | split row " ") --notitles
# }
# "d" | "delete" => {
# exec ($env.PROVISIONING_NAME) $use_debug "-mod" "taskserv" "delete" ...($ops | split row " ") --notitles
# }
# "g" | "generate" => {
# exec ($env.PROVISIONING_NAME) $use_debug "-mod" "taskserv" "generate" ...($ops | split row " ") --notitles
# }
# "l"| "list" => {
# #use defs/lists.nu on_list
# on_list "taskservs" ($onsel | default "") ""
# },
# "qr" => {
# #use utils/qr.nu *
# make_qr
# },
# _ => {
# invalid_task "taskserv" $task --end
# },
# }
# }