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
add WithBaseDir option to tar context #52
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Josh Wolf <josh@wolfs.io>
5c268f2
to
2127ae6
Compare
@@ -143,7 +144,7 @@ func (c *Context) writeTar(ctx context.Context, tw *tar.Writer, fsys fs.FS, user | |||
header.Devminor = int64(minor) | |||
} | |||
// work around some weirdness, without this we wind up with just the basename | |||
header.Name = path | |||
header.Name = filepath.Join(c.BaseDir, path) |
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.
this should be equivalent to header.Name = path
when c.BaseDir
is the zero value, but please correct me if I'm wrong!
I don't fully understand what this change tries to do. Let's say I have a directory tree like this:
And I want everything under Unless you are saying you want them to appear in the tarball as |
This. If there's a better way to achieve this within the confines of Also, here is a rough draft of the downstream impact this would have for something like |
I get it. I don't see any reason not to support it. I do wonder if this is the best way to achieve it? Thinking about $ mkdir /target/dir
$ tar -C /target/dir -xvf mytarfile.tar I only create the prefix if I want every potential consumer to have it (which is a valid use case). |
Adds a
WithBaseDir
option to the tar context to allow building tarballs with more control over the archives root directory.This is useful when the unarchive process isn't performed by the consumer, but the consumer still wants to adhere to some required directory structure (such as in
kontext
, where the archive is used to create a container layer unpacked at/
)This option is disabled by default.