Jesús Pérez c62e967ce3
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

110 lines
3.6 KiB
Plaintext

use std
use ../lib_provisioning *
# Cluster workflow definitions
export def cluster_workflow [
cluster_type: string # Cluster type
operation: string # Operation: create, delete
infra?: string # Infrastructure target
settings?: string # Settings file path
--check (-c) # Check mode only
--wait (-w) # Wait for completion
--orchestrator: string = "http://localhost:8080" # Orchestrator URL
]: nothing -> record {
let workflow_data = {
cluster_type: $cluster_type,
operation: $operation,
infra: ($infra | default ""),
settings: ($settings | default ""),
check_mode: $check,
wait: $wait
}
# Submit to orchestrator
let response = (http post $"($orchestrator)/workflows/cluster/create" --content-type "application/json" ($workflow_data | to json))
if not ($response | get success) {
return { status: "error", message: ($response | get error) }
}
let task_id = ($response | get data)
_print $"Cluster ($operation) workflow submitted: ($task_id)"
if $wait {
wait_for_workflow_completion $orchestrator $task_id
} else {
{ status: "submitted", task_id: $task_id }
}
}
# Specific cluster operations
export def "cluster create" [
cluster_type: string # Cluster type
infra?: string # Infrastructure target
settings?: string # Settings file path
--check (-c) # Check mode only
--wait (-w) # Wait for completion
--orchestrator: string = "http://localhost:8080" # Orchestrator URL
]: nothing -> record {
cluster_workflow $cluster_type "create" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
}
export def "cluster delete" [
cluster_type: string # Cluster type
infra?: string # Infrastructure target
settings?: string # Settings file path
--check (-c) # Check mode only
--wait (-w) # Wait for completion
--orchestrator: string = "http://localhost:8080" # Orchestrator URL
]: nothing -> record {
cluster_workflow $cluster_type "delete" $infra $settings --check=$check --wait=$wait --orchestrator $orchestrator
}
def wait_for_workflow_completion [orchestrator: string, task_id: string]: nothing -> record {
_print "Waiting for workflow completion..."
mut result = { status: "pending" }
while true {
let status_response = (http get $"($orchestrator)/tasks/($task_id)")
if not ($status_response | get success) {
return { status: "error", message: "Failed to get task status" }
}
let task = ($status_response | get data)
let task_status = ($task | get status)
match $task_status {
"Completed" => {
_print $"✅ Workflow completed successfully"
if ($task | get output | is-not-empty) {
_print "Output:"
_print ($task | get output)
}
$result = { status: "completed", task: $task }
break
},
"Failed" => {
_print $"❌ Workflow failed"
if ($task | get error | is-not-empty) {
_print "Error:"
_print ($task | get error)
}
$result = { status: "failed", task: $task }
break
},
"Running" => {
_print $"🔄 Workflow is running..."
},
_ => {
_print $"⏳ Workflow status: ($task_status)"
}
}
sleep 2sec
}
return $result
}