Skip to content

Added Exported libs to Hauler#579

Open
bcdurden wants to merge 2 commits intohauler-dev:mainfrom
bcdurden:enhancement/export-hauler-lib
Open

Added Exported libs to Hauler#579
bcdurden wants to merge 2 commits intohauler-dev:mainfrom
bcdurden:enhancement/export-hauler-lib

Conversation

@bcdurden
Copy link
Copy Markdown

PR Merge Request — Export Hauler Public API

Please check below, if the PR fulfills these requirements:

  • Commit(s) and code follow the repositories guidelines.
  • Test(s) have been added or updated to support these change(s).
  • Doc(s) have been added or updated to support these change(s).

Associated Links:

  • None

Types of Changes:

  • Enhancement/Feature

Proposed Changes:

Hauler has a gap in its exported Go libraries, making it difficult to call the tool programmatically as a library. This PR exports five functions from pkg/store/ that mirror the logic already present in cmd/hauler/cli/store/.

The CLI continues to use its existing internal code paths — this is not a refactoring. It is a parallel export of the CLI's capabilities into the public API surface. The five exports are:

  1. WriteExportsManifest — standalone manifest generation
  2. AddFile — file storage path export
  3. AddImageWithOpts + RewriteReference — image storage with configurable options and Docker Hub registry preservation
  4. AddChartWithOpts + helpers — Helm chart storage
  5. Sync — orchestrator composing the above, with SyncOptions.Validate()

For simpler commands, the mapping was straightforward. For compositional commands like sync, additional plumbing (SyncOptions, Validate(), related helpers) was added because the CLI's existing flag-heavy approach scattered these concerns across multiple internal types.

Verification/Testing of Changes:

The CLI does not yet call these new exported functions — that migration was out of scope. Unit tests are included in the same pkg/ packages where the functions live.

Manual verification: go test ./... and make build should pass. The changes are entirely additive — new pkg/store/ files with zero modifications to existing CLI behavior or internal packages.

Additional Context:

This is a single PR consolidating five exports. They are designed to be independently reviewable, but consolidated here for merge management.

Design decisions:

  • Public option structs use _Options suffix to avoid conflicts with existing internal/flags/ types.
  • The Exports type uses unexported fields with getter methods (Digests(), Records()) rather than exported fields to enforce invariants.
  • Retry logic is excluded from the public API — callers who need it should wrap the functions themselves.
  • New packages import only pkg/, never internal/, ensuring the public API is self-contained.

…sive. Does not affect hauler-cli command path, only external-facing import features added
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands Hauler’s public Go API by adding exported pkg/store helpers that mirror existing CLI store behaviors, enabling programmatic use of store sync/add/save capabilities.

Changes:

  • Added exported store APIs for syncing manifests/image lists and adding files/images/charts with options.
  • Added exports-manifest writer (manifest.json) support for OCI layouts, plus an Exports tracking type.
  • Added unit/integration-style tests for the new exported APIs and fixed chart repo URL handling in pkg/content/chart.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/store/sync.go New exported Sync API and SyncOptions plus internal helpers for manifest and image.txt processing
pkg/store/sync_test.go Tests for SyncOptions.Validate, Sync, and the internal sync helpers
pkg/store/save.go New exported WriteExportsManifest and Exports helper type for generating manifest.json
pkg/store/save_test.go Tests for WriteExportsManifest behavior and Exports getters
pkg/store/add.go New exported AddFile, AddImageWithOpts, RewriteReference, and chart/image helper utilities
pkg/store/add_test.go Tests covering file/image/chart addition, rewrites, and image discovery helpers
pkg/content/chart/chart.go Adjusted repoURL handling to avoid incorrectly prefixing empty repo URLs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/store/save.go
Comment thread pkg/store/save_test.go Outdated
Comment thread pkg/store/sync_test.go Outdated
Comment thread pkg/store/sync.go Outdated
Comment thread pkg/store/sync.go
Comment thread pkg/store/sync.go
Comment thread pkg/store/sync.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

2 participants