This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Helm plugin written in Go that compares rendered Kubernetes manifests between git commits.
# Build
make build # Output: bin/helm-git-diff
# Testing
make test # Run all tests
go test -v ./... # Alternative test command
go test -run TestName ./... # Run specific test
# Linting
make lint # Go linter (golangci-lint)
make lint-yaml # YAML linter
make lint-md # Markdown linter (markdownlint)
# Local Installation
helm plugin install . # Install from source
helm git-diff # Test plugin after install
# Cleanup
make clean # Remove bin/ directorySingle-package, flat structure - all code in main package within main.go:
main()→parseFlags()→checkGitRepo()→run()run()→ Either uses provided chart names or callsdetectChangedCharts()- For each chart →
diffChart()→ renders at both refs → compares manifests
- Configuration:
parseFlags(),shouldUseColor(),isTerminal() - Workflow:
run(),detectChangedCharts(),detectChartContext() - Core Operations:
diffChart(),renderChartFromWorkdir(),renderChartAtRef() - Utilities:
colorizeDiff(),isLibraryChart(),buildDependencies(),getChartPathsToExtract()
Central configuration object passed through all operations containing flags, chart paths, and state (differences detected, color usage).
- Base ref: Extracts chart files at commit using
git archive, renders in temp directory - Current ref:
- If
HEAD: Uses working directory directly (captures uncommitted changes) - Otherwise: Uses
git archivelike base ref
- If
- Both use
helm templateviaexec.Commandto render manifests
detectChangedCharts() uses git diff --name-only to find modified files, then maps them back to chart directories by looking for Chart.yaml in parent paths.
- Single package (
main), flat structure - no subdirectories - PascalCase for exported identifiers, camelCase for unexported
- Return errors explicitly - no panics except for unrecoverable failures
- Print errors to stderr, normal output to stdout
- Exit code 1 for all errors
- Minimal comments - code should be self-documenting
- Function ordering: config → workflow → operations → utilities
- Standard
testingpackage - Tests in
main_test.go - Use
t.TempDir()for temporary directories (auto-cleanup) - Skip tests when prerequisites unavailable (conditional checks)
- Create isolated git repos in tests for integration testing
- Clean up resources with
deferstatements
- Runtime: golang, Helm, Git
- Build: GNU Make
- Linting: golangci-lint, yamllint, markdownlint-cli
Defined in plugin.yaml:
- Binary location:
${HELM_PLUGIN_DIR}/bin/helm-git-diff - Install/update hook:
install-plugin.sh(builds from source) - Cross-platform support (Windows uses
.exeextension)