Skip to content

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

Merged
johnstcn merged 4 commits into
mainfrom
cj/extract-pkg-fileszip
Oct 25, 2024
Merged

chore(coderd): extract fileszip to its own package for reuse#15229
johnstcn merged 4 commits into
mainfrom
cj/extract-pkg-fileszip

Conversation

@johnstcn
Copy link
Copy Markdown
Member

Related to #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 in the fileszip package will be helpful here.

@johnstcn johnstcn self-assigned this Oct 25, 2024
Comment on lines +22 to +28
func TestTarFileBytes() []byte {
return append([]byte{}, testTarFileBytes...)
}

func TestZipFileBytes() []byte {
return append([]byte{}, testZipFileBytes...)
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: returning a clone of the byte to avoid accidental mutation in tests

Comment on lines +16 to +20
//go:embed testdata/test.tar
var testTarFileBytes []byte

//go:embed testdata/test.zip
var testZipFileBytes []byte
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: I chose to go:embed these so that we don't end up with silly path errors.

@johnstcn johnstcn requested review from defelmnq and mafredri October 25, 2024 12:01
Copy link
Copy Markdown
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits but otherwise LGTM.

Comment thread fileszip/fileszip.go Outdated
Comment thread fileszip/fileszip_test.go Outdated
Comment thread cli/templatepull_test.go Outdated
@johnstcn johnstcn merged commit df34858 into main Oct 25, 2024
@johnstcn johnstcn deleted the cj/extract-pkg-fileszip branch October 25, 2024 14:14
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants