|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +RSP (Raw String Peeler) is a Rust CLI tool that converts escaped strings embedded in YAML ConfigMaps into properly formatted multi-line strings using YAML's pipe (`|`) syntax. It transforms hard-to-read escaped JSON/YAML/TOML strings into human-readable format. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +**Build the project:** |
| 12 | +```bash |
| 13 | +cargo build |
| 14 | +``` |
| 15 | + |
| 16 | +**Run the application:** |
| 17 | +```bash |
| 18 | +cargo run |
| 19 | +``` |
| 20 | + |
| 21 | +**Run tests:** |
| 22 | +```bash |
| 23 | +cargo test |
| 24 | +``` |
| 25 | + |
| 26 | +**Build for release:** |
| 27 | +```bash |
| 28 | +cargo build --release |
| 29 | +``` |
| 30 | + |
| 31 | +**Check code without building:** |
| 32 | +```bash |
| 33 | +cargo check |
| 34 | +``` |
| 35 | + |
| 36 | +## Architecture |
| 37 | + |
| 38 | +- **Entry point:** `src/main.rs` - Main CLI entry point |
| 39 | +- **CLI module:** `src/cli.rs` - Command-line interface using clap |
| 40 | +- **Core logic:** `src/peeler.rs` - YAML parsing and string processing |
| 41 | +- **Error handling:** `src/error.rs` - Custom error types using thiserror |
| 42 | +- **Specification:** `specs/README.md` - Contains detailed requirements and expected behavior |
| 43 | +- **Package configuration:** `Cargo.toml` - Uses Rust 2024 edition with dependencies: clap, serde, serde_yaml, anyhow, thiserror |
| 44 | + |
| 45 | +## Key functionality |
| 46 | + |
| 47 | +1. Parses YAML files containing Kubernetes ConfigMaps |
| 48 | +2. Detects escaped string values in the `data` section for keys ending with `.yaml`, `.yml`, `.json`, or `.toml` |
| 49 | +3. Converts escaped strings to proper YAML multi-line format using pipe (`|`) syntax |
| 50 | +4. Outputs formatted YAML to stdout or specified file |
| 51 | + |
| 52 | +## Testing |
| 53 | + |
| 54 | +Comprehensive test suite covering: |
| 55 | + |
| 56 | +**Unit Tests (`tests/peeler_tests.rs`):** |
| 57 | +- String unescaping functionality (normal and edge cases) |
| 58 | +- ConfigMap processing logic |
| 59 | +- File extension detection |
| 60 | +- YAML serialization with pipe syntax |
| 61 | +- File I/O operations |
| 62 | + |
| 63 | +**Integration Tests (`tests/cli_tests.rs`):** |
| 64 | +- CLI command execution (help, version, peel) |
| 65 | +- File input/output handling |
| 66 | +- Error conditions and edge cases |
| 67 | +- Command-line argument parsing |
| 68 | + |
| 69 | +**Edge Case Tests (`tests/edge_cases_tests.rs`):** |
| 70 | +- Empty and malformed YAML files |
| 71 | +- Non-ConfigMap YAML documents |
| 72 | +- Large strings and complex escaping |
| 73 | +- Unicode content and special characters |
| 74 | +- Binary file handling |
| 75 | + |
| 76 | +**Run tests:** |
| 77 | +```bash |
| 78 | +cargo test # All tests |
| 79 | +cargo test --test peeler_tests # Unit tests only |
| 80 | +cargo test --test cli_tests # CLI integration tests |
| 81 | +cargo test --test edge_cases_tests # Edge case tests |
| 82 | +``` |
| 83 | + |
| 84 | +**Sample data:** `tests/test_data/sample_configmap.yaml` contains example input for manual testing. |
| 85 | + |
| 86 | +## Contribution |
| 87 | + |
| 88 | +IMPORTANT: Please check same cases locally as CICD does, before commit any changes such as `cargo test --all --verbose` |
0 commit comments