From 22c5e8ca8b1e1d6257cc9efc5d0bde7c8400ac30 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 22 Nov 2024 22:30:36 +0100 Subject: [PATCH] cli password-store: upload generators folder only if it has secrets --- .../clan_cli/vars/secret_modules/password_store.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py b/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py index 936226668..4af78b6ad 100644 --- a/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py +++ b/pkgs/clan-cli/clan_cli/vars/secret_modules/password_store.py @@ -153,15 +153,18 @@ class SecretStore(SecretStoreBase): def upload(self, output_dir: Path) -> None: with tarfile.open(output_dir / "secrets.tar.gz", "w:gz") as tar: for gen_name, generator in self.machine.vars_generators.items(): - tar_dir = tarfile.TarInfo(name=gen_name) - tar_dir.type = tarfile.DIRTYPE - tar_dir.mode = 0o511 - tar.addfile(tarinfo=tar_dir) + dir_exists = False for f_name, file in generator["files"].items(): if not file["deploy"]: continue if not file["secret"]: continue + if not dir_exists: + tar_dir = tarfile.TarInfo(name=gen_name) + tar_dir.type = tarfile.DIRTYPE + tar_dir.mode = 0o511 + tar.addfile(tarinfo=tar_dir) + dir_exists = True tar_file = tarfile.TarInfo(name=f"{gen_name}/{f_name}") content = self.get(gen_name, f_name, generator["share"]) tar_file.size = len(content)