pkg/archive: gzDecompress(): use local vars for MOBY_DISABLE_PIGZ
@@ -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) {
- noPigzEnv := os.Getenv("MOBY_DISABLE_PIGZ")
- var noPigz bool
-
- if noPigzEnv != "" {
- var err error
- noPigz, err = strconv.ParseBool(noPigzEnv)
+ if noPigzEnv := os.Getenv("MOBY_DISABLE_PIGZ"); noPigzEnv != "" {
+ noPigz, err := strconv.ParseBool(noPigzEnv)
if err != nil {
logrus.WithError(err).Warn("invalid value in MOBY_DISABLE_PIGZ env var")
}
- }
-
if noPigz {
logrus.Debugf("Use of pigz is disabled due to MOBY_DISABLE_PIGZ=%s", noPigzEnv)
return gzip.NewReader(buf)
}
+ }
unpigzPath, err := exec.LookPath("unpigz")
if err != nil {
