Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
Reset uid/gid to 0 in build context to fix cache busting issues on ADD/COPY in stream mode#549
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package image | ||
| import ( | ||
| "bytes" | ||
| "path/filepath" | ||
| "testing" | ||
| "github.com/docker/docker/pkg/streamformatter" | ||
| "github.com/gotestyourself/gotestyourself/fs" | ||
| "github.com/moby/buildkit/session" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
| func TestAddDirToSession(t *testing.T) { | ||
| dest := fs.NewDir(t, "test-build-session", | ||
| fs.WithFile("Dockerfile", ` | ||
| FROM alpine:3.6 | ||
| COPY foo / | ||
| `), | ||
| fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)), | ||
| ) | ||
| defer dest.Remove() | ||
| contextDir := dest.Path() | ||
| sharedKey, err := getBuildSharedKey(contextDir) | ||
| require.NoError(t, err) | ||
| var s *session.Session | ||
| s, err = session.NewSession(filepath.Base(contextDir), sharedKey) | ||
| require.NoError(t, err) | ||
| syncDone := make(chan error) | ||
| progressOutput := streamformatter.NewProgressOutput(new(bytes.Buffer)) | ||
| err = addDirToSession(s, contextDir, progressOutput, syncDone) | ||
| // Needs some assertions here to ensure we reset uid/gid to 0 for example | ||
| require.NoError(t, err) | ||
| } | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnephin@tonistiigi ok I guess the best is to mock/fake the session here instead of using the true one. @tonistiigi does it worth that builkit provides a session faker at some point? I can put it in the cli ATM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the CLI depend on a
type Session interface{...}instead of the struct would be great, then it should be easy for us to fake.A fake as part of the CLI testing code sounds fine to me.