PLAN-004A: UIS Core CLI System
IMPLEMENTATION RULES: Before implementing this plan, read and follow:
- WORKFLOW.md - The implementation process
- PLANS.md - Plan structure and best practices
Status: Completed
Goal: Create the foundation libraries, service scanner, config system, and basic CLI commands for UIS.
Last Updated: 2026-01-22
Part of: PLAN-004-uis-orchestration-system.md (Epic)
Prerequisites: PLAN-003-minimal-container-delivery.md - ✅ Complete
Priority: High
Delivers:
uis list- List available services with statusuis status- Show deployed services healthuis deploy- Deploy services from configuis enable/disable- Manage enabled-services.conf- First-run folder creation (
.uis.extend/,.uis.secrets/)
Overview
This plan creates the MVP of the UIS orchestration system - a working CLI that can:
- Scan and discover services with metadata
- Deploy services based on
enabled-services.conf - Show service status
- Enable/disable services in config
Core Philosophy: Zero-config start - works immediately with sensible defaults.
./uis start && ./uis deploy # Works immediately with defaults!
Key Constraint: Do NOT modify provision-host/kubernetes/. Build alongside it.
Architecture: Container vs Host Boundary
IMPORTANT: This section clarifies where code runs to avoid confusion.
┌─────────────────────────────────────────────────────────────────────────────────┐
│ USER'S HOST MACHINE │
│ │
│ ./uis (bash) or uis.ps1 (PowerShell) │
│ ├── Responsibility: Container lifecycle (start/stop) │
│ ├── Responsibility: First-run folder creation (.uis.extend/, .uis.secrets/) │
│ ├── Responsibility: Mount folders into container │
│ └── Routes ALL other commands to container │
│ │
│ .uis.extend/ <- Created by HOST wrapper on first run │
│ .uis.secrets/ <- Created by HOST wrapper on first run │
│ .kube/config <- Already exists on host (Rancher Desktop) │
│ │
└────────────────────────────────────┬────────────────────────────────────────────┘
│ docker exec
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ UIS-PROVISION-HOST CONTAINER │
│ │
│ /mnt/urbalurbadisk/provision-host/uis/manage/uis-cli.sh │
│ ├── Receives ALL commands from host wrapper (except start/stop/shell) │
│ ├── Sources libraries from /mnt/urbalurbadisk/provision-host/uis/lib/ │
│ ├── Scans services from /mnt/urbalurbadisk/provision-host/uis/services/ │
│ ├── Runs kubectl, ansible-playbook, helm │
│ └── Reads config from mounted .uis.extend/ and .uis.secrets/ │
│ │
│ Mounted volumes: │
│ ├── .uis.extend/ → /mnt/urbalurbadisk/.uis.extend/ (config) │
│ ├── .uis.secrets/ → /mnt/urbalurbadisk/.uis.secrets/ (secrets) │
│ └── .kube/config → /home/ansible/.kube/config (kubernetes access) │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
What Runs Where
| Operation | Runs On | Tool |
|---|---|---|
./uis start | HOST | Docker commands |
./uis stop | HOST | Docker commands |
./uis shell | HOST | docker exec -it |
| First-run folder creation | HOST | mkdir (in wrapper) |
./uis list | CONTAINER | uis-cli.sh |
./uis deploy | CONTAINER | uis-cli.sh → ansible |
./uis status | CONTAINER | uis-cli.sh → kubectl |
./uis enable/disable | CONTAINER | uis-cli.sh |
| Service scanning | CONTAINER | uis-cli.sh |
| Kubernetes operations | CONTAINER | kubectl/helm |
| Ansible playbooks | CONTAINER | ansible-playbook |
Config File Locations (Inside Container)
| Purpose | Container Path | Host Path (mounted) |
|---|---|---|
| Enabled services | /mnt/urbalurbadisk/.uis.extend/enabled-services.conf | ./.uis.extend/enabled-services.conf |
| Cluster config | /mnt/urbalurbadisk/.uis.extend/cluster-config.sh | ./.uis.extend/cluster-config.sh |
| Service templates | /mnt/urbalurbadisk/provision-host/uis/templates/ | (baked into container) |
| Secrets config | /mnt/urbalurbadisk/.uis.secrets/secrets-config/ | ./.uis.secrets/secrets-config/ |
Error Handling Strategy
All UIS commands follow consistent error handling:
Exit Codes
| Code | Meaning | Example |
|---|---|---|
| 0 | Success | Command completed |
| 1 | General error | Unknown command |
| 2 | Config error | Malformed config file, missing required field |
| 3 | Kubernetes error | Cluster unreachable, deployment failed |
| 4 | Dependency error | Required service not deployed |
Error Handling Functions
# lib/utilities.sh - Error handling helpers
die() {
log_error "$1"
exit "${2:-1}"
}
die_config() {
log_error "Configuration error: $1"
exit 2
}
die_k8s() {
log_error "Kubernetes error: $1"
log_error "Is the cluster running? Try: kubectl cluster-info"
exit 3
}
die_dependency() {
log_error "Dependency error: $1"
log_error "Try deploying the required service first"
exit 4
}
Deployment Failure Behavior
- Single service fails: Stop and report error, don't continue to next service
- Dependency not met: Stop and show which dependency is missing
- Cluster unreachable: Stop immediately with helpful error message
- Partial rollback: NOT automatic (too risky) - user must manually clean up