Add IsNonCompressedTarball method to Compressor interface#122
Add IsNonCompressedTarball method to Compressor interface#122mdzhigarov wants to merge 3 commits intocloudfoundry:developfrom
Conversation
- Add IsNonCompressedTarball method to Compressor interface - Implement IsNonCompressedTarball in tarballCompressor using 'file' command - Implement IsNonCompressedTarball in FakeCompressor returning false - Add comprehensive unit tests for IsNonCompressedTarball functionality - Tests cover positive/negative cases, error handling, and edge cases
fileutil/tarball_compressor.go
Outdated
| } | ||
|
|
||
| func (c tarballCompressor) IsNonCompressedTarball(path string) (bool, error) { | ||
| stdout, _, exitStatus, err := c.cmdRunner.RunCommand("file", path) |
There was a problem hiding this comment.
I think that this will need to be implemented in Golang, rather than using file, or have a separate path for windows.
The agent needs to be able to function on Windows stemcells.
There was a problem hiding this comment.
If this is ran on a windows stemcell the file command will not be found and the cmdRunner will simply return an error. That is completely fine - the tar will be treated as compressed so same behavior as today.
This would work even if the tar was originally created with the --no-compression flag. On Windows, we'd compress it again after compilation which is not a big deal.
There was a problem hiding this comment.
I agree that this is the likely outcome but I don't want to introduce a(nother) behavior difference between Linux and Windows.
Probably the cleanest option is to use a golang-native way to do this rather than shelling out to file.
There was a problem hiding this comment.
Agreed. Updated the PR to detect the tar compression natively.
Tested the with bosh-agent compile on the latest lite stemcell.
79181cc to
232b93e
Compare
This PR adds a new method
IsNonCompressedTarballto theCompressorinterface to detect whether a file is a non-compressed tarball.Changes
IsNonCompressedTarball(path string) (bool, error)method to theCompressorinterfacetarballCompressorusing the native golang approach to inspect the tar contentsFakeCompressorreturningfalsefor testing purposesTesting
All existing tests pass and new unit tests provide comprehensive coverage of the new functionality.