mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-09-30 11:37:57 +00:00
Also includes a small change to make us of https://github.com/containers/buildah/pull/5039 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
28 lines
583 B
Go
28 lines
583 B
Go
package tmpdir
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/containers/common/pkg/config"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// GetTempDir returns base for a temporary directory on host.
|
|
func GetTempDir() string {
|
|
if tmpdir, ok := os.LookupEnv("TMPDIR"); ok {
|
|
abs, err := filepath.Abs(tmpdir)
|
|
if err == nil {
|
|
return abs
|
|
}
|
|
logrus.Warnf("ignoring TMPDIR from environment, evaluating it: %v", err)
|
|
}
|
|
containerConfig, err := config.Default()
|
|
if err != nil {
|
|
tmpdir, err := containerConfig.ImageCopyTmpDir()
|
|
if err != nil {
|
|
return tmpdir
|
|
}
|
|
}
|
|
return "/var/tmp"
|
|
}
|