Skip to content

feat: WritableFS-based vendor operations#3

Merged
panyam merged 1 commit into
mainfrom
feat/vendor-writablefs
Apr 4, 2026
Merged

feat: WritableFS-based vendor operations#3
panyam merged 1 commit into
mainfrom
feat/vendor-writablefs

Conversation

@panyam

@panyam panyam commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

Adds WritableFS-based versions of all vendor/fetch operations. Data flows from network through decompression through tar parsing directly into WritableFS — zero temp files, zero os.* calls.

New API

// Fetch all sources to any WritableFS
results, err := templar.FetchAllSourcesFS(memFS, config)

// Write lock/readme to FS
templar.WriteLockFileFS(fsys, "lock.yaml", lock, info)
templar.WriteVendorReadmeFS(fsys, ".modules", info)

// Read lock from FS
lock, err := templar.LoadLockFileFS(fsys, "lock.yaml")

Pipeline

http.Get(url) → resp.Body (io.Reader)
  → gzip.NewReader (io.Reader)
    → tar.NewReader (io.Reader)
      → for each entry: fsys.WriteFile(path, bytes, perm)

No intermediate files. All writes go through WritableFS.

Test utilities

Unified makeTestTarGz(t, TarGzOpts, files) replaces the two separate helpers:

  • TarGzOpts.TopDir — GitHub-style nested directory
  • TarGzOpts.IncludePAX — PAX global header for edge case testing

5 new MemFS-based tests. All existing tests updated to shared helper.

Old path-based functions kept for backward compatibility.

@panyam panyam force-pushed the feat/vendor-writablefs branch 3 times, most recently from 149f4ef to 3ce636e Compare April 4, 2026 18:49
…pport

Breaking API changes:
- FileSystemLoader.Folders is now []FSFolder (was []string + []fs.FS)
- FSFolder{FS, Path}: pairs filesystem with folder path
- FSFolder.resolve(): auto-creates LocalFS if FS is nil
- NewFileSystemLoader(...FSFolder): takes FSFolder varargs
- LocalFolder(dir): convenience for local OS directories
- LocalFolders(dirs...): batch convenience for migration
- VendorConfig.FS: required WritableFS for template resolution
- SourceLoader uses config.FS for all template + vendor resolution

WritableFS vendor operations:
- FetchSourceFS, FetchAllSourcesFS, extractTarGzFS
- WriteLockFileFS, WriteVendorReadmeFS, LoadLockFileFS
- Data flows: HTTP → gzip → tar → fsys.WriteFile (zero temp files)

Test improvements:
- Shared makeTestTarGz(t, TarGzOpts, files): unified tarball helper
- namespace_test.go: rewritten with MemFS (0 os.* calls)
- vendoring_test.go: lock/readme/fallback tests → MemFS
- fetch_test.go: extract tests → MemFS via extractTarGzFS
- loadAndRender() helper for template loading via MemFS

Fixed: FileSystemLoader path handling for "." root folder with FS
Skipped: TestSourceLoader_RelativePathsInVendoredTemplates (#4)
Updated: examples/main.go, utils/basic-server.go, cmd/templar/debug.go

87 core tests passing.
@panyam panyam force-pushed the feat/vendor-writablefs branch from 3ce636e to ebaa5cd Compare April 4, 2026 18:54
@panyam panyam merged commit 5e2d801 into main Apr 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant