summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-03-26 08:20:38 -0400
committerMatthew Heon <mheon@redhat.com>2021-03-29 10:56:14 -0400
commit57e0d8f2930690de69c690c41e30abaa2cdb3776 (patch)
tree31f5eb85c72641fc0dccdaa5c281251322b6e236 /libpod
parent505f43c084a710c36195b8fe979c2ccb673c6e0c (diff)
downloadpodman-57e0d8f2930690de69c690c41e30abaa2cdb3776.tar.gz
podman-57e0d8f2930690de69c690c41e30abaa2cdb3776.tar.bz2
podman-57e0d8f2930690de69c690c41e30abaa2cdb3776.zip
Use TMPDIR when commiting images
Fixes: https://github.com/containers/podman/issues/9825 Currently we are using TMPDIR for storaing temporary files when building images, but not when you directly commit the images. This change simply uses the TMPDIR environment variable if set to store temporary files. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/docker_registry_options.go1
-rw-r--r--libpod/image/image_test.go23
2 files changed, 24 insertions, 0 deletions
diff --git a/libpod/image/docker_registry_options.go b/libpod/image/docker_registry_options.go
index 0a2a375ae..d95234e3d 100644
--- a/libpod/image/docker_registry_options.go
+++ b/libpod/image/docker_registry_options.go
@@ -69,6 +69,7 @@ func GetSystemContext(signaturePolicyPath, authFilePath string, forceCompress bo
sc.AuthFilePath = authFilePath
sc.DirForceCompress = forceCompress
sc.DockerRegistryUserAgent = fmt.Sprintf("libpod/%s", podmanVersion.Version)
+ sc.BigFilesTemporaryDir = parse.GetTempDir()
return sc
}
diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go
index 3e6e7b9db..e2518b687 100644
--- a/libpod/image/image_test.go
+++ b/libpod/image/image_test.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/pkg/util"
+ podmanVersion "github.com/containers/podman/v3/version"
"github.com/containers/storage"
"github.com/containers/storage/pkg/reexec"
"github.com/opencontainers/go-digest"
@@ -298,3 +299,25 @@ func TestNormalizedTag(t *testing.T) {
}
}
}
+
+func TestGetSystemContext(t *testing.T) {
+ sc := GetSystemContext("", "", false)
+ assert.Equal(t, sc.SignaturePolicyPath, "")
+ assert.Equal(t, sc.AuthFilePath, "")
+ assert.Equal(t, sc.DirForceCompress, false)
+ assert.Equal(t, sc.DockerRegistryUserAgent, fmt.Sprintf("libpod/%s", podmanVersion.Version))
+ assert.Equal(t, sc.BigFilesTemporaryDir, "/var/tmp")
+
+ oldtmpdir := os.Getenv("TMPDIR")
+ os.Setenv("TMPDIR", "/mnt")
+ sc = GetSystemContext("/tmp/foo", "/tmp/bar", true)
+ assert.Equal(t, sc.SignaturePolicyPath, "/tmp/foo")
+ assert.Equal(t, sc.AuthFilePath, "/tmp/bar")
+ assert.Equal(t, sc.DirForceCompress, true)
+ assert.Equal(t, sc.BigFilesTemporaryDir, "/mnt")
+ if oldtmpdir != "" {
+ os.Setenv("TMPDIR", oldtmpdir)
+ } else {
+ os.Unsetenv("TMPDIR")
+ }
+}