Skip to content

Commit 894ac18

Browse files
authored
Merge pull request #1 from pomcho555/feature/implement-rsp-cli
Implement RSP CLI tool for YAML ConfigMap string processing
2 parents be07cef + d1e9ebb commit 894ac18

File tree

21 files changed

+2138
-2
lines changed

21 files changed

+2138
-2
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!--
2+
Please use the following template to assist with creating an issue and to ensure a speedy resolution. If an area is not applicable, feel free to delete the area or mark with `N/A`
3+
-->
4+
5+
### Rust Version
6+
7+
* Use the output of `rustc -V`
8+
9+
### Affected Version of clap
10+
11+
* Can be found in Cargo.lock of your project (i.e. `grep clap Cargo.lock`)
12+
13+
### Bug or Feature Request Summary
14+
15+
16+
### Expected Behavior Summary
17+
18+
19+
### Actual Behavior Summary
20+
21+
22+
### Steps to Reproduce the issue
23+
24+
25+
### Sample Code or Link to Sample Code
26+
27+
28+
### Debug output

.github/workflows/audit.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * 0' # Run weekly on Sundays
8+
9+
jobs:
10+
audit:
11+
name: Security Audit
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout sources
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Rust toolchain
19+
uses: dtolnay/rust-toolchain@stable
20+
21+
- name: Install cargo-audit
22+
run: cargo install cargo-audit
23+
24+
- name: Run security audit
25+
run: cargo audit
26+
27+
- name: Check for vulnerable dependencies
28+
run: cargo audit --deny warnings

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
11+
steps:
12+
- name: Checkout Source
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Rust
16+
uses: dtolnay/rust-toolchain@stable
17+
18+
- name: Cache Cargo
19+
uses: actions/cache@v4
20+
with:
21+
path: |
22+
~/.cargo/registry
23+
~/.cargo/git
24+
target
25+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-cargo-
28+
29+
- name: Build Release
30+
run: cargo build --release
31+
32+
- name: Create Release Archive
33+
run: |
34+
mkdir -p release
35+
cp target/release/rsp release/
36+
cd release
37+
tar -czf rsp-${{ runner.os }}.tar.gz rsp
38+
39+
- name: Upload Build Artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: rsp-${{ runner.os }}
43+
path: release/rsp-${{ runner.os }}.tar.gz
44+
retention-days: 7
45+
46+
- name: Create Release
47+
if: github.ref == 'refs/heads/main'
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
tag_name: latest
51+
name: Latest Build
52+
body: Automated build from main branch
53+
draft: false
54+
prerelease: true
55+
files: release/rsp-${{ runner.os }}.tar.gz
56+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt, clippy
23+
24+
- name: Cache dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-cargo-
34+
35+
- name: Build
36+
run: cargo build --verbose
37+
38+
- name: Run tests
39+
run: cargo test --verbose
40+
41+
- name: Check formatting
42+
run: cargo fmt --all -- --check
43+
44+
- name: Run clippy
45+
run: cargo clippy --all-targets --all-features -- -D warnings
46+
47+
- name: Security audit
48+
run: |
49+
cargo install cargo-audit
50+
cargo audit
51+
52+
- name: Build release
53+
run: cargo build --release --verbose

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
name: Lint and Format Check
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout sources
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Rust toolchain
15+
uses: dtolnay/rust-toolchain@stable
16+
with:
17+
components: rustfmt, clippy
18+
19+
- name: Cache Cargo
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cargo/registry
24+
~/.cargo/git
25+
target
26+
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-cargo-lint-
29+
30+
- name: Check formatting
31+
run: cargo fmt --all -- --check
32+
33+
- name: Run Clippy
34+
run: cargo clippy --all-targets --all-features -- -D warnings
35+
36+
- name: Check documentation
37+
run: cargo doc --no-deps --all-features
38+
env:
39+
RUSTDOCFLAGS: -D warnings

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest]
12+
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Rust toolchain
18+
uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt, clippy
21+
22+
- name: Cache Cargo
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ matrix.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ matrix.os }}-cargo-test-
32+
33+
- name: Run tests
34+
run: cargo test --all --verbose

.github/workflows/toc.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Generate Table of Contents
2+
3+
on:
4+
push:
5+
paths:
6+
- 'README.md'
7+
- 'docs/**/*.md'
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
generate-toc:
14+
name: Generate TOC
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout sources
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Generate TOC
24+
uses: technote-space/toc-generator@v4
25+
with:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
TARGET_PATHS: 'README.md'
28+
TOC_TITLE: '## Table of Contents'
29+
CREATE_PR: false
30+
COMMIT_MESSAGE: 'docs: update table of contents'
31+
COMMIT_NAME: 'github-actions[bot]'
32+
COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com'

CLAUDE.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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

Comments
 (0)