1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

pkg/archive: gzDecompress(): use local vars for MOBY_DISABLE_PIGZ

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-07-26 09:39:01 +02:00
parent b321474747
commit e3491ab56a
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -143,21 +143,16 @@ func xzDecompress(ctx context.Context, archive io.Reader) (io.ReadCloser, error)
} }
func gzDecompress(ctx context.Context, buf io.Reader) (io.ReadCloser, error) { func gzDecompress(ctx context.Context, buf io.Reader) (io.ReadCloser, error) {
noPigzEnv := os.Getenv("MOBY_DISABLE_PIGZ") if noPigzEnv := os.Getenv("MOBY_DISABLE_PIGZ"); noPigzEnv != "" {
var noPigz bool noPigz, err := strconv.ParseBool(noPigzEnv)
if noPigzEnv != "" {
var err error
noPigz, err = strconv.ParseBool(noPigzEnv)
if err != nil { if err != nil {
logrus.WithError(err).Warn("invalid value in MOBY_DISABLE_PIGZ env var") logrus.WithError(err).Warn("invalid value in MOBY_DISABLE_PIGZ env var")
} }
}
if noPigz { if noPigz {
logrus.Debugf("Use of pigz is disabled due to MOBY_DISABLE_PIGZ=%s", noPigzEnv) logrus.Debugf("Use of pigz is disabled due to MOBY_DISABLE_PIGZ=%s", noPigzEnv)
return gzip.NewReader(buf) return gzip.NewReader(buf)
} }
}
unpigzPath, err := exec.LookPath("unpigz") unpigzPath, err := exec.LookPath("unpigz")
if err != nil { if err != nil {