kzdiff
v1.7.0
Published
CLI tool for comparing Kustomize build results between branches
Maintainers
Readme
kzdiff
A CLI tool for comparing Kustomize build results between branches or local directories.
Installation
npm install -g kzdiffPrerequisites
- Git
- Kustomize
Usage
Compare with remote branch (default: main)
kzdiff ./overlays/productionCompare with specific branch
kzdiff ./overlays/production -b developCompare local directories
# Compare staging and production environments
kzdiff ./overlays/staging ./overlays/production
# Compare any two Kustomize directories
kzdiff ./base ./overlays/devFilter specific resources
# Show only Deployments
kzdiff ./overlays/production -f kind=Deployment
# Show multiple resource types
kzdiff ./overlays/production -f kind=Deployment -f kind=Service
# Filter by name
kzdiff ./overlays/production -f name=my-app
# Filter by namespace
kzdiff ./overlays/production -f namespace=productionAdvanced filtering with JSONPath
# Filter by replica count
kzdiff ./overlays/production -f '$[?(@.spec.replicas>2)]'
# Filter by labels
kzdiff ./overlays/production -f '$[?(@.metadata.labels.team=="platform")]'Options
-b, --branch <ref>- Remote branch or commit to compare against (remote comparison only, default: auto-detect)-r, --ref <ref>- Same as -b/--branch-f, --filter <expr>- Filter resources using JSONPath expressions (can be specified multiple times)-v, --verbose- Enable verbose debug logging-h, --help- Display help--version- Show version number--- Pass remaining arguments to kustomize
Examples
Remote branch comparison
# Compare with auto-detected default branch (main/master)
kzdiff ./overlays/production
# Compare with specific branch
kzdiff ./overlays/production -b develop
# Compare with specific commit
kzdiff ./overlays/production -r b44e5dcad7aa15e023eb09f24a5b9b968cc46e13
# Filter to show only Deployments and Services
kzdiff ./overlays/production -f kind=Deployment -f kind=Service
# Complex filtering with JSONPath
kzdiff ./overlays/production -f '$[?(@.spec.replicas>2)]' -b main
# Pass options to kustomize
kzdiff ./overlays/production -- --enable-helm
# Combine multiple options
kzdiff ./overlays/production -b staging -f kind=Deployment -- --enable-helmLocal directory comparison
# Compare two local environments
kzdiff ./overlays/staging ./overlays/production
# Compare with filters
kzdiff ./overlays/staging ./overlays/production -f kind=Deployment
# Compare with kustomize options
kzdiff ./overlays/staging ./overlays/production -- --enable-helm
# Combine filters and kustomize options
kzdiff ./overlays/dev ./overlays/prod -f kind=Service -f kind=Deployment -- --load-restrictor=noneDevelopment
Prerequisites
- Bun 1.2.19+
- mise (for tool version management)
Setup
# Install dependencies
bun install
# Run tests
bun test
# Build standalone binary
bun run build:standalone
# Install locally for development
bun linkProject Structure
kzdiff/
├── src/
│ ├── cli.ts # CLI entry point
│ ├── kustomize.ts # Core Kustomize operations
│ ├── diff.ts # YAML diffing logic
│ ├── filter.ts # Resource filtering with JSONPath
│ └── debug.ts # Debug utilities
├── examples/ # Example Kustomize configurations
└── tests/ # Test filesLicense
MIT
