Add Garden accessor methods for manifest and blob store access.

Expose GetManifest, BlobExists, ReadBlob, WriteBlob, and
ReplaceManifest on *Garden to support future gRPC and higher-level
operations without breaking encapsulation. Includes 5 unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 23:19:48 -07:00
parent 0113703908
commit 34330a35ef
2 changed files with 188 additions and 0 deletions

View File

@@ -98,6 +98,35 @@ func (g *Garden) SetClock(c clockwork.Clock) {
g.clock = c
}
// GetManifest returns the current manifest.
func (g *Garden) GetManifest() *manifest.Manifest {
return g.manifest
}
// BlobExists reports whether a blob with the given hash exists in the store.
func (g *Garden) BlobExists(hash string) bool {
return g.store.Exists(hash)
}
// ReadBlob returns the contents of the blob with the given hash.
func (g *Garden) ReadBlob(hash string) ([]byte, error) {
return g.store.Read(hash)
}
// WriteBlob writes data to the blob store and returns the hash.
func (g *Garden) WriteBlob(data []byte) (string, error) {
return g.store.Write(data)
}
// ReplaceManifest atomically replaces the current manifest.
func (g *Garden) ReplaceManifest(m *manifest.Manifest) error {
if err := m.Save(g.manifestPath); err != nil {
return fmt.Errorf("saving manifest: %w", err)
}
g.manifest = m
return nil
}
// Add tracks new files, directories, or symlinks. Each path is resolved
// to an absolute path, inspected for its type, and added to the manifest.
// Regular files are hashed and stored in the blob store.