How bitnami/charts-syncer works
Project type and purpose
• This is a Go-based command-line tool (“charts-syncer”) whose job is to synchronize Helm chart packages and their associated container images between source and target repositories (Helm, OCI, ChartMuseum, Harbor, local).
• It can operate online or “air-gapped” via a two-step download-and-upload flow and can be run manually or as a Kubernetes CronJob.
File structure
• Top-level:
• cmd/ – the CLI entrypoint and commands (main.go, sync.go, version.go)
• api/ – Protobuf definitions and generated Go code for configuration and index artifacts
• internal/ – internal packages (config loader, cache, indexer, logging, utilities)
• pkg/ – the core library:
· pkg/client – pluggable clients for source/target chart and OCI registries
· pkg/syncer – the orchestration logic to sync charts/images
• deployment/– Kubernetes CronJob manifests and Kustomize config
• docs/, examples/, test/ – supporting documentation, samples, and end-to-end scripts
• Presence of Protobuf files (api/config.proto, internal/indexer/api/index.proto) indicates a strongly-typed config & index format.
• Makefile, Dockerfile, Go modules and GitHub workflows define build, CI, release and deployment.
README for additional insights
• Describes “sync” use cases, advanced flags, supported repository kinds, two-step air-gap mode.
• Mentions a Kubernetes CronJob for scheduled synchronization.
• Confirms key architectural pieces: source repo, target repo, chart packaging, image relocation, config loader.
Components
a. Main components
• CLI Frontend (cmd/*.go)
• Configuration Loader (internal/config)
• Sync Orchestrator (pkg/syncer)
• Indexer (internal/indexer)
• Chart-client plugins (pkg/client/repo/*)
• Container-registry client plugins (pkg/client/repo/*/oci)
• Cache (internal/cache)
• Utilities & Logging (internal/utils, internal/log)
• Kubernetes CronJob (deployment/cronjob.yaml)
• External Services: Source Helm/OCI/ChartMuseum/Harbor, Target Helm/OCI, Container Registry
b. Relationships & interactions
1. User invokes the CLI (charts-syncer sync) or CronJob triggers it.
2. CLI parses flags and loads config via Protobuf (api/config.pb.go → internal/config).
3. Sync Orchestrator (pkg/syncer):
– Uses Indexer to fetch/parse chart index from source repo.
– Iterates charts: for each, uses chart-client plugin to download chart package.
– Extracts and rewrites chart metadata (values.yaml, Chart.yaml, Images.lock) via internal/utils.
– Uses container-registry client plugin to pull and push image layers (unless skipImages).
– Uses chart-client plugin to push modified chart package to target.
– Caches downloads in internal/cache.
– Logs progress via internal/log.
4. On air-gap mode: orchestrator writes files to local disk (LOCAL target), to be uploaded in a second step.
c. Architectural patterns & design principles
• Layered modular design: cmd → internal → pkg → external plugins
• Dependency injection via interfaces in pkg/client to support multiple repo kinds
• Protobuf for strongly-typed config and index serialization
• Separation of concerns: indexing, chart transformation, image relocation
• Cache abstraction to support in-memory or on-disk caching
d. Relevant technologies, frameworks, libraries
• Go modules (go.mod), Protobuf (prototool.yaml)
• Kubernetes CronJob for scheduled runs
• Helm repo clients, OCI registry APIs
• Kustomize for deployment manifests
• GitHub Actions, goreleaser for CI/CD
• Docker container (Dockerfile)