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
73 changes: 73 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Enhanced exclude pattern matching to support substring matching, path component matching, and improved glob pattern support
- Exclude patterns now work consistently in both sort-only and regular diff modes
- Fixed issue where exclude patterns like `--exclude 'configgen'` had no effect

## [0.1.8] - 2024-12-XX

### Added
- Exclude patterns support for sort-only mode
- Ability to skip specific files during sorting using `--exclude` flag
- Configuration file support for exclude patterns

### Changed
- Improved CLI documentation with exclude pattern examples

## [0.1.7] - 2024-12-XX

### Added
- Sort-only mode feature (`--sort-only` flag)
- Ability to sort YAML files without diff computation
- Support for recursive glob patterns (`**/*.yaml`)
- In-place sorting capability with `-i` flag

### Changed
- Enhanced CLI with new sorting options
- Updated README with sort-only examples

## [0.1.6] - 2024-12-XX

### Added
- Regex path parser feature
- Enhanced path pattern matching

### Changed
- Improved dependency versions
- Updated package lock file

## [0.1.5] - 2024-12-XX

### Added
- Initial crates.io publishing support
- CI/CD workflow improvements

### Changed
- Dependency upgrades
- Code cleanup and optimization

## [0.1.4] - 2024-12-XX

### Fixed
- Package lock file updates
- Various bug fixes and improvements

---

## Release Notes

This project follows semantic versioning. Each release includes:
- **Added** for new features
- **Changed** for changes in existing functionality
- **Deprecated** for soon-to-be removed features
- **Removed** for now removed features
- **Fixed** for any bug fixes
- **Security** for security vulnerabilities
22 changes: 17 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## Important Notes for Claude Code

* Always commit as current user, not as `claude`.

## Project Overview

YABE (YAml Base Extractor) is a GitOps YAML organizer tool written in Rust. It computes common base configurations among multiple YAML files and generates differences for each file, reducing duplication in GitOps workflows. The tool supports quorum-based diffing, YAML sorting, and both configuration file and command-line interfaces.
Expand Down Expand Up @@ -36,6 +40,12 @@ cargo run -- -i -r helm_values.yaml file1.yaml file2.yaml

# Using path patterns
cargo run -- -p "*.yaml" -p "configs/*.yaml"

# Using exclude patterns to skip files
cargo run -- -p "**/*.yaml" --exclude "target" --exclude "*.tmp"

# Sort-only mode with exclusions
cargo run -- --sort-only --sort-config-path ./sort-config.yaml -p "**/*.yaml" --exclude "target"
```

## Architecture
Expand All @@ -50,18 +60,20 @@ cargo run -- -p "*.yaml" -p "configs/*.yaml"

### Key Data Flow
1. **Input Processing**: Parse CLI args and config files, expand glob patterns
2. **YAML Loading**: Read and parse all input YAML files
3. **Base Merging**: If existing base provided, merge with each input file
4. **Diff Computation**: Compute diffs against read-only base (if provided)
5. **Quorum Processing**: Extract common base from diffs using quorum percentage
6. **Output Generation**: Write base file and per-file diffs (in-place or to output folder)
2. **File Filtering**: Apply exclude patterns to filter out unwanted files using multiple matching strategies
3. **YAML Loading**: Read and parse all remaining input YAML files
4. **Base Merging**: If existing base provided, merge with each input file
5. **Diff Computation**: Compute diffs against read-only base (if provided)
6. **Quorum Processing**: Extract common base from diffs using quorum percentage
7. **Output Generation**: Write base file and per-file diffs (in-place or to output folder)

### Configuration System
The tool supports both command-line arguments and YAML configuration files. Config file values are overridden by command-line arguments. Key configuration options:
- `read_only_base`: Reference YAML for diff computation
- `base`: Existing base to merge with inputs
- `quorum`: Percentage threshold for common base extraction
- `sort_config_path`: YAML sorting rules configuration
- `exclude_patterns`: Patterns to exclude files during processing (supports substring, glob, and path component matching)

### Testing Structure
Tests are organized by module:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "yabe-gitops"
description = "GitOps organizer"
repository = "https://github.com/dvrkn/yabe"
readme = "README.md"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
keywords = ["gitops", "kubernetes", "argocd", "yaml", "helm"]
license = "MIT"
Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,55 @@ Use the --sort-only flag to only sort YAML files without performing any diffing

# Sort files in-place while excluding terraform files
./yabe --sort-only --sort-config-path sort-config.yaml -p "./envs/**/*.yaml" --exclude "*.terraform.yaml" -i

# Exclude files by directory name (any file with "target" in the path)
./yabe --sort-only --sort-config-path sort-config.yaml -p "**/*.yaml" --exclude "target"

# Exclude multiple patterns - files in build directories and temp files
./yabe --sort-only --sort-config-path sort-config.yaml -p "**/*.yaml" --exclude "target" --exclude "build" --exclude "*.tmp"
```

### Exclude Patterns

The `--exclude` option supports flexible pattern matching to skip unwanted files during processing. You can specify multiple exclude patterns, and files matching any pattern will be skipped.

**Supported pattern types:**

1. **Substring matching**: Excludes files containing the pattern anywhere in the path
```bash
--exclude "target" # Excludes files with "target" in the path
--exclude "node_modules" # Excludes files with "node_modules" in the path
```

2. **Glob patterns**: Standard file matching patterns
```bash
--exclude "*.tmp" # Excludes all .tmp files
--exclude ".*" # Excludes hidden files
--exclude "test_*.yaml" # Excludes files starting with "test_"
```

3. **Path component matching**: Matches against individual directories or filenames
```bash
--exclude "build" # Excludes files in any "build" directory
--exclude "dist" # Excludes files in any "dist" directory
```

4. **Full path glob matching**: Complex path patterns
```bash
--exclude "*/temp/*" # Excludes files in any "temp" subdirectory
--exclude "target/**" # Excludes all files under target directory
```

**Examples:**
```bash
# Exclude multiple directory types
./yabe -p "**/*.yaml" --exclude "target" --exclude "node_modules" --exclude ".git"

# Exclude by file patterns and directories
./yabe -p "**/*.yaml" --exclude "*.terraform.yaml" --exclude "build" --exclude "dist"

# Complex exclusion for GitOps environments
./yabe --sort-only -p "**/*.yaml" --exclude "target" --exclude ".argocd" --exclude "*.secret.yaml"
```

### Using Configuration File
Expand Down