Files
moby/pkg/archive/utils.go
Derek McGowan 57a042b77c deprecate pkg/(chroot)archive for github.com/moby/go-archive
- pkg/archive: deprecate, and add aliases
  Keeping the tests in this commit; also moves various utilities
  into a _test.go file, as they were now only used in tests.
- pkg/chrootarchive: deprecate and add aliase
  deprecate pkg/archive and add aliases
  keeping the tests in this commit
- Add temporary exceptions for deprecation linting errors, because
  this commit is to verify everything works with the aliases.
- remove tests that depend on un-exported types

    === RUN   TestDisablePigz
    --- FAIL: TestDisablePigz (0.00s)
    panic: interface conversion: io.Reader is *archive.readCloserWrapper, not *archive.readCloserWrapper (types from different packages) [recovered]

- pkg/archive, pkg/chrootarchive: remove test files

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 10:56:58 -07:00

43 lines
1.3 KiB
Go

package archive
import (
"github.com/docker/docker/pkg/idtools"
"github.com/moby/go-archive"
)
// ToArchiveOpt converts an [TarOptions] to a [archive.TarOptions].
//
// Deprecated: use [archive.TarOptions] instead, this utility is for internal use to transition to the [github.com/moby/go-archive] module.
func ToArchiveOpt(options *TarOptions) *archive.TarOptions {
return toArchiveOpt(options)
}
func toArchiveOpt(options *TarOptions) *archive.TarOptions {
if options == nil {
return nil
}
var chownOpts *archive.ChownOpts
if options.ChownOpts != nil {
chownOpts = &archive.ChownOpts{
UID: options.ChownOpts.UID,
GID: options.ChownOpts.GID,
}
}
return &archive.TarOptions{
IncludeFiles: options.IncludeFiles,
ExcludePatterns: options.ExcludePatterns,
Compression: options.Compression,
NoLchown: options.NoLchown,
IDMap: idtools.ToUserIdentityMapping(options.IDMap),
ChownOpts: chownOpts,
IncludeSourceDir: options.IncludeSourceDir,
WhiteoutFormat: options.WhiteoutFormat,
NoOverwriteDirNonDir: options.NoOverwriteDirNonDir,
RebaseNames: options.RebaseNames,
InUserNS: options.InUserNS,
BestEffortXattrs: options.BestEffortXattrs,
}
}