This guide helps agentic coding agents work effectively with the chartify codebase.
- Build CLI:
go build -o chartify ./cmd/chartify(25s, set timeout 60s+) - Build chart repo server:
go build -o chartreposerver ./cmd/chartreposerver - Download dependencies:
go mod download(15s, set timeout 120s+)
go mod download: 15 seconds (set timeout: 120+ seconds)go build: 25 seconds (set timeout: 60+ seconds)go test ./...: 60 seconds (set timeout: 180+ seconds)go vet ./...: 42 seconds (set timeout: 120+ seconds)go fmt ./...: 1 second (set timeout: 30+ seconds)- NEVER CANCEL build commands - they complete predictably
- Run all tests:
CGO_ENABLED=0 go test ./...(60s, set timeout 180s+) - Run with verbose output:
RETAIN_TEMP_DIR=1 go test -v ./... - Run single test:
go test -run TestFunctionName ./... - Run single test file:
go test -v chartify_test.go - Use Makefile:
make testormake test/verbose
- Format code:
go fmt ./... - Vet code:
go vet ./...(42s, set timeout 120s+) - NOTE: golangci-lint config (.golangci.yaml) has compatibility issues with recent versions. Use
go fmtandgo vetfor validation.
- Basic usage:
./chartify -o OUTPUT_DIR RELEASE_NAME CHART_OR_MANIFEST_PATH - Example with Helm chart:
./chartify -o /tmp/output test-release testdata/charts/log - Example with K8s manifests:
./chartify -o /tmp/output test-release testdata/kube_manifest_yml - Help:
./chartify -h
- Usage:
./chartreposerver CHARTS_DIR - Example:
./chartreposerver testdata/charts(serves charts on port 18080) - No help flag available - expects exactly 1 argument (charts directory)
- Order: standard library → third-party → local (github.com/helmfile/chartify prefix)
- Use
goimportsorgciformatter for consistent ordering - Example:
import ( "fmt" "os" "github.com/Masterminds/semver/v3" "helm.sh/helm/v3/pkg/registry" "github.com/helmfile/chartify" )
- Use
go fmt ./...before committing - Line length: 120 characters (per golangci.yaml)
- Use
gofmtwith simplify: true
- Use PascalCase for exported types, functions, constants
- Use camelCase for unexported variables and fields
- Type names should be descriptive (e.g.,
ChartifyOpts,PatchOpts) - Interface names typically end with "Option" when used for functional options pattern
- Use
func(t *testing.T)andt.Helper()for test helpers
- Always check and return errors explicitly
- Use early returns for error conditions
- Pattern:
if err != nil { return "", err }
- In tests, use
require.NoError(t, err)orrequire.Error(t, err)from testify - Use
require.Containsf(t, err.Error(), "msg")to check error messages
- Use
github.com/stretchr/testify/requirefor assertions - Use
github.com/google/go-cmp/cmpfor comparing complex structs - Test functions:
func TestFeatureName(t *testing.T) - Integration tests in
integration_test.go - Use
RETAIN_TEMP_DIR=1env var to keep temp directories for debugging - Setup functions use
t.Helper()and are called at start of tests
- The codebase uses functional options extensively
- Pattern:
type Option func(*Runner) error - Implementation:
func HelmBin(b string) Option { return func(r *Runner) error { r.HelmBinary = b; return nil } } - Usage:
New(HelmBin("helm"), UseHelm3(true))
- Exported types and functions should have godoc comments
- Comment explains "what" and "why", not "how"
- Use
// nolintsparingly when intentionally bypassing linters
chartify.go- Core library functionalitykustomize.go- Kustomize integrationpatch.go- Strategic merge and JSON patch logicreplace.go- Text replacement functionalityrequirements.go- Chart dependency managementrunner.go- Command execution utilitiescmd/chartify/main.go- CLI entry pointcmd/chartreposerver/main.go- HTTP server for charts
Always manually test CLI functionality after making changes to core library code:
- Test with Helm chart:
./chartify -o /tmp/test1 test-release testdata/charts/log && ls /tmp/test1/ - Test with K8s manifests:
./chartify -o /tmp/test2 test-release testdata/kube_manifest_yml && find /tmp/test2/ -type f - Verify help:
./chartify -h
Run these commands to ensure CI passes:
go fmt ./...
go vet ./...
CGO_ENABLED=0 go test ./...- Go 1.25.4+
- Helm v4.1.0 (helm command)
- Kustomize v5.8.0+ (kustomize command)
- Helm: Required for chart operations. Usually pre-installed as
helmcommand. - Kustomize: Required for kustomize integration. Usually pre-installed as
kustomizecommand. - Note: Helm repo add commands may fail in restricted network environments but tests can still pass.
- Helm repo operations may fail in restricted network environments - core functionality still works
- Some complex kustomize examples may fail helm template validation - this is expected
- Use environment variable
HELM_BINto override helm binary path for testing - Never cancel build commands - they take predictable time (see timeouts above)
- Use
RETAIN_TEMP_DIR=1environment variable to keep temporary directories for debugging - Build output goes to temporary directories that are automatically cleaned up
- The CLI expects exactly 2 positional arguments: RELEASE_NAME and CHART_PATH, with -o flag for output directory