Skip exec.LookPath if a specific gzip implementation is disabled
Both pigz and igzip can be disabled via the environment variables. If disabled, calling exec.LookPath and logging "not found" message is, even in the debug level, doesn't make much sense. Signed-off-by: Kazuyoshi Kato <kaz@fly.io>
This commit is contained in:
parent
34378ec9b4
commit
535916d1d0
@ -303,27 +303,24 @@ func cmdStream(cmd *exec.Cmd, in io.Reader) (io.ReadCloser, error) {
|
||||
}
|
||||
|
||||
func detectCommand(path, disableEnvName string) string {
|
||||
// Check if this command is disabled via the env variable
|
||||
value := os.Getenv(disableEnvName)
|
||||
if value != "" {
|
||||
disable, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
log.L.WithError(err).Warnf("could not parse %s: %s", disableEnvName, value)
|
||||
}
|
||||
|
||||
if disable {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
path, err := exec.LookPath(path)
|
||||
if err != nil {
|
||||
log.L.WithError(err).Debugf("%s not found", path)
|
||||
return ""
|
||||
}
|
||||
|
||||
// Check if this command is disabled via the env variable
|
||||
value := os.Getenv(disableEnvName)
|
||||
if value == "" {
|
||||
return path
|
||||
}
|
||||
|
||||
disable, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
log.L.WithError(err).Warnf("could not parse %s: %s", disableEnvName, value)
|
||||
return path
|
||||
}
|
||||
|
||||
if disable {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user