-
Notifications
You must be signed in to change notification settings - Fork 461
Remove docker/docker as a dependency #2298
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
base: main
Are you sure you want to change the base?
Changes from all commits
35d5820
29af5c1
ac21060
88f1020
770f75e
e6b58d8
768976b
e12d83d
62d0b32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,11 @@ import ( | |
| "strings" | ||
| "syscall" | ||
|
|
||
| "github.com/docker/docker/pkg/archive" | ||
| "github.com/docker/docker/pkg/idtools" | ||
| "github.com/docker/docker/pkg/pools" | ||
| "github.com/docker/docker/pkg/system" | ||
| "github.com/moby/go-archive" | ||
| "github.com/moby/go-archive/compression" | ||
| "github.com/moby/sys/sequential" | ||
| mobyuser "github.com/moby/sys/user" | ||
| "go.podman.io/storage/pkg/system" | ||
| ) | ||
|
|
||
| type ( | ||
|
|
@@ -26,14 +26,11 @@ type ( | |
|
|
||
| // TarOptions wraps the tar options. | ||
| TarOptions struct { | ||
| IncludeFiles []string | ||
| ExcludePatterns []string | ||
| Compression Compression | ||
| NoLchown bool | ||
| // REMOVED: use remap instead | ||
| //UIDMaps []idtools.IDMap | ||
| //GIDMaps []idtools.IDMap | ||
| ChownOpts *idtools.Identity | ||
| IncludeFiles []string | ||
| ExcludePatterns []string | ||
| Compression Compression | ||
| NoLchown bool | ||
| ChownOpts *Identity | ||
| IncludeSourceDir bool | ||
| // WhiteoutFormat is the expected on disk format for whiteout files. | ||
| // This format will be converted to the standard format on pack | ||
|
|
@@ -69,21 +66,27 @@ type AlterHeader interface { | |
| Alter(*tar.Header) (bool, error) | ||
| } | ||
|
|
||
| // Identity holds a UID and GID pair. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Structurally they are the same so we could. Only reason I have to argue against it is that |
||
| type Identity struct { | ||
| UID int | ||
| GID int | ||
| } | ||
|
|
||
| type RemapIDs struct { | ||
| mappings *idtools.IdentityMapping | ||
| mappings *mobyuser.IdentityMapping | ||
| } | ||
|
|
||
| func (r RemapIDs) Alter(hdr *tar.Header) (bool, error) { | ||
| ids, err := r.mappings.ToHost(idtools.Identity{UID: hdr.Uid, GID: hdr.Gid}) | ||
| hdr.Uid, hdr.Gid = ids.UID, ids.GID | ||
| uid, gid, err := r.mappings.ToHost(hdr.Uid, hdr.Gid) | ||
| hdr.Uid, hdr.Gid = uid, gid | ||
| return true, err | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| // ApplyLayer is copied from github.com/docker/docker/pkg/archive | ||
| func ApplyLayer(dest string, layer io.Reader, options *TarOptions) (int64, error) { | ||
| dest = filepath.Clean(dest) | ||
| var err error | ||
| layer, err = archive.DecompressStream(layer) | ||
| layer, err = compression.DecompressStream(layer) | ||
| if err != nil { | ||
| return 0, err | ||
| } | ||
|
|
@@ -96,8 +99,6 @@ func ApplyLayer(dest string, layer io.Reader, options *TarOptions) (int64, error | |
| // Returns the size in bytes of the contents of the layer. | ||
| func unpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, err error) { | ||
| tr := tar.NewReader(layer) | ||
| trBuf := pools.BufioReader32KPool.Get(tr) | ||
| defer pools.BufioReader32KPool.Put(trBuf) | ||
|
|
||
| var dirs []*tar.Header | ||
| unpackedPaths := make(map[string]struct{}) | ||
|
|
@@ -183,7 +184,7 @@ func unpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, | |
| parentPath := filepath.Join(dest, parent) | ||
|
|
||
| if _, err := os.Lstat(parentPath); err != nil && os.IsNotExist(err) { | ||
| err = system.MkdirAll(parentPath, 0600) | ||
| err = os.MkdirAll(parentPath, 0600) | ||
| if err != nil { | ||
| return 0, err | ||
| } | ||
|
|
@@ -262,8 +263,7 @@ func unpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, | |
| } | ||
| } | ||
|
|
||
| trBuf.Reset(tr) | ||
| srcData := io.Reader(trBuf) | ||
| srcData := io.Reader(tr) | ||
| srcHdr := hdr | ||
|
|
||
| // Hard links into /.wh..wh.plnk don't work, as we don't extract that directory, so | ||
|
|
@@ -309,7 +309,7 @@ func unpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64, | |
| return size, nil | ||
| } | ||
|
|
||
| func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, Lchown bool, chownOpts *idtools.Identity, inUserns bool, currentUser *user.User) error { | ||
| func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, Lchown bool, chownOpts *Identity, inUserns bool, currentUser *user.User) error { | ||
| // hdr.Mode is in linux format, which we can use for sycalls, | ||
| // but for os.Foo() calls we need the mode converted to os.FileMode, | ||
| // so use hdrInfo.Mode() (they differ for e.g. setuid bits) | ||
|
|
@@ -388,7 +388,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L | |
| // Lchown is not supported on Windows. | ||
| if Lchown && runtime.GOOS != "windows" { | ||
| if chownOpts == nil { | ||
| chownOpts = &idtools.Identity{UID: hdr.Uid, GID: hdr.Gid} | ||
| chownOpts = &Identity{UID: hdr.Uid, GID: hdr.Gid} | ||
| } | ||
| if err := os.Lchown(path, chownOpts.UID, chownOpts.GID); err != nil { | ||
| return err | ||
|
|
||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.