From 7999465d89b545274bb392862f483b71c9aabc9d Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Tue, 1 Oct 2024 19:52:00 -0700 Subject: [PATCH] Make clan_cli.secrets.sops.SopsKey immutable and remove its __eq__ method Immutability seems sensible for this type. There is some ambiguity on how to compare keys, in particular when `user.name == ""`, but the rest matches. --- pkgs/clan-cli/clan_cli/secrets/sops.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/secrets/sops.py b/pkgs/clan-cli/clan_cli/secrets/sops.py index ad956ef3a..b3a90483c 100644 --- a/pkgs/clan-cli/clan_cli/secrets/sops.py +++ b/pkgs/clan-cli/clan_cli/secrets/sops.py @@ -31,7 +31,7 @@ class KeyType(enum.Enum): return None -@dataclass +@dataclass(frozen=True, eq=False) class SopsKey: pubkey: str username: str @@ -108,8 +108,7 @@ def maybe_get_user_or_machine(flake_dir: Path, key: SopsKey) -> SopsKey | None: continue this_pub_key, this_key_type = read_key(user) if key.pubkey == this_pub_key and key.key_type == this_key_type: - key.username = user.name - return key + return SopsKey(key.pubkey, user.name, key.key_type) return None