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