Files
Brent Baude a31e8d2a23 zstd now default compression for podman machine
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>
2024-02-20 14:26:41 -06:00

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"
}