Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated client.SolveOpts.LocalDirs member #4644

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 0 additions & 44 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ var allTests = []func(t *testing.T, sb integration.Sandbox){
testSnapshotWithMultipleBlobs,
testExportLocalNoPlatformSplit,
testExportLocalNoPlatformSplitOverwrite,
testSolverOptLocalDirsStillWorks,
}

func TestIntegration(t *testing.T) {
Expand Down Expand Up @@ -1557,49 +1556,6 @@ func testRelativeWorkDir(t *testing.T, sb integration.Sandbox) {
require.Equal(t, []byte("/test1/test2\n"), dt)
}

// TODO: remove this test once `client.SolveOpt.LocalDirs`, now marked as deprecated, is removed.
// For more context on this test, please check:
// https://github.com/moby/buildkit/pull/4583#pullrequestreview-1847043452
func testSolverOptLocalDirsStillWorks(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")

c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()

out := llb.Image("docker.io/library/busybox:latest").
File(llb.Copy(llb.Local("mylocal"), "input.txt", "input.txt")).
Run(llb.Shlex(`sh -c "/bin/rev < input.txt > /out/output.txt"`)).
AddMount(`/out`, llb.Scratch())

def, err := out.Marshal(sb.Context())
require.NoError(t, err)

srcDir := integration.Tmpdir(t,
fstest.CreateFile("input.txt", []byte("Hello World"), 0600),
)

destDir := integration.Tmpdir(t)

_, err = c.Solve(sb.Context(), def, SolveOpt{
LocalDirs: map[string]string{
"mylocal": srcDir.Name,
},
Exports: []ExportEntry{
{
Type: ExporterLocal,
OutputDir: destDir.Name,
},
},
}, nil)

require.NoError(t, err)

dt, err := os.ReadFile(filepath.Join(destDir.Name, "output.txt"))
require.NoError(t, err)
require.Equal(t, []byte("dlroW olleH"), dt)
}

func testFileOpMkdirMkfile(t *testing.T, sb integration.Sandbox) {
requiresLinux(t)
c, err := New(sb.Context(), sb.Address())
Expand Down
26 changes: 1 addition & 25 deletions client/solve.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (

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

mounts, err := prepareMounts(&opt)
if err != nil {
return nil, err
}
syncedDirs, err := prepareSyncedFiles(def, mounts)
syncedDirs, err := prepareSyncedFiles(def, opt.LocalMounts)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -543,22 +538,3 @@ func parseCacheOptions(ctx context.Context, isGateway bool, opt SolveOpt) (*cach
}
return &res, nil
}

func prepareMounts(opt *SolveOpt) (map[string]fsutil.FS, error) {
// merge local mounts and fallback local directories together
mounts := make(map[string]fsutil.FS)
for k, mount := range opt.LocalMounts {
mounts[k] = mount
}
for k, dir := range opt.LocalDirs {
mount, err := fsutil.NewFS(dir)
if err != nil {
return nil, err
}
if _, ok := mounts[k]; ok {
return nil, errors.Errorf("local mount %s already exists", k)
}
mounts[k] = mount
}
return mounts, nil
}