How roboll/helmfile works
Project type and purpose
• This is a Go-based CLI tool (“helmfile”) that orchestrates Helm chart releases across environments.
• It reads one or more Helmfile yamls, computes desired release state, and invokes Helm under the hood.
File structure
• Entry point: main.go (CLI bootstrap).
• pkg/app – command implementation and orchestration.
• pkg/argparser – CLI flag parsing.
• pkg/state – domain logic: load environment, chart dependencies, compute state.
• pkg/tmpl – templating engine (Go text templates + Sprig + secret expansion).
• pkg/helmexec – abstraction over invoking helm subprocess.
• pkg/remote – support for remote charts or config.
• pkg/plugins – pluggable value sources.
• pkg/event – event bus for logging/telemetry.
• scripts and hooks – pre/post build and CI pipeline.
• examples, docs, tests – illustrate usage and verify correctness.
Core architecture and component identification
a. CLI Layer
– Component: main.go + pkg/argparser
– Responsibility: parse user input, commands (sync, apply, diff, destroy).
b. Application Orchestrator
– Component: pkg/app
– Responsibility: coordinate loading of config, templating, state computation, helm execution.
c. Configuration & Environment Loader
– Component: pkg/app/config.go + pkg/environment
– Responsibility: read Helmfile, environment overrides, remote includes.
d. Templating Engine
– Component: pkg/tmpl + two-pass renderer
– Responsibility: render Helmfile/Gotemplate and inline secrets.
e. State Manager
– Component: pkg/state
– Responsibility: build desired release graph, filter by selectors, reconcile with cluster (helmfile.diff).
f. Helm Executor
– Component: pkg/helmexec + pkg/exectest
– Responsibility: shell out to helm CLI, capture logs, errors.
g. Plugins & Remote Integrations
– Component: pkg/plugins + pkg/remote
– Responsibility: fetch additional values, decrypt secrets, integrate with vault/Git.
h. Event & Logging
– Component: pkg/event
– Responsibility: publish events (start step, success, failure) for uniform logging.
i. CI/CD hooks & Docker/Vagrant
– .circleci, Dockerfile, Vagrantfile
– Responsibility: containerized build/test, local dev environments.
Relationships and data flow
– User invokes CLI (main.go) → argparser builds Cmd object → app.Run()
– app loads config via environment & config loader → passes raw YAML through tmpl rendering
– state manager receives rendered config → computes desired release state → emits events
– helmexec invoked per release → events logged → results aggregated
– final exit code and optionally state snapshot/write back.
Architectural patterns and principles
– Layered architecture: presentation (CLI) → application → domain (state) → infrastructure (helmexec).
– Single Responsibility: each pkg handles a distinct concern.
– Dependency injection: interfaces for exec, remote, plugin to allow testing/mocking.
– Event-driven logging: centralized event bus.
Final checklist
• All main components present and clearly labeled.
• Callouts for important design principles (DI, event bus, layered separation).