2025-09-22 22:11:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
use ../lib_provisioning/utils/ssh.nu *
|
|
|
|
use ../lib_provisioning/defs/lists.nu *
|
feat: Complete config-driven architecture migration v2.0.0
Transform provisioning system from ENV-based to hierarchical config-driven architecture.
This represents a complete system redesign with breaking changes requiring migration.
## Migration Summary
- 65+ files migrated across entire codebase
- 200+ ENV variables replaced with 476 config accessors
- 29 syntax errors fixed across 17 files
- 92% token efficiency maintained during migration
## Core Features Added
### Hierarchical Configuration System
- 6-layer precedence: defaults → user → project → infra → env → runtime
- Deep merge strategy with intelligent precedence rules
- Multi-environment support (dev/test/prod) with auto-detection
- Configuration templates for all environments
### Enhanced Interpolation Engine
- Dynamic variables: {{paths.base}}, {{env.HOME}}, {{now.date}}
- Git context: {{git.branch}}, {{git.commit}}, {{git.remote}}
- SOPS integration: {{sops.decrypt()}} for secrets management
- Path operations: {{path.join()}} for dynamic construction
- Security: circular dependency detection, injection prevention
### Comprehensive Validation
- Structure, path, type, semantic, and security validation
- Code injection and path traversal detection
- Detailed error reporting with actionable messages
- Configuration health checks and warnings
## Architecture Changes
### Configuration Management (core/nulib/lib_provisioning/config/)
- loader.nu: 1600+ line hierarchical config loader with validation
- accessor.nu: 476 config accessor functions replacing ENV vars
### Provider System (providers/)
- AWS, UpCloud, Local providers fully config-driven
- Unified middleware system with standardized interfaces
### Task Services (core/nulib/taskservs/)
- Kubernetes, storage, networking, registry services migrated
- Template-driven configuration generation
### Cluster Management (core/nulib/clusters/)
- Complete lifecycle management through configuration
- Environment-specific cluster templates
## New Configuration Files
- config.defaults.toml: System defaults (84 lines)
- config.*.toml.example: Environment templates (400+ lines each)
- Enhanced CLI: validate, env, multi-environment support
## Security Enhancements
- Type-safe configuration access through validated functions
- SOPS integration for encrypted secrets management
- Input validation preventing injection attacks
- Environment isolation and access controls
## Breaking Changes
⚠️ ENV variables no longer supported as primary configuration
⚠️ Function signatures require --config parameter
⚠️ CLI arguments and return types modified
⚠️ Provider authentication now config-driven
## Migration Path
1. Backup current environment variables
2. Copy config.user.toml.example → config.user.toml
3. Migrate ENV vars to TOML format
4. Validate: ./core/nulib/provisioning validate config
5. Test functionality with new configuration
## Validation Results
✅ Structure valid
✅ Paths valid
✅ Types valid
✅ Semantic rules valid
✅ File references valid
System ready for production use with config-driven architecture.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 02:36:50 +00:00
|
|
|
use ../lib_provisioning/config/accessor.nu *
|
2025-09-22 22:11:41 +00:00
|
|
|
use lib_provisioning *
|
|
|
|
export def taskserv_get_file [
|
|
|
|
settings: record
|
|
|
|
taskserv: record
|
|
|
|
server: record
|
|
|
|
live_ip: string
|
|
|
|
req_sudo: bool
|
|
|
|
local_mode: bool
|
|
|
|
]: nothing -> bool {
|
|
|
|
let target_path = ($taskserv.target_path | default "")
|
|
|
|
if $target_path == "" {
|
|
|
|
_print $"🛑 No (_ansi red_bold)target_path(_ansi reset) found in ($server.hostname) taskserv ($taskserv.name)"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let source_path = ($taskserv.soruce_path | default "")
|
|
|
|
if $source_path == "" {
|
|
|
|
_print $"🛑 No (_ansi red_bold)source_path(_ansi reset) found in ($server.hostname) taskserv ($taskserv.name)"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if $local_mode {
|
|
|
|
let res = (^cp $source_path $target_path | combine)
|
|
|
|
if $res.exit_code != 0 {
|
|
|
|
_print $"🛑 Error get_file [ local-mode ] (_ansi red_bold)($source_path) to ($target_path)(_ansi reset) in ($server.hostname) taskserv ($taskserv.name)"
|
|
|
|
_print $res.stdout
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
let ip = if $live_ip != "" {
|
|
|
|
$live_ip
|
|
|
|
} else {
|
|
|
|
#use ../../../providers/prov_lib/middleware.nu mw_get_ip
|
|
|
|
(mw_get_ip $settings $server $server.liveness_ip false)
|
|
|
|
}
|
|
|
|
let ssh_key_path = ($server.ssh_key_path | default "")
|
|
|
|
if $ssh_key_path == "" {
|
|
|
|
_print $"🛑 No (_ansi red_bold)ssh_key_path(_ansi reset) found in ($server.hostname) taskserv ($taskserv.name)"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if not ($ssh_key_path | path exists) {
|
|
|
|
_print $"🛑 Error (_ansi red_bold)($ssh_key_path)(_ansi reset) not found for ($server.hostname) taskserv ($taskserv.name)"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
mut cmd = if $req_sudo { "sudo" } else { "" }
|
|
|
|
let wk_path = $"/home/($env.SSH_USER)/($source_path | path basename)"
|
|
|
|
$cmd = $"($cmd) cp ($source_path) ($wk_path); sudo chown ($env.SSH_USER) ($wk_path)"
|
|
|
|
let res = (ssh_cmd $settings $server false $cmd $ip)
|
|
|
|
if not $res { return false }
|
|
|
|
if not (scp_from $settings $server $wk_path $target_path $ip ) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
let rm_cmd = if $req_sudo {
|
|
|
|
$"sudo rm -f ($wk_path)"
|
|
|
|
} else {
|
|
|
|
$"rm -f ($wk_path)"
|
|
|
|
}
|
|
|
|
return ( ssh_cmd $settings $server false $rm_cmd $ip )
|
|
|
|
}
|
|
|
|
|
|
|
|
export def find_taskserv [
|
|
|
|
settings: record,
|
|
|
|
server: record,
|
|
|
|
taskserv_name: string,
|
|
|
|
out: string
|
|
|
|
]: nothing -> record {
|
|
|
|
let taskserv = ($server | get -o taskservs | where {|t| ($t | get -o name | default "") == $taskserv_name} | get -o 0 | default {} )
|
|
|
|
if ($taskserv | is-empty) {
|
|
|
|
_print $"🛑 No taskserv found" $"for (_ansi yellow_bold)($taskserv_name)(_ansi reset)"
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
let src_path = ($settings | get -o src_path | default "")
|
|
|
|
let hostname = ($server | get -o hostname | default "")
|
feat: Complete config-driven architecture migration v2.0.0
Transform provisioning system from ENV-based to hierarchical config-driven architecture.
This represents a complete system redesign with breaking changes requiring migration.
## Migration Summary
- 65+ files migrated across entire codebase
- 200+ ENV variables replaced with 476 config accessors
- 29 syntax errors fixed across 17 files
- 92% token efficiency maintained during migration
## Core Features Added
### Hierarchical Configuration System
- 6-layer precedence: defaults → user → project → infra → env → runtime
- Deep merge strategy with intelligent precedence rules
- Multi-environment support (dev/test/prod) with auto-detection
- Configuration templates for all environments
### Enhanced Interpolation Engine
- Dynamic variables: {{paths.base}}, {{env.HOME}}, {{now.date}}
- Git context: {{git.branch}}, {{git.commit}}, {{git.remote}}
- SOPS integration: {{sops.decrypt()}} for secrets management
- Path operations: {{path.join()}} for dynamic construction
- Security: circular dependency detection, injection prevention
### Comprehensive Validation
- Structure, path, type, semantic, and security validation
- Code injection and path traversal detection
- Detailed error reporting with actionable messages
- Configuration health checks and warnings
## Architecture Changes
### Configuration Management (core/nulib/lib_provisioning/config/)
- loader.nu: 1600+ line hierarchical config loader with validation
- accessor.nu: 476 config accessor functions replacing ENV vars
### Provider System (providers/)
- AWS, UpCloud, Local providers fully config-driven
- Unified middleware system with standardized interfaces
### Task Services (core/nulib/taskservs/)
- Kubernetes, storage, networking, registry services migrated
- Template-driven configuration generation
### Cluster Management (core/nulib/clusters/)
- Complete lifecycle management through configuration
- Environment-specific cluster templates
## New Configuration Files
- config.defaults.toml: System defaults (84 lines)
- config.*.toml.example: Environment templates (400+ lines each)
- Enhanced CLI: validate, env, multi-environment support
## Security Enhancements
- Type-safe configuration access through validated functions
- SOPS integration for encrypted secrets management
- Input validation preventing injection attacks
- Environment isolation and access controls
## Breaking Changes
⚠️ ENV variables no longer supported as primary configuration
⚠️ Function signatures require --config parameter
⚠️ CLI arguments and return types modified
⚠️ Provider authentication now config-driven
## Migration Path
1. Backup current environment variables
2. Copy config.user.toml.example → config.user.toml
3. Migrate ENV vars to TOML format
4. Validate: ./core/nulib/provisioning validate config
5. Test functionality with new configuration
## Validation Results
✅ Structure valid
✅ Paths valid
✅ Types valid
✅ Semantic rules valid
✅ File references valid
System ready for production use with config-driven architecture.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 02:36:50 +00:00
|
|
|
let run_taskservs_path = (get-run-taskservs-path)
|
|
|
|
mut taskserv_host_path = ($src_path | path join $run_taskservs_path |
|
2025-09-22 22:11:41 +00:00
|
|
|
path join $hostname | path join $"($taskserv_name).k")
|
|
|
|
let def_taskserv = if ($taskserv_host_path | path exists) {
|
|
|
|
(open -r $taskserv_host_path)
|
|
|
|
} else {
|
feat: Complete config-driven architecture migration v2.0.0
Transform provisioning system from ENV-based to hierarchical config-driven architecture.
This represents a complete system redesign with breaking changes requiring migration.
## Migration Summary
- 65+ files migrated across entire codebase
- 200+ ENV variables replaced with 476 config accessors
- 29 syntax errors fixed across 17 files
- 92% token efficiency maintained during migration
## Core Features Added
### Hierarchical Configuration System
- 6-layer precedence: defaults → user → project → infra → env → runtime
- Deep merge strategy with intelligent precedence rules
- Multi-environment support (dev/test/prod) with auto-detection
- Configuration templates for all environments
### Enhanced Interpolation Engine
- Dynamic variables: {{paths.base}}, {{env.HOME}}, {{now.date}}
- Git context: {{git.branch}}, {{git.commit}}, {{git.remote}}
- SOPS integration: {{sops.decrypt()}} for secrets management
- Path operations: {{path.join()}} for dynamic construction
- Security: circular dependency detection, injection prevention
### Comprehensive Validation
- Structure, path, type, semantic, and security validation
- Code injection and path traversal detection
- Detailed error reporting with actionable messages
- Configuration health checks and warnings
## Architecture Changes
### Configuration Management (core/nulib/lib_provisioning/config/)
- loader.nu: 1600+ line hierarchical config loader with validation
- accessor.nu: 476 config accessor functions replacing ENV vars
### Provider System (providers/)
- AWS, UpCloud, Local providers fully config-driven
- Unified middleware system with standardized interfaces
### Task Services (core/nulib/taskservs/)
- Kubernetes, storage, networking, registry services migrated
- Template-driven configuration generation
### Cluster Management (core/nulib/clusters/)
- Complete lifecycle management through configuration
- Environment-specific cluster templates
## New Configuration Files
- config.defaults.toml: System defaults (84 lines)
- config.*.toml.example: Environment templates (400+ lines each)
- Enhanced CLI: validate, env, multi-environment support
## Security Enhancements
- Type-safe configuration access through validated functions
- SOPS integration for encrypted secrets management
- Input validation preventing injection attacks
- Environment isolation and access controls
## Breaking Changes
⚠️ ENV variables no longer supported as primary configuration
⚠️ Function signatures require --config parameter
⚠️ CLI arguments and return types modified
⚠️ Provider authentication now config-driven
## Migration Path
1. Backup current environment variables
2. Copy config.user.toml.example → config.user.toml
3. Migrate ENV vars to TOML format
4. Validate: ./core/nulib/provisioning validate config
5. Test functionality with new configuration
## Validation Results
✅ Structure valid
✅ Paths valid
✅ Types valid
✅ Semantic rules valid
✅ File references valid
System ready for production use with config-driven architecture.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 02:36:50 +00:00
|
|
|
$taskserv_host_path = ($src_path | path join $run_taskservs_path | path join $"($taskserv_name).k")
|
2025-09-22 22:11:41 +00:00
|
|
|
if ($taskserv_host_path | path exists) {
|
|
|
|
(open -r $taskserv_host_path)
|
|
|
|
} else {
|
|
|
|
_print $"🛑 No taskserv path found" $"for (_ansi yellow_bold)($taskserv_name)(_ansi reset) in ($taskserv_host_path)"
|
|
|
|
$taskserv_host_path = ""
|
|
|
|
""
|
|
|
|
}
|
|
|
|
}
|
feat: Complete config-driven architecture migration v2.0.0
Transform provisioning system from ENV-based to hierarchical config-driven architecture.
This represents a complete system redesign with breaking changes requiring migration.
## Migration Summary
- 65+ files migrated across entire codebase
- 200+ ENV variables replaced with 476 config accessors
- 29 syntax errors fixed across 17 files
- 92% token efficiency maintained during migration
## Core Features Added
### Hierarchical Configuration System
- 6-layer precedence: defaults → user → project → infra → env → runtime
- Deep merge strategy with intelligent precedence rules
- Multi-environment support (dev/test/prod) with auto-detection
- Configuration templates for all environments
### Enhanced Interpolation Engine
- Dynamic variables: {{paths.base}}, {{env.HOME}}, {{now.date}}
- Git context: {{git.branch}}, {{git.commit}}, {{git.remote}}
- SOPS integration: {{sops.decrypt()}} for secrets management
- Path operations: {{path.join()}} for dynamic construction
- Security: circular dependency detection, injection prevention
### Comprehensive Validation
- Structure, path, type, semantic, and security validation
- Code injection and path traversal detection
- Detailed error reporting with actionable messages
- Configuration health checks and warnings
## Architecture Changes
### Configuration Management (core/nulib/lib_provisioning/config/)
- loader.nu: 1600+ line hierarchical config loader with validation
- accessor.nu: 476 config accessor functions replacing ENV vars
### Provider System (providers/)
- AWS, UpCloud, Local providers fully config-driven
- Unified middleware system with standardized interfaces
### Task Services (core/nulib/taskservs/)
- Kubernetes, storage, networking, registry services migrated
- Template-driven configuration generation
### Cluster Management (core/nulib/clusters/)
- Complete lifecycle management through configuration
- Environment-specific cluster templates
## New Configuration Files
- config.defaults.toml: System defaults (84 lines)
- config.*.toml.example: Environment templates (400+ lines each)
- Enhanced CLI: validate, env, multi-environment support
## Security Enhancements
- Type-safe configuration access through validated functions
- SOPS integration for encrypted secrets management
- Input validation preventing injection attacks
- Environment isolation and access controls
## Breaking Changes
⚠️ ENV variables no longer supported as primary configuration
⚠️ Function signatures require --config parameter
⚠️ CLI arguments and return types modified
⚠️ Provider authentication now config-driven
## Migration Path
1. Backup current environment variables
2. Copy config.user.toml.example → config.user.toml
3. Migrate ENV vars to TOML format
4. Validate: ./core/nulib/provisioning validate config
5. Test functionality with new configuration
## Validation Results
✅ Structure valid
✅ Paths valid
✅ Types valid
✅ Semantic rules valid
✅ File references valid
System ready for production use with config-driven architecture.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 02:36:50 +00:00
|
|
|
let taskservs_path = (get-taskservs-path)
|
|
|
|
mut main_taskserv_path = ($taskservs_path | path join $taskserv_name | path join "kcl" | path join $"($taskserv_name).k")
|
|
|
|
if not ($main_taskserv_path | path exists) {
|
|
|
|
$main_taskserv_path = ($taskservs_path | path join $taskserv_name | path join ($taskserv |
|
2025-09-22 22:11:41 +00:00
|
|
|
get -o profile | default "") | path join "kcl" | path join $"($taskserv_name).k")
|
|
|
|
}
|
|
|
|
let def_main = if ($main_taskserv_path | path exists) {
|
|
|
|
(open -r $main_taskserv_path)
|
|
|
|
} else {
|
|
|
|
_print $"🛑 No taskserv main path found" $"for (_ansi yellow_bold)($taskserv_name)(_ansi reset) ($main_taskserv_path)"
|
|
|
|
$main_taskserv_path = ""
|
|
|
|
""
|
|
|
|
}
|
|
|
|
{ path_def: $taskserv_host_path, def: $def_taskserv, path_main: $main_taskserv_path, main: $def_main }
|
|
|
|
}
|
|
|
|
export def list_taskservs [
|
|
|
|
settings: record
|
|
|
|
]: nothing -> list {
|
|
|
|
let list_taskservs = (taskservs_list)
|
|
|
|
if ($list_taskservs | length) == 0 {
|
|
|
|
_print $"🛑 no items found for (_ansi cyan)taskservs list(_ansi reset)"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
$list_taskservs
|
|
|
|
}
|