chore(coderd): extract fileszip to package archive for reuse (#15229)

Related to https://github.com/coder/coder/issues/15087
As part of sniffing the workspace tags from an uploaded file, we need to
be able to handle both zip and tar files. Extracting the functions to
a separate `archive` package will be helpful here.
This commit is contained in:
Cian Johnston
2024-10-25 15:14:39 +01:00
committed by GitHub
parent 5ad47471b5
commit df34858c3c
8 changed files with 156 additions and 126 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/archive"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd"
"github.com/coder/coder/v2/coderd/coderdtest"
@ -95,7 +96,7 @@ func TestTemplatePull_Stdout(t *testing.T) {
// Verify .zip format
tarReader := tar.NewReader(bytes.NewReader(expected))
expectedZip, err := coderd.CreateZipFromTar(tarReader)
expectedZip, err := archive.CreateZipFromTar(tarReader, coderd.HTTPFileMaxBytes)
require.NoError(t, err)
inv, root = clitest.New(t, "templates", "pull", "--zip", template.Name)