PLR1704: fix
This commit is contained in:
@@ -13,24 +13,24 @@ def check_secrets(machine: Machine, service: None | str = None) -> bool:
|
||||
missing_secret_facts = []
|
||||
missing_public_facts = []
|
||||
services = [service] if service else list(machine.facts_data.keys())
|
||||
for service in services:
|
||||
for secret_fact in machine.facts_data[service]["secret"]:
|
||||
for svc in services:
|
||||
for secret_fact in machine.facts_data[svc]["secret"]:
|
||||
if isinstance(secret_fact, str):
|
||||
secret_name = secret_fact
|
||||
else:
|
||||
secret_name = secret_fact["name"]
|
||||
if not machine.secret_facts_store.exists(service, secret_name):
|
||||
if not machine.secret_facts_store.exists(svc, secret_name):
|
||||
machine.info(
|
||||
f"Secret fact '{secret_fact}' for service '{service}' is missing.",
|
||||
f"Secret fact '{secret_fact}' for service '{svc}' is missing.",
|
||||
)
|
||||
missing_secret_facts.append((service, secret_name))
|
||||
missing_secret_facts.append((svc, secret_name))
|
||||
|
||||
for public_fact in machine.facts_data[service]["public"]:
|
||||
if not machine.public_facts_store.exists(service, public_fact):
|
||||
for public_fact in machine.facts_data[svc]["public"]:
|
||||
if not machine.public_facts_store.exists(svc, public_fact):
|
||||
machine.info(
|
||||
f"Public fact '{public_fact}' for service '{service}' is missing.",
|
||||
f"Public fact '{public_fact}' for service '{svc}' is missing.",
|
||||
)
|
||||
missing_public_facts.append((service, public_fact))
|
||||
missing_public_facts.append((svc, public_fact))
|
||||
|
||||
machine.debug(f"missing_secret_facts: {missing_secret_facts}")
|
||||
machine.debug(f"missing_public_facts: {missing_public_facts}")
|
||||
|
||||
@@ -178,10 +178,10 @@ def _generate_facts_for_machine(
|
||||
else:
|
||||
machine_service_facts = machine.facts_data
|
||||
|
||||
for service in machine_service_facts:
|
||||
for svc in machine_service_facts:
|
||||
machine_updated |= generate_service_facts(
|
||||
machine=machine,
|
||||
service=service,
|
||||
service=svc,
|
||||
regenerate=regenerate,
|
||||
secret_facts_store=machine.secret_facts_store,
|
||||
public_facts_store=machine.public_facts_store,
|
||||
|
||||
@@ -52,12 +52,12 @@ def list_state_folders(machine: Machine, service: None | str = None) -> None:
|
||||
description=f"The service: {service} needs to be configured for the machine.",
|
||||
)
|
||||
|
||||
for service in state:
|
||||
if not service:
|
||||
for svc in state:
|
||||
if not svc:
|
||||
continue
|
||||
|
||||
print(f"· service: {service}")
|
||||
service_cfg = state.get(service)
|
||||
print(f"· service: {svc}")
|
||||
service_cfg = state.get(svc)
|
||||
|
||||
if not service_cfg:
|
||||
continue # or handle missing config
|
||||
|
||||
@@ -11,9 +11,9 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
|
||||
msg = "No providers specified"
|
||||
raise ClanError(msg)
|
||||
with host.host_connection() as ssh:
|
||||
for provider in backup_scripts["providers"]:
|
||||
for prov in backup_scripts["providers"]:
|
||||
proc = ssh.run(
|
||||
[backup_scripts["providers"][provider]["create"]],
|
||||
[backup_scripts["providers"][prov]["create"]],
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
msg = "failed to start backup"
|
||||
|
||||
Reference in New Issue
Block a user