Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: allow exposing fsutil.FS through SolveOpts
Browse files Browse the repository at this point in the history
This completes propogating the fsutil.FS abstraction into the SolveOpt,
deprecating the old LocalDirs.

Since this is entirely a golang-level abstraction, we could potentially
investigate just removing the old LocalDirs directly.

Signed-off-by: Justin Chadwell <[email protected]>
jedevc committed Aug 8, 2023

Verified

This commit was signed with the committer’s verified signature.
dmtucker David Tucker
1 parent 2437e2f commit b69a117
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions client/solve.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ import (

type SolveOpt struct {
Exports []ExportEntry
LocalDirs map[string]string
LocalDirs map[string]string // Deprecated: use LocalFiles
LocalFiles map[string]fsutil.FS
OCIStores map[string]content.Store
SharedKey string
Frontend string
@@ -90,7 +91,19 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
return nil, errors.New("invalid with def and cb")
}

syncedDirs, err := prepareSyncedFiles(def, opt.LocalDirs)
sourceFS := make(map[string]fsutil.FS)
for k, fs := range opt.LocalFiles {
sourceFS[k] = fs
}
for k, dir := range opt.LocalDirs {
fs, err := fsutil.NewFS(dir)
if err != nil {
return nil, err
}
sourceFS[k] = fs
}

syncedDirs, err := prepareSyncedFiles(def, sourceFS)
if err != nil {
return nil, err
}
@@ -361,16 +374,7 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG
return res, nil
}

func prepareSyncedFiles(def *llb.Definition, localDirs map[string]string) (filesync.StaticDirSource, error) {
localFiles := make(map[string]fsutil.FS)
for name, d := range localDirs {
fs, err := fsutil.NewFS(d)
if err != nil {
return nil, err
}
localFiles[name] = fs
}

func prepareSyncedFiles(def *llb.Definition, localFiles map[string]fsutil.FS) (filesync.StaticDirSource, error) {
resetUIDAndGID := func(p string, st *fstypes.Stat) fsutil.MapResult {
st.Uid = 0
st.Gid = 0

0 comments on commit b69a117

Please sign in to comment.