start to name temporary directories in more places

This commit is contained in:
Jörg Thalheim
2024-10-01 18:48:25 +02:00
parent a5e18fda08
commit f9a42831e4
7 changed files with 10 additions and 8 deletions

View File

@@ -100,7 +100,7 @@ def flash_machine(
secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore( secret_facts_store: SecretStoreBase = secret_facts_module.SecretStore(
machine=machine machine=machine
) )
with TemporaryDirectory() as tmpdir_: with TemporaryDirectory(prefix="disko-install-") as tmpdir_:
tmpdir = Path(tmpdir_) tmpdir = Path(tmpdir_)
upload_dir = machine.secrets_upload_directory upload_dir = machine.secrets_upload_directory

View File

@@ -45,7 +45,7 @@ def install_nixos(
generate_facts([machine], None, False) generate_facts([machine], None, False)
generate_vars([machine], None, False) generate_vars([machine], None, False)
with TemporaryDirectory() as tmpdir_: with TemporaryDirectory(prefix="nixos-install-") as tmpdir_:
tmpdir = Path(tmpdir_) tmpdir = Path(tmpdir_)
upload_dir_ = machine.secrets_upload_directory upload_dir_ = machine.secrets_upload_directory

View File

@@ -80,7 +80,7 @@ def nix_eval(flags: list[str]) -> list[str]:
] ]
) )
if os.environ.get("IN_NIX_SANDBOX"): if os.environ.get("IN_NIX_SANDBOX"):
with tempfile.TemporaryDirectory() as nix_store: with tempfile.TemporaryDirectory(prefix="nix-store-") as nix_store:
return [ return [
*default_flags, *default_flags,
"--override-input", "--override-input",

View File

@@ -121,7 +121,7 @@ def execute_generator(
raise ClanError(msg) from e raise ClanError(msg) from e
env = os.environ.copy() env = os.environ.copy()
with TemporaryDirectory() as tmp: with TemporaryDirectory(prefix="vars-") as tmp:
tmpdir = Path(tmp) tmpdir = Path(tmp)
tmpdir_in = tmpdir / "in" tmpdir_in = tmpdir / "in"
tmpdir_prompts = tmpdir / "prompts" tmpdir_prompts = tmpdir / "prompts"

View File

@@ -129,11 +129,13 @@ def run_vm(
cache.mkdir(exist_ok=True) cache.mkdir(exist_ok=True)
if cachedir is None: if cachedir is None:
cache_tmp = stack.enter_context(TemporaryDirectory(dir=cache)) cache_tmp = stack.enter_context(
TemporaryDirectory(prefix="vm-cache-", dir=cache)
)
cachedir = Path(cache_tmp) cachedir = Path(cache_tmp)
if socketdir is None: if socketdir is None:
socket_tmp = stack.enter_context(TemporaryDirectory()) socket_tmp = stack.enter_context(TemporaryDirectory(prefix="vm-sockets-"))
socketdir = Path(socket_tmp) socketdir = Path(socket_tmp)
# TODO: We should get this from the vm argument # TODO: We should get this from the vm argument

View File

@@ -232,7 +232,7 @@ def create_flake(
sp.run(["git", "commit", "-a", "-m", "Initial commit"], cwd=flake, check=True) sp.run(["git", "commit", "-a", "-m", "Initial commit"], cwd=flake, check=True)
if remote: if remote:
with tempfile.TemporaryDirectory(): with tempfile.TemporaryDirectory(prefix="flake-"):
yield FlakeForTest(flake) yield FlakeForTest(flake)
else: else:
yield FlakeForTest(flake) yield FlakeForTest(flake)

View File

@@ -38,7 +38,7 @@ class SshdConfig:
def sshd_config(test_root: Path) -> Iterator[SshdConfig]: def sshd_config(test_root: Path) -> Iterator[SshdConfig]:
# FIXME, if any parent of the sshd directory is world-writable than sshd will refuse it. # FIXME, if any parent of the sshd directory is world-writable than sshd will refuse it.
# we use .direnv instead since it's already in .gitignore # we use .direnv instead since it's already in .gitignore
with TemporaryDirectory() as _dir: with TemporaryDirectory(prefix="sshd-") as _dir:
tmpdir = Path(_dir) tmpdir = Path(_dir)
host_key = test_root / "data" / "ssh_host_ed25519_key" host_key = test_root / "data" / "ssh_host_ed25519_key"
host_key.chmod(0o600) host_key.chmod(0o600)