diff --git a/unarchive/archive.go b/archive/archive.go similarity index 99% rename from unarchive/archive.go rename to archive/archive.go index 8f86878..f614013 100644 --- a/unarchive/archive.go +++ b/archive/archive.go @@ -1,4 +1,4 @@ -package unarchive +package archive import ( "fmt" diff --git a/unarchive/testdata/archives/dot-dir.tar.gz b/archive/testdata/archives/dot-dir.tar.gz similarity index 100% rename from unarchive/testdata/archives/dot-dir.tar.gz rename to archive/testdata/archives/dot-dir.tar.gz diff --git a/unarchive/testdata/archives/softlink-cousin.tar b/archive/testdata/archives/softlink-cousin.tar similarity index 100% rename from unarchive/testdata/archives/softlink-cousin.tar rename to archive/testdata/archives/softlink-cousin.tar diff --git a/unarchive/testdata/archives/softlink-cousin.tar.gz b/archive/testdata/archives/softlink-cousin.tar.gz similarity index 100% rename from unarchive/testdata/archives/softlink-cousin.tar.gz rename to archive/testdata/archives/softlink-cousin.tar.gz diff --git a/unarchive/testdata/archives/softlink-cousin.zip b/archive/testdata/archives/softlink-cousin.zip similarity index 100% rename from unarchive/testdata/archives/softlink-cousin.zip rename to archive/testdata/archives/softlink-cousin.zip diff --git a/unarchive/testdata/archives/softlink-rel.tar b/archive/testdata/archives/softlink-rel.tar similarity index 100% rename from unarchive/testdata/archives/softlink-rel.tar rename to archive/testdata/archives/softlink-rel.tar diff --git a/unarchive/testdata/archives/softlink-rel.tar.gz b/archive/testdata/archives/softlink-rel.tar.gz similarity index 100% rename from unarchive/testdata/archives/softlink-rel.tar.gz rename to archive/testdata/archives/softlink-rel.tar.gz diff --git a/unarchive/testdata/archives/softlink-rel.zip b/archive/testdata/archives/softlink-rel.zip similarity index 100% rename from unarchive/testdata/archives/softlink-rel.zip rename to archive/testdata/archives/softlink-rel.zip diff --git a/unarchive/testdata/archives/softlink-uncle-file.tar b/archive/testdata/archives/softlink-uncle-file.tar similarity index 100% rename from unarchive/testdata/archives/softlink-uncle-file.tar rename to archive/testdata/archives/softlink-uncle-file.tar diff --git a/unarchive/testdata/archives/softlink-uncle-file.tar.gz b/archive/testdata/archives/softlink-uncle-file.tar.gz similarity index 100% rename from unarchive/testdata/archives/softlink-uncle-file.tar.gz rename to archive/testdata/archives/softlink-uncle-file.tar.gz diff --git a/unarchive/testdata/archives/softlink-uncle-file.zip b/archive/testdata/archives/softlink-uncle-file.zip similarity index 100% rename from unarchive/testdata/archives/softlink-uncle-file.zip rename to archive/testdata/archives/softlink-uncle-file.zip diff --git a/unarchive/testdata/archives/strip-components.tar b/archive/testdata/archives/strip-components.tar similarity index 100% rename from unarchive/testdata/archives/strip-components.tar rename to archive/testdata/archives/strip-components.tar diff --git a/unarchive/testdata/archives/strip-components.tar.gz b/archive/testdata/archives/strip-components.tar.gz similarity index 100% rename from unarchive/testdata/archives/strip-components.tar.gz rename to archive/testdata/archives/strip-components.tar.gz diff --git a/unarchive/testdata/archives/strip-components.zip b/archive/testdata/archives/strip-components.zip similarity index 100% rename from unarchive/testdata/archives/strip-components.zip rename to archive/testdata/archives/strip-components.zip diff --git a/unarchive/testdata/archives/unix.tar b/archive/testdata/archives/unix.tar similarity index 100% rename from unarchive/testdata/archives/unix.tar rename to archive/testdata/archives/unix.tar diff --git a/unarchive/testdata/archives/unix.tar.gz b/archive/testdata/archives/unix.tar.gz similarity index 100% rename from unarchive/testdata/archives/unix.tar.gz rename to archive/testdata/archives/unix.tar.gz diff --git a/unarchive/testdata/archives/unix.zip b/archive/testdata/archives/unix.zip similarity index 100% rename from unarchive/testdata/archives/unix.zip rename to archive/testdata/archives/unix.zip diff --git a/unarchive/testdata/archives/win.tar b/archive/testdata/archives/win.tar similarity index 100% rename from unarchive/testdata/archives/win.tar rename to archive/testdata/archives/win.tar diff --git a/unarchive/testdata/archives/win.tar.gz b/archive/testdata/archives/win.tar.gz similarity index 100% rename from unarchive/testdata/archives/win.tar.gz rename to archive/testdata/archives/win.tar.gz diff --git a/unarchive/testdata/archives/win.zip b/archive/testdata/archives/win.zip similarity index 100% rename from unarchive/testdata/archives/win.zip rename to archive/testdata/archives/win.zip diff --git a/unarchive/testdata/zipslip/abs.tar b/archive/testdata/zipslip/abs.tar similarity index 100% rename from unarchive/testdata/zipslip/abs.tar rename to archive/testdata/zipslip/abs.tar diff --git a/unarchive/testdata/zipslip/abs.tar.gz b/archive/testdata/zipslip/abs.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/abs.tar.gz rename to archive/testdata/zipslip/abs.tar.gz diff --git a/unarchive/testdata/zipslip/hardlink-tilde.tar b/archive/testdata/zipslip/hardlink-tilde.tar similarity index 100% rename from unarchive/testdata/zipslip/hardlink-tilde.tar rename to archive/testdata/zipslip/hardlink-tilde.tar diff --git a/unarchive/testdata/zipslip/hardlink-tilde.tar.gz b/archive/testdata/zipslip/hardlink-tilde.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/hardlink-tilde.tar.gz rename to archive/testdata/zipslip/hardlink-tilde.tar.gz diff --git a/unarchive/testdata/zipslip/rel.tar b/archive/testdata/zipslip/rel.tar similarity index 100% rename from unarchive/testdata/zipslip/rel.tar rename to archive/testdata/zipslip/rel.tar diff --git a/unarchive/testdata/zipslip/rel.tar.gz b/archive/testdata/zipslip/rel.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/rel.tar.gz rename to archive/testdata/zipslip/rel.tar.gz diff --git a/unarchive/testdata/zipslip/rel.zip b/archive/testdata/zipslip/rel.zip similarity index 100% rename from unarchive/testdata/zipslip/rel.zip rename to archive/testdata/zipslip/rel.zip diff --git a/unarchive/testdata/zipslip/softlink-abs.tar b/archive/testdata/zipslip/softlink-abs.tar similarity index 100% rename from unarchive/testdata/zipslip/softlink-abs.tar rename to archive/testdata/zipslip/softlink-abs.tar diff --git a/unarchive/testdata/zipslip/softlink-abs.tar.gz b/archive/testdata/zipslip/softlink-abs.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/softlink-abs.tar.gz rename to archive/testdata/zipslip/softlink-abs.tar.gz diff --git a/unarchive/testdata/zipslip/softlink-abs.zip b/archive/testdata/zipslip/softlink-abs.zip similarity index 100% rename from unarchive/testdata/zipslip/softlink-abs.zip rename to archive/testdata/zipslip/softlink-abs.zip diff --git a/unarchive/testdata/zipslip/softlink-loop.tar b/archive/testdata/zipslip/softlink-loop.tar similarity index 100% rename from unarchive/testdata/zipslip/softlink-loop.tar rename to archive/testdata/zipslip/softlink-loop.tar diff --git a/unarchive/testdata/zipslip/softlink-rel.tar b/archive/testdata/zipslip/softlink-rel.tar similarity index 100% rename from unarchive/testdata/zipslip/softlink-rel.tar rename to archive/testdata/zipslip/softlink-rel.tar diff --git a/unarchive/testdata/zipslip/softlink-rel.tar.gz b/archive/testdata/zipslip/softlink-rel.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/softlink-rel.tar.gz rename to archive/testdata/zipslip/softlink-rel.tar.gz diff --git a/unarchive/testdata/zipslip/softlink-rel.zip b/archive/testdata/zipslip/softlink-rel.zip similarity index 100% rename from unarchive/testdata/zipslip/softlink-rel.zip rename to archive/testdata/zipslip/softlink-rel.zip diff --git a/unarchive/testdata/zipslip/softlink-uncle.tar b/archive/testdata/zipslip/softlink-uncle.tar similarity index 100% rename from unarchive/testdata/zipslip/softlink-uncle.tar rename to archive/testdata/zipslip/softlink-uncle.tar diff --git a/unarchive/testdata/zipslip/softlink-uncle.tar.gz b/archive/testdata/zipslip/softlink-uncle.tar.gz similarity index 100% rename from unarchive/testdata/zipslip/softlink-uncle.tar.gz rename to archive/testdata/zipslip/softlink-uncle.tar.gz diff --git a/unarchive/testdata/zipslip/softlink-uncle.zip b/archive/testdata/zipslip/softlink-uncle.zip similarity index 100% rename from unarchive/testdata/zipslip/softlink-uncle.zip rename to archive/testdata/zipslip/softlink-uncle.zip diff --git a/unarchive/unarchive.go b/archive/unarchive.go similarity index 97% rename from unarchive/unarchive.go rename to archive/unarchive.go index 85e585f..d7f791b 100644 --- a/unarchive/unarchive.go +++ b/archive/unarchive.go @@ -1,4 +1,4 @@ -package unarchive +package archive import ( "encoding/json" @@ -33,7 +33,7 @@ func IsSupportedArchive(filePath string) bool { return ok } -// The 'archiver' dependency includes an API called 'Unarchive' to extract archive files. This API uses the archive file +// The 'archive' dependency includes an API called 'Unarchive' to extract archive files. This API uses the archive file // extension to determine the archive type. // We therefore need to use the file name as it was in Artifactory, and not the file name which was downloaded. To achieve this, // we added a new implementation of the 'Unarchive' func and use it instead of the default one. @@ -58,7 +58,7 @@ func (u *Unarchiver) Unarchive(archivePath, archiveName, destinationPath string) return unarchiver.Unarchive(archivePath, destinationPath) } -// Instead of using 'archiver.byExtension' that by default sets OverwriteExisting to false, we implement our own. +// Instead of using 'archive.byExtension' that by default sets OverwriteExisting to false, we implement our own. func (u *Unarchiver) byExtension(filename string) (interface{}, error) { var ec interface{} for _, c := range supportedArchives { diff --git a/unarchive/unarchive_test.go b/archive/unarchive_test.go similarity index 93% rename from unarchive/unarchive_test.go rename to archive/unarchive_test.go index 014e593..ccf2312 100644 --- a/unarchive/unarchive_test.go +++ b/archive/unarchive_test.go @@ -1,4 +1,4 @@ -package unarchive +package archive import ( "os" @@ -16,13 +16,13 @@ func TestUnarchive(t *testing.T) { // Create temp directory tmpDir := t.TempDir() - // Run unarchive on archive created on Unix + // Run archive on archive created on Unix err := runUnarchive(t, uarchiver, "unix."+extension, "archives", filepath.Join(tmpDir, "unix")) assert.NoError(t, err) assert.FileExists(t, filepath.Join(tmpDir, "unix", "link")) assert.FileExists(t, filepath.Join(tmpDir, "unix", "dir", "file")) - // Run unarchive on archive created on Windows + // Run archive on archive created on Windows err = runUnarchive(t, uarchiver, "win."+extension, "archives", filepath.Join(tmpDir, "win")) assert.NoError(t, err) assert.FileExists(t, filepath.Join(tmpDir, "win", "link.lnk")) @@ -50,7 +50,7 @@ func TestUnarchiveSymlink(t *testing.T) { // Create temp directory tmpDir := t.TempDir() - // Run unarchive + // Run archive err := runUnarchive(t, uarchiver, testCase.prefix+"."+extension, "archives", tmpDir) assert.NoError(t, err) @@ -104,13 +104,13 @@ func TestUnarchiveWithStripComponents(t *testing.T) { // Create temp directory tmpDir := t.TempDir() - // Run unarchive on archive created on Unix + // Run archive on archive created on Unix err := runUnarchive(t, uarchiver, "strip-components."+extension, "archives", filepath.Join(tmpDir, "unix")) assert.NoError(t, err) assert.DirExists(t, filepath.Join(tmpDir, "unix", "nested_folder_1")) assert.DirExists(t, filepath.Join(tmpDir, "unix", "nested_folder_2")) - // Run unarchive on archive created on Windows + // Run archive on archive created on Windows err = runUnarchive(t, uarchiver, "strip-components."+extension, "archives", filepath.Join(tmpDir, "win")) assert.NoError(t, err) assert.DirExists(t, filepath.Join(tmpDir, "win", "nested_folder_1")) @@ -119,12 +119,12 @@ func TestUnarchiveWithStripComponents(t *testing.T) { } } -// Test unarchive file with a directory named "." in the root directory +// Test archive file with a directory named "." in the root directory func TestUnarchiveDotDir(t *testing.T) { // Create temp directory tmpDir := t.TempDir() - // Run unarchive + // Run archive err := runUnarchive(t, Unarchiver{}, "dot-dir.tar.gz", "archives", tmpDir+string(os.PathSeparator)) assert.NoError(t, err) assert.DirExists(t, filepath.Join(tmpDir, "dir"))