2026-01-14 02:00:23 +00:00
|
|
|
use std
|
|
|
|
|
use ../lib_provisioning *
|
|
|
|
|
use ../lib_provisioning/platform *
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Taskserv workflow definitions
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Get orchestrator endpoint from platform configuration or use provided default
|
|
|
|
|
def get-orchestrator-url [--orchestrator: string = ""] {
|
|
|
|
|
if ($orchestrator | is-not-empty) {
|
|
|
|
|
return $orchestrator
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Try to get from platform discovery
|
|
|
|
|
let result = (do { service-endpoint "orchestrator" } | complete)
|
|
|
|
|
if $result.exit_code == 0 {
|
|
|
|
|
$result.stdout
|
2025-12-11 21:57:05 +00:00
|
|
|
} else {
|
2026-01-14 02:00:23 +00:00
|
|
|
# Fallback to default if no active workspace
|
|
|
|
|
"http://localhost:9090"
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
2026-01-14 02:00:23 +00:00
|
|
|
}
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Detect if orchestrator URL is local (for plugin usage)
|
|
|
|
|
def use-local-plugin [orchestrator_url: string] {
|
|
|
|
|
# Check if it's a local endpoint
|
|
|
|
|
(detect-platform-mode $orchestrator_url) == "local"
|
|
|
|
|
}
|
|
|
|
|
export def taskserv_workflow [
|
|
|
|
|
taskserv: string # Taskserv name
|
|
|
|
|
operation: string # Operation: create, delete, generate, check-updates
|
|
|
|
|
infra?: string # Infrastructure target
|
|
|
|
|
settings?: string # Settings file path
|
|
|
|
|
--check (-c) # Check mode only
|
|
|
|
|
--wait (-w) # Wait for completion
|
|
|
|
|
--orchestrator: string = "" # Orchestrator URL (optional, uses platform config if not provided)
|
|
|
|
|
] {
|
|
|
|
|
let orch_url = (get-orchestrator-url --orchestrator=$orchestrator)
|
|
|
|
|
let workflow_data = {
|
|
|
|
|
taskserv: $taskserv,
|
|
|
|
|
operation: $operation,
|
|
|
|
|
infra: ($infra | default ""),
|
|
|
|
|
settings: ($settings | default ""),
|
|
|
|
|
check_mode: $check,
|
|
|
|
|
wait: $wait
|
2025-12-11 21:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Submit to orchestrator
|
|
|
|
|
let response = (http post $"($orch_url)/workflows/taskserv/create" --content-type "application/json" ($workflow_data | to json))
|
2025-12-11 21:57:05 +00:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
if not ($response | get success) {
|
|
|
|
|
return { status: "error", message: ($response | get error) }
|
2025-12-11 21:57:05 +00:00
|
|
|
}
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
let task_id = ($response | get data)
|
|
|
|
|
_print $"Taskserv ($operation) workflow submitted: ($task_id)"
|
2025-12-11 21:57:05 +00:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
if $wait {
|
|
|
|
|
wait_for_workflow_completion $orch_url $task_id
|
2025-10-07 10:32:04 +01:00
|
|
|
} else {
|
2026-01-14 02:00:23 +00:00
|
|
|
{ status: "submitted", task_id: $task_id }
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
# Specific taskserv operations
|
|
|
|
|
export def "taskserv create" [
|
|
|
|
|
taskserv: string # Taskserv name
|
|
|
|
|
infra?: string # Infrastructure target
|
|
|
|
|
settings?: string # Settings file path
|
|
|
|
|
--check (-c) # Check mode only
|
|
|
|
|
--wait (-w) # Wait for completion
|
|
|
|
|
--orchestrator: string = "" # Orchestrator URL (optional, uses platform config if not provided)
|
|
|
|
|
] {
|
|
|
|
|
taskserv_workflow $taskserv "create" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
export def "taskserv delete" [
|
|
|
|
|
taskserv: string # Taskserv name
|
|
|
|
|
infra?: string # Infrastructure target
|
|
|
|
|
settings?: string # Settings file path
|
|
|
|
|
--check (-c) # Check mode only
|
|
|
|
|
--wait (-w) # Wait for completion
|
|
|
|
|
--orchestrator: string = "" # Orchestrator URL (optional, uses platform config if not provided)
|
|
|
|
|
] {
|
|
|
|
|
taskserv_workflow $taskserv "delete" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
export def "taskserv generate" [
|
|
|
|
|
taskserv: string # Taskserv name
|
|
|
|
|
infra?: string # Infrastructure target
|
|
|
|
|
settings?: string # Settings file path
|
|
|
|
|
--check (-c) # Check mode only
|
|
|
|
|
--wait (-w) # Wait for completion
|
|
|
|
|
--orchestrator: string = "" # Orchestrator URL (optional, uses platform config if not provided)
|
|
|
|
|
] {
|
|
|
|
|
taskserv_workflow $taskserv "generate" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
|
|
|
|
|
}
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
export def "taskserv check-updates" [
|
|
|
|
|
taskserv?: string # Taskserv name (optional for all)
|
|
|
|
|
infra?: string # Infrastructure target
|
|
|
|
|
settings?: string # Settings file path
|
|
|
|
|
--check (-c) # Check mode only
|
|
|
|
|
--wait (-w) # Wait for completion
|
|
|
|
|
--orchestrator: string = "" # Orchestrator URL (optional, uses platform config if not provided)
|
|
|
|
|
] {
|
|
|
|
|
let taskserv_name = ($taskserv | default "")
|
|
|
|
|
taskserv_workflow $taskserv_name "check-updates" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
|
|
|
|
|
}
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
def wait_for_workflow_completion [orchestrator: string, task_id: string] {
|
|
|
|
|
_print "Waiting for workflow completion..."
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
mut result = { status: "pending" }
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
while true {
|
|
|
|
|
let status_response = (http get $"($orchestrator)/tasks/($task_id)")
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
if not ($status_response | get success) {
|
|
|
|
|
return { status: "error", message: "Failed to get task status" }
|
|
|
|
|
}
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
let task = ($status_response | get data)
|
|
|
|
|
let task_status = ($task | get status)
|
2025-10-07 10:32:04 +01:00
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
match $task_status {
|
|
|
|
|
"Completed" => {
|
|
|
|
|
_print $"✅ Workflow completed successfully"
|
|
|
|
|
if ($task | get output | is-not-empty) {
|
|
|
|
|
_print "Output:"
|
|
|
|
|
_print ($task | get output)
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
2026-01-14 02:00:23 +00:00
|
|
|
$result = { status: "completed", task: $task }
|
|
|
|
|
break
|
|
|
|
|
},
|
|
|
|
|
"Failed" => {
|
|
|
|
|
_print $"❌ Workflow failed"
|
|
|
|
|
if ($task | get error | is-not-empty) {
|
|
|
|
|
_print "Error:"
|
|
|
|
|
_print ($task | get error)
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
2026-01-14 02:00:23 +00:00
|
|
|
$result = { status: "failed", task: $task }
|
|
|
|
|
break
|
|
|
|
|
},
|
|
|
|
|
"Running" => {
|
|
|
|
|
_print $"🔄 Workflow is running..."
|
|
|
|
|
},
|
|
|
|
|
_ => {
|
|
|
|
|
_print $"⏳ Workflow status: ($task_status)"
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
sleep 2sec
|
2025-10-07 10:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 02:00:23 +00:00
|
|
|
return $result
|
chore: complete KCL to Nickel migration cleanup and setup pre-commit
Clean up 404 KCL references (99.75% complete):
- Rename kcl_* variables to schema_*/nickel_* (kcl_path→schema_path, etc.)
- Update functions: parse_kcl_file→parse_nickel_file
- Update env vars: KCL_MOD_PATH→NICKEL_IMPORT_PATH
- Fix cli/providers-install: add has_nickel and nickel_version variables
- Correct import syntax: .nickel.→.ncl.
- Update 57 files across core, CLI, config, and utilities
Configure pre-commit hooks:
- Activate: nushell-check, nickel-typecheck, markdownlint
- Comment out: Rust hooks (fmt, clippy, test), check-yaml
Testing:
- Module discovery: 9 modules (6 providers, 1 taskserv, 2 clusters) ✅
- Syntax validation: 15 core files ✅
- Pre-commit hooks: all passing ✅
2026-01-08 20:08:46 +00:00
|
|
|
}
|