Skip to content

Commit

Permalink
vendor: github.com/crazy-max/fsutil@fs-root-getter
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Feb 12, 2024
1 parent 562a9a9 commit 5a7b9d9
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 73 deletions.
23 changes: 11 additions & 12 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,12 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
defers = append(defers, releaseLoad)

if lm, ok := so.LocalMounts["context"]; ok {
sharedKey := lm.(fs).root
if p, err := filepath.Abs(sharedKey); err == nil {
sharedKey = filepath.Base(p)
if sharedKey, ok := fsutil.GetRoot(lm); ok && sharedKey != "" {
if p, err := filepath.Abs(sharedKey); err == nil {
sharedKey = filepath.Base(p)
}
so.SharedKey = sharedKey + ":" + tryNodeIdentifier(configDir)
}
so.SharedKey = sharedKey + ":" + tryNodeIdentifier(configDir)
}

if opt.Pull {
Expand Down Expand Up @@ -1147,16 +1148,15 @@ func LoadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, pw prog
dockerfileReader = buf
inp.ContextPath, _ = os.MkdirTemp("", "empty-dir")
toRemove = append(toRemove, inp.ContextPath)
lm, err := newFS(inp.ContextPath)
lm, err := fsutil.NewFS(inp.ContextPath)
if err != nil {
return nil, err
} else {
target.LocalMounts["context"] = lm
}
target.LocalMounts["context"] = lm
}
}
case isLocalDir(inp.ContextPath):
lm, err := newFS(inp.ContextPath)
lm, err := fsutil.NewFS(inp.ContextPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1212,7 +1212,7 @@ func LoadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, pw prog
}

if dockerfileDir != "" {
lm, err := newFS(dockerfileDir)
lm, err := fsutil.NewFS(dockerfileDir)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1311,12 +1311,11 @@ func LoadInputs(ctx context.Context, d *driver.DriverHandle, inp Inputs, pw prog
if k == "context" || k == "dockerfile" {
localName = "_" + k // underscore to avoid collisions
}
lm, err := newFS(v.Path)
lm, err := fsutil.NewFS(v.Path)
if err != nil {
return nil, err
} else {
target.LocalMounts[localName] = lm
}
target.LocalMounts[localName] = lm
target.FrontendAttrs["context:"+k] = "local:" + localName
}

Expand Down
21 changes: 0 additions & 21 deletions build/fs.go

This file was deleted.

6 changes: 5 additions & 1 deletion build/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/moby/buildkit/client"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
)

const DockerfileLabel = "com.docker.image.source.entrypoint"
Expand Down Expand Up @@ -116,7 +117,10 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st
return
}
for k, lm := range so.LocalMounts {
dir := lm.(fs).root
dir, ok := fsutil.GetRoot(lm)
if !ok || dir == "" {
continue
}
dir, err = filepath.EvalSymlinks(dir)
if err != nil {
continue
Expand Down
6 changes: 3 additions & 3 deletions build/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestGetGitAttributesDirty(t *testing.T) {
func TestLocalDirs(t *testing.T) {
setupTest(t)

wdfs, err := newFS(".")
wdfs, err := fsutil.NewFS(".")
require.NoError(t, err)

so := &client.SolveOpt{
Expand Down Expand Up @@ -197,10 +197,10 @@ func TestLocalDirsSub(t *testing.T) {
gitutil.GitCommit(c, t, "initial commit")
gitutil.GitSetRemote(c, t, "origin", "[email protected]:docker/buildx.git")

ctxfs, err := newFS(".")
ctxfs, err := fsutil.NewFS(".")
require.NoError(t, err)

dockerfilefs, err := newFS("app")
dockerfilefs, err := fsutil.NewFS("app")
require.NoError(t, err)

so := &client.SolveOpt{
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/tonistiigi/fsutil => github.com/crazy-max/fsutil v0.0.0-20240210105035-b48ba0a28213
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ github.com/containerd/ttrpc v1.2.2/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf
github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4=
github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crazy-max/fsutil v0.0.0-20240210105035-b48ba0a28213 h1:V3gWlzhVvrZmytk4AmrNy+Xk8J3c6LgB+o5owRqUU4Y=
github.com/crazy-max/fsutil v0.0.0-20240210105035-b48ba0a28213/go.mod h1:9kMVqMyQ/Sx2df5LtnGG+nbrmiZzCS7V6gjW3oGHsvI=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -452,8 +454,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c=
github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw=
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302 h1:ZT8ibgassurSISJ1Pj26NsM3vY2jxFZn63Nd/TpHmRw=
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302/go.mod h1:9kMVqMyQ/Sx2df5LtnGG+nbrmiZzCS7V6gjW3oGHsvI=
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea h1:SXhTLE6pb6eld/v/cCndK0AMpt1wiVFb/YYmqB3/QG0=
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea/go.mod h1:WPnis/6cRcDZSUvVmezrxJPkiO87ThFYsoUiMwWNDJk=
github.com/tonistiigi/vt100 v0.0.0-20230623042737-f9a4f7ef6531 h1:Y/M5lygoNPKwVNLMPXgVfsRT40CSFKXCxuU8LoHySjs=
Expand Down
6 changes: 1 addition & 5 deletions vendor/github.com/tonistiigi/fsutil/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/tonistiigi/fsutil/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions vendor/github.com/tonistiigi/fsutil/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions vendor/github.com/tonistiigi/fsutil/diff_containerd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions vendor/github.com/tonistiigi/fsutil/docker-bake.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/github.com/tonistiigi/fsutil/filter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/github.com/tonistiigi/fsutil/followlinks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/tonistiigi/fsutil/fs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/tonistiigi/fsutil/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/tonistiigi/fsutil/stat.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a7b9d9

Please sign in to comment.