mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

given that we are moving to building our own machine images, we have decided to use zstd compression as it is superior in speed to the alternatives. as such, this pr adds zstd to our machine code; and also has to account for dealing with sparseness on darwin; which the default zstd golang library does not. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
42 lines
609 B
Go
42 lines
609 B
Go
package compression
|
|
|
|
import "strings"
|
|
|
|
type ImageCompression int64
|
|
|
|
const (
|
|
Xz ImageCompression = iota
|
|
Zip
|
|
Gz
|
|
Bz2
|
|
Zstd
|
|
)
|
|
|
|
func KindFromFile(path string) ImageCompression {
|
|
switch {
|
|
case strings.HasSuffix(path, Bz2.String()):
|
|
return Bz2
|
|
case strings.HasSuffix(path, Gz.String()):
|
|
return Gz
|
|
case strings.HasSuffix(path, Zip.String()):
|
|
return Zip
|
|
case strings.HasSuffix(path, Xz.String()):
|
|
return Xz
|
|
}
|
|
return Zstd
|
|
}
|
|
|
|
func (c ImageCompression) String() string {
|
|
switch c {
|
|
case Gz:
|
|
return "gz"
|
|
case Zip:
|
|
return "zip"
|
|
case Bz2:
|
|
return "bz2"
|
|
case Xz:
|
|
return "xz"
|
|
}
|
|
return "zst"
|
|
}
|