Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ func NewDefaultArchiver() *Archiver {
return &Archiver{Untar: Untar}
}

// breakoutError is used to differentiate errors related to breaking out
// When testing archive breakout in the unit tests, this error is expected
// in order for the test to pass.
type breakoutError error
// breakoutErr marks errors caused by archive breakout attempts.
// Unit tests use it to distinguish expected breakout failures from other
// errors.
type breakoutErr struct{ error }

func breakoutError(err error) error {
return &breakoutErr{error: err}
}

const (
AUFSWhiteoutFormat WhiteoutFormat = 0 // AUFSWhiteoutFormat is the default format for whiteouts
Expand Down
3 changes: 2 additions & 1 deletion utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func testBreakout(untarFn string, tmpdir string, headers []*tar.Header) error {
return fmt.Errorf("could not find untar function %q in testUntarFns", untarFn)
}
if err := untar(dest, reader); err != nil {
if !errors.As(err, new(breakoutError)) {
var boErr *breakoutErr
if !errors.As(err, &boErr) {
// If untar returns an error unrelated to an archive breakout,
// then consider this an unexpected error and abort.
return err
Expand Down
Loading