Large combined batch of 23 files refactored from star-imports to selective.
Grouped because two sub-batches accumulated in staging without intermediate
commit.
=== Orchestrator facades (Layer 3) ===
ai/mod.nu [12 symbols from ai/lib.nu]
config/loader.nu [14 symbols from loader/mod.nu]
config/accessor/mod.nu [15 symbols from accessor/functions.nu]
sops/mod.nu [11 symbols from sops/lib.nu]
user/mod.nu [16 symbols from user/config.nu]
=== Selective imports ===
defs/lists.nu utils/on_select (kept, selective)
services/manager.nu (all dead dropped)
webhook/ai_webhook.nu ai/lib [4] + settings/lib
kms/lib.nu utils/error + utils/interface + plugins/kms
gitea/locking.nu api_client [8]
gitea/workspace_git.nu api_client [3]
gitea/extension_publish.nu api_client [8] + config/loader
infra_validator/rules_engine.nu config_loader [3]
plugins/kms.nu config/accessor/core [config-get]
coredns/api_client.nu config/loader [get-config]
=== Dangling imports removed (target file does not exist) ===
coredns/docker.nu ../utils/log.nu → deleted (uses corefile.nu [2])
coredns/zones.nu ../utils/log.nu → deleted (uses corefile.nu [1])
coredns/service.nu ../utils/log.nu → deleted (uses corefile.nu [2])
coredns/corefile.nu ../utils/log.nu → deleted
=== Broken paths cleaned up ===
project/detect.nu Former `use ../../../lib_provisioning *` resolved to
non-existent path (core/lib_provisioning). Silent no-op at runtime.
Removed. Error count went 19 -> 17.
=== Dead imports dropped ===
utils/ssh.nu config/accessor DROPPED (dead)
utils/init.nu config/accessor DROPPED (dead)
infra_validator/agent_interface.nu report_generator DROPPED (dead)
=== Dynamic imports preserved ===
providers/loader.nu line 179 `use ($provider_entry.entry_point) *` is
intentional runtime dispatch — not convertible to selective.
Validation: all files match pre-existing baseline. Gitea subsystem has
known pre-existing 50-error noise (transitive); independent of this work.
Refs: ADR-025
139 lines
4.8 KiB
Text
139 lines
4.8 KiB
Text
# Module: System Initialization
|
|
# Purpose: Handles system initialization, environment setup, and workspace initialization.
|
|
# Dependencies: error, interface, config/accessor
|
|
|
|
|
|
# config/accessor star-import was dead — dropped (ADR-025 Phase 3 Layer 2).
|
|
|
|
# Get the complete provisioning command arguments as a string
|
|
export def get-provisioning-args [] : nothing -> string {
|
|
$env.PROVISIONING_ARGS? | default ""
|
|
}
|
|
|
|
# Get the provisioning command name
|
|
export def get-provisioning-name [] : nothing -> string {
|
|
$env.PROVISIONING_NAME? | default "provisioning"
|
|
}
|
|
|
|
# Get the provisioning infrastructure path
|
|
export def get-provisioning-infra-path [] : nothing -> string {
|
|
$env.PROVISIONING_INFRA_PATH? | default ""
|
|
}
|
|
|
|
# Get the provisioning resources path
|
|
export def get-provisioning-resources [] : nothing -> string {
|
|
$env.PROVISIONING_RESOURCES? | default ""
|
|
}
|
|
|
|
# Get the provisioning URL
|
|
export def get-provisioning-url [] : nothing -> string {
|
|
$env.PROVISIONING_URL? | default "https://provisioning.systems"
|
|
}
|
|
|
|
# Get whether SOPS encryption is enabled
|
|
export def get-provisioning-use-sops [] : nothing -> string {
|
|
$env.PROVISIONING_USE_SOPS? | default ""
|
|
}
|
|
|
|
# Get the effective workspace
|
|
export def get-effective-workspace [] : nothing -> string {
|
|
$env.CURRENT_WORKSPACE? | default "default"
|
|
}
|
|
|
|
# Get workspace path (defaults to effective workspace if not provided)
|
|
export def get-workspace-path [workspace?: string] : nothing -> string {
|
|
let ws = if ($workspace | is-empty) {
|
|
(get-effective-workspace)
|
|
} else {
|
|
$workspace
|
|
}
|
|
let ws_base = ($env.PROVISIONING_WORKSPACES? | default "")
|
|
if ($ws_base | is-not-empty) {
|
|
$ws_base | path join $ws
|
|
} else {
|
|
""
|
|
}
|
|
}
|
|
|
|
# Detect infrastructure from PWD
|
|
export def detect-infra-from-pwd [] : nothing -> string {
|
|
""
|
|
}
|
|
|
|
# Get work format (Nickel is the default post-migration)
|
|
export def get-work-format [] : nothing -> string {
|
|
$env.PROVISIONING_WORK_FORMAT? | default "ncl"
|
|
}
|
|
|
|
export def show_titles [] {
|
|
# Check if titles are disabled
|
|
if ($env.PROVISIONING_NO_TITLES? | default false) { return }
|
|
if ($env.PROVISIONING_OUT? | is-not-empty) { return }
|
|
if ($env.PROVISIONING_TITLES_SHOWN? | default false) { return }
|
|
|
|
# Mark as shown to prevent duplicates
|
|
$env.PROVISIONING_TITLES_SHOWN = true
|
|
|
|
# Find ascii.txt from PROVISIONING_RESOURCES or PROVISIONING directory
|
|
let ascii_file = (
|
|
if ($env.PROVISIONING_RESOURCES? | is-not-empty) {
|
|
($env.PROVISIONING_RESOURCES | path join "ascii.txt")
|
|
} else if ($env.PROVISIONING? | is-not-empty) {
|
|
($env.PROVISIONING | path join "resources" | path join "ascii.txt")
|
|
} else {
|
|
""
|
|
}
|
|
)
|
|
|
|
# Display if file exists
|
|
if ($ascii_file | is-not-empty) and ($ascii_file | path exists) {
|
|
print $"(ansi blue_bold)(open -r $ascii_file)(ansi reset)"
|
|
}
|
|
}
|
|
export def use_titles [ ] {
|
|
if ($env.PROVISIONING_NO_TITLES? | default false) { return false }
|
|
if ($env.PROVISIONING_NO_TERMINAL? | default false) { return false }
|
|
let args = ($env.PROVISIONING_ARGS? | default "")
|
|
if ($args | is-not-empty) and ($args | str contains "-h" ) { return false }
|
|
if ($args | is-not-empty) and ($args | str contains "--notitles" ) { return false }
|
|
if ($args | is-not-empty) and ($args | str contains "query") and ($args | str contains "-o" ) { return false }
|
|
true
|
|
}
|
|
export def provisioning_init [
|
|
helpinfo: bool
|
|
module: string
|
|
args: list<string> # Other options, use help to get info
|
|
] {
|
|
if (use_titles) { show_titles }
|
|
if $helpinfo != null and $helpinfo {
|
|
let cmd_line: list<string> = if ($args| length) == 0 {
|
|
$args | str join " "
|
|
} else {
|
|
($env.PROVISIONING_ARGS? | default "")
|
|
}
|
|
let cmd_args: list<string> = ($cmd_line | str replace "--helpinfo" "" |
|
|
str replace "-h" "" | str replace $module "" | str trim | split row " "
|
|
)
|
|
if ($cmd_args | length) > 0 {
|
|
# Refactored from try-catch to do/complete for explicit error handling
|
|
let str_mod_0_result = (do { $cmd_args | get 0 } | complete)
|
|
let str_mod_0 = if $str_mod_0_result.exit_code == 0 { ($str_mod_0_result.stdout | str trim) } else { "" }
|
|
|
|
let str_mod_1_result = (do { $cmd_args | get 1 } | complete)
|
|
let str_mod_1 = if $str_mod_1_result.exit_code == 0 { ($str_mod_1_result.stdout | str trim) } else { "" }
|
|
|
|
if $str_mod_1 != "" {
|
|
let final_args = ($cmd_args | drop nth 0 1)
|
|
^$"((get-provisioning-name))" "-mod" $"'($str_mod_0) ($str_mod_1)'" ...$final_args help
|
|
} else if $str_mod_0 != "" {
|
|
let final_args = ($cmd_args | drop nth 0)
|
|
^$"((get-provisioning-name))" "-mod" ($str_mod_0) ...$final_args help
|
|
} else {
|
|
^$"((get-provisioning-name))" "-mod" $"($module | str replace ' ' '|')" ...$cmd_args help
|
|
}
|
|
} else {
|
|
^$"((get-provisioning-name))" help
|
|
}
|
|
exit 0
|
|
}
|
|
}
|