Skip to content

Commit

Permalink
core: add include/exclude name to host dir copy name (dagger#5469)
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Sipsma <erik@dagger.io>
  • Loading branch information
sipsma committed Jul 15, 2023
1 parent f34f974 commit 9cd69d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ func (host *Host) Directory(ctx context.Context, gw bkgw.Client, dirPath string,
llb.SessionID(gw.BuildOpts().SessionID),
}

opName := fmt.Sprintf("copy %s", absPath)

if len(filter.Exclude) > 0 {
opName += fmt.Sprintf(" (exclude %s)", strings.Join(filter.Exclude, ", "))
localOpts = append(localOpts, llb.ExcludePatterns(filter.Exclude))
}

if len(filter.Include) > 0 {
opName += fmt.Sprintf(" (include %s)", strings.Join(filter.Include, ", "))
localOpts = append(localOpts, llb.IncludePatterns(filter.Include))
}

Expand All @@ -89,7 +93,7 @@ func (host *Host) Directory(ctx context.Context, gw bkgw.Client, dirPath string,
// mount when possible
st := llb.Scratch().File(
llb.Copy(llb.Local(absPath, localOpts...), "/", "/"),
llb.WithCustomNamef("copy %s", absPath),
llb.WithCustomNamef(opName),
)

def, err := st.Marshal(ctx, llb.Platform(platform))
Expand Down
2 changes: 1 addition & 1 deletion core/integration/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestHostWorkdirExcludeInclude(t *testing.T) {
require.NoError(t, os.WriteFile(filepath.Join(dir, "subdir", "sub-file"), []byte("goodbye"), 0600))

ctx := context.Background()
c, err := dagger.Connect(ctx, dagger.WithWorkdir(dir))
c, err := dagger.Connect(ctx, dagger.WithWorkdir(dir), dagger.WithLogOutput(os.Stderr))
require.NoError(t, err)
defer c.Close()

Expand Down

0 comments on commit 9cd69d0

Please sign in to comment.