Skip to content

Commit

Permalink
Append tar and ova decompressor (#351)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schurter <[email protected]>
  • Loading branch information
LeConTesteur and schmichael authored Jan 31, 2022
1 parent d38eed1 commit ea452ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions decompress.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Decompressor interface {
var Decompressors map[string]Decompressor

func init() {
tarDecompressor := new(TarDecompressor)
tbzDecompressor := new(TarBzip2Decompressor)
tgzDecompressor := new(TarGzipDecompressor)
txzDecompressor := new(TarXzDecompressor)
Expand All @@ -38,6 +39,8 @@ func init() {
"tgz": tgzDecompressor,
"txz": txzDecompressor,
"zip": new(ZipDecompressor),
"tar": tarDecompressor,
"ova": tarDecompressor,
}
}

Expand Down
6 changes: 3 additions & 3 deletions decompress_tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func untar(input io.Reader, dst, src string, dir bool, umask os.FileMode) error
return nil
}

// tarDecompressor is an implementation of Decompressor that can
// TarDecompressor is an implementation of Decompressor that can
// unpack tar files.
type tarDecompressor struct{}
type TarDecompressor struct{}

func (d *tarDecompressor) Decompress(dst, src string, dir bool, umask os.FileMode) error {
func (d *TarDecompressor) Decompress(dst, src string, dir bool, umask os.FileMode) error {
// If we're going into a directory we should make that first
mkdir := dst
if !dir {
Expand Down
4 changes: 2 additions & 2 deletions decompress_tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestTar(t *testing.T) {
cases[i].Input = filepath.Join("./testdata", "decompress-tar", tc.Input)
}

TestDecompressor(t, new(tarDecompressor), cases)
TestDecompressor(t, new(TarDecompressor), cases)
}

// testDecompressPermissions decompresses a directory and checks the permissions of the expanded files
Expand Down Expand Up @@ -76,7 +76,7 @@ func testDecompressorPermissions(t *testing.T, d Decompressor, input string, exp
}

func TestDecompressTarPermissions(t *testing.T) {
d := new(tarDecompressor)
d := new(TarDecompressor)
input := "./test-fixtures/decompress-tar/permissions.tar"

var expected map[string]int
Expand Down

0 comments on commit ea452ad

Please sign in to comment.