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
..
2025-10-07 10:32:04 +01:00

Taskserv Validation & Testing System

Version: 1.0.0 Status: Production Ready


Quick Start

Validate Before Deployment

# Complete validation (recommended)
provisioning taskserv validate kubernetes

# Check mode (dry-run)
provisioning taskserv create kubernetes --check

# Sandbox testing
provisioning taskserv test kubernetes --runtime docker
```plaintext

---

## Available Commands

| Command | Description |
|---------|-------------|
| `taskserv validate <name>` | Multi-level validation (Nickel, templates, scripts, dependencies) |
| `taskserv check-deps <name>` | Check dependencies against infrastructure |
| `taskserv create <name> --check` | Dry-run with preview (no actual deployment) |
| `taskserv test <name>` | Test in sandbox container |

---

## Validation Levels

### 1. **Static Validation**

- ✅ Nickel schema syntax
- ✅ Jinja2 template syntax
- ✅ Shell script validation (shellcheck)
- ⚡ **Fast** - No infrastructure needed

### 2. **Dependency Validation**

- ✅ Required dependencies available
- ✅ Conflict detection
- ✅ Resource requirements
- ✅ Health check configuration

### 3. **Check Mode (Dry-Run)**

- ✅ All static validations
- ✅ Dependency checking
- ✅ Configuration preview
- ✅ Prerequisites verification
- 🚫 **No actual deployment**

### 4. **Sandbox Testing**

- ✅ Package prerequisites
- ✅ Configuration validity
- ✅ Script execution
- ✅ Health check simulation
- 🐳 Requires Docker/Podman

---

## Examples

### Complete Validation Workflow

```bash
# 1. Static validation
provisioning taskserv validate kubernetes --level static

# 2. Check dependencies
provisioning taskserv check-deps kubernetes --infra my-project

# 3. Dry-run with preview
provisioning taskserv create kubernetes --check -v

# 4. Sandbox testing
provisioning taskserv test kubernetes --runtime docker

# 5. Deploy (after all checks pass)
provisioning taskserv create kubernetes
```plaintext

### Quick Validation

```bash
# All validations in one command
provisioning taskserv validate kubernetes --level all -v
```plaintext

### CI/CD Integration

```yaml
# .gitlab-ci.yml
validate:
  script:
    - provisioning taskserv validate kubernetes --out json
    - provisioning taskserv check-deps kubernetes --infra prod

test:
  script:
    - provisioning taskserv test kubernetes --runtime docker

deploy:
  script:
    - provisioning taskserv create kubernetes
  only:
    - main
```plaintext

---

## Module Structure

```plaintext
taskservs/
├── validate.nu           # Main validation framework
├── deps_validator.nu     # Dependency validation
├── check_mode.nu         # Enhanced check mode
├── test.nu               # Sandbox testing
├── create.nu             # Taskserv creation
├── delete.nu             # Taskserv deletion
├── update.nu             # Taskserv updates
├── generate.nu           # Configuration generation
├── handlers.nu           # Core handlers
├── run.nu                # Execution engine
├── utils.nu              # Utilities
├── ops.nu                # Operations
└── mod.nu                # Module exports
```plaintext

---

## Key Features

### ✅ **Multi-Level Validation**

- Static, dependency, prerequisite, and health check validation
- Fail-fast with clear error messages
- Verbose mode for detailed output

### 🎯 **Enhanced Check Mode**

- Comprehensive dry-run before deployment
- Configuration preview
- File listing
- No SSH required in check mode

### 🐳 **Sandbox Testing**

- Isolated container environment
- Docker and Podman support
- Keep containers for debugging
- Multiple test scenarios

### 📊 **Multiple Output Formats**

- Text (default, human-readable)
- JSON (for automation)
- YAML (for configuration)

### 🔗 **Dependency Management**

- Automatic dependency detection
- Conflict resolution
- Resource requirement validation
- Health check configuration

---

## Dependencies

### Required

- Nushell 0.107.1+
- Nickel 0.11.3+

### Optional

- `shellcheck` - Enhanced script validation
- `docker` or `podman` - Sandbox testing
- `glow` or `bat` - Better markdown rendering

---

## Documentation

- [Complete Validation Guide](../../../docs/user/taskserv-validation-guide.md)
- [Nickel Schema Patterns](../../../.claude/kcl_idiomatic_patterns.md)
- [Taskserv Development](../../../docs/development/taskserv-development.md)

---

## Troubleshooting

### Validation Errors

```bash
# Check Nickel syntax
nickel fmt <file>.ncl

# Validate dependencies manually
nickel run extensions/taskservs/<name>/nickel/dependencies.ncl

# Run with verbose output
provisioning taskserv validate <name> -v
```plaintext

### Sandbox Testing Issues

```bash
# Check Docker is running
docker ps

# Keep container for debugging
provisioning taskserv test <name> --keep

# Connect to container
docker exec -it taskserv-test-<name> bash
```plaintext

### shellcheck not found

```bash
# macOS
brew install shellcheck

# Ubuntu/Debian
apt install shellcheck
```plaintext

---

## Contributing

When adding new validation checks:

1. Add validation function in appropriate module
2. Update `validate.nu` to call new check
3. Add tests in `tests/` directory
4. Update documentation
5. Add examples in this README

---

## Version History

| Version | Date | Changes |
|---------|------|---------|
| 1.0.0 | 2025-10-06 | Initial validation and testing system |

---

**Maintained By**: Infrastructure Team
**Status**: ✅ Production Ready