Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
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`
-->

### Rust Version

* Use the output of `rustc -V`

### Affected Version of clap

* Can be found in Cargo.lock of your project (i.e. `grep clap Cargo.lock`)

### Bug or Feature Request Summary


### Expected Behavior Summary


### Actual Behavior Summary


### Steps to Reproduce the issue


### Sample Code or Link to Sample Code


### Debug output
28 changes: 28 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Security Audit

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0' # Run weekly on Sundays

jobs:
audit:
name: Security Audit
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-audit
run: cargo install cargo-audit

- name: Run security audit
run: cargo audit

- name: Check for vulnerable dependencies
run: cargo audit --deny warnings
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout Source
uses: actions/checkout@v4

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Build Release
run: cargo build --release

- name: Create Release Archive
run: |
mkdir -p release
cp target/release/rsp release/
cd release
tar -czf rsp-${{ runner.os }}.tar.gz rsp

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: rsp-${{ runner.os }}
path: release/rsp-${{ runner.os }}.tar.gz
retention-days: 7

- name: Create Release
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: Latest Build
body: Automated build from main branch
draft: false
prerelease: true
files: release/rsp-${{ runner.os }}.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Security audit
run: |
cargo install cargo-audit
cargo audit

- name: Build release
run: cargo build --release --verbose
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-lint-

- name: Check formatting
run: cargo fmt --all -- --check

- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Check documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests

on: [push, pull_request]

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-cargo-test-

- name: Run tests
run: cargo test --all --verbose
32 changes: 32 additions & 0 deletions .github/workflows/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Generate Table of Contents

on:
push:
paths:
- 'README.md'
- 'docs/**/*.md'

permissions:
contents: write

jobs:
generate-toc:
name: Generate TOC
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Generate TOC
uses: technote-space/toc-generator@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_PATHS: 'README.md'
TOC_TITLE: '## Table of Contents'
CREATE_PR: false
COMMIT_MESSAGE: 'docs: update table of contents'
COMMIT_NAME: 'github-actions[bot]'
COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
88 changes: 88 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

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.

## Commands

**Build the project:**
```bash
cargo build
```

**Run the application:**
```bash
cargo run
```

**Run tests:**
```bash
cargo test
```

**Build for release:**
```bash
cargo build --release
```

**Check code without building:**
```bash
cargo check
```

## Architecture

- **Entry point:** `src/main.rs` - Main CLI entry point
- **CLI module:** `src/cli.rs` - Command-line interface using clap
- **Core logic:** `src/peeler.rs` - YAML parsing and string processing
- **Error handling:** `src/error.rs` - Custom error types using thiserror
- **Specification:** `specs/README.md` - Contains detailed requirements and expected behavior
- **Package configuration:** `Cargo.toml` - Uses Rust 2024 edition with dependencies: clap, serde, serde_yaml, anyhow, thiserror

## Key functionality

1. Parses YAML files containing Kubernetes ConfigMaps
2. Detects escaped string values in the `data` section for keys ending with `.yaml`, `.yml`, `.json`, or `.toml`
3. Converts escaped strings to proper YAML multi-line format using pipe (`|`) syntax
4. Outputs formatted YAML to stdout or specified file

## Testing

Comprehensive test suite covering:

**Unit Tests (`tests/peeler_tests.rs`):**
- String unescaping functionality (normal and edge cases)
- ConfigMap processing logic
- File extension detection
- YAML serialization with pipe syntax
- File I/O operations

**Integration Tests (`tests/cli_tests.rs`):**
- CLI command execution (help, version, peel)
- File input/output handling
- Error conditions and edge cases
- Command-line argument parsing

**Edge Case Tests (`tests/edge_cases_tests.rs`):**
- Empty and malformed YAML files
- Non-ConfigMap YAML documents
- Large strings and complex escaping
- Unicode content and special characters
- Binary file handling

**Run tests:**
```bash
cargo test # All tests
cargo test --test peeler_tests # Unit tests only
cargo test --test cli_tests # CLI integration tests
cargo test --test edge_cases_tests # Edge case tests
```

**Sample data:** `tests/test_data/sample_configmap.yaml` contains example input for manual testing.

## Contribution

IMPORTANT: Please check same cases locally as CICD does, before commit any changes such as `cargo test --all --verbose`
Loading