How anchore/binny works
Main Components
• CLI Frontend (cmd/binny)
• Entry point (main.go) invoking Cobra commands under cmd/binny/cli/command
• Parses flags, subcommands: install, check, update, list, add
• Core Engine
• Configuration Loader (.binny.yaml) → internal data structures
• Event Bus (internal/bus) for decoupled event handling
• Task Executor (event/) that drives operations per tool
• Install & Version Modules (tool/ & cmd/binny/cli/internal/yamlpatch)
• Multiple install methods: githubrelease, goinstall, hostedshell
• Multiple version resolvers: github-release, go-proxy, git, etc.
• State Store
• Local JSON store (store.go at project root) representing installed binaries
• Directory layout under user‐specified install path (e.g. $DEST/bin/)
• External Services
• GitHub Releases API
• Go Proxy (proxy.golang.org)
• Git repos on disk (for git resolver)
• Hosted shell scripts (arbitrary URLs)
• Supporting Utilities
• Logging & redaction (internal/log, internal/redact)
• File download & checksum (internal/download_file)
• Semver parsing (internal/semver)
Relationships & Data Flow
• The frontend reads the Config File, then dispatches a command event into the Event Bus.
• The Task Executor picks up events, coordinates the Install & Version Modules.
• Each module may:
• Call out to an External Service
• Download binaries or run go install
• Emit events (success/failure) back on the bus
• On success, the State Store is updated (writes JSON).
• The CLI returns status and prints output via UI components (internal/ui).
Architectural Patterns
• Modular Plugins: Each install method and resolver is a swap-in module under tool/.
• Event-Driven Core: The central bus decouples CLI commands from execution logic.
• Separation of Concerns:
• CLI concerns in cmd/
• Business logic in internal/ & tool/
• Persistence in store.go
• Testing scaffolds in test/, tool/*/testdata
Diagramming Advice
• CLI Frontend, Config Loader, Event Bus, Executor, Modules, Store, External Services
• Green = User-facing (CLI/UI)
• Blue = Core Engine
• Orange = External integrations
• Gray = Persistence