Fix TypeError creating B2 tasks on TrueNAS 24.10: handle both credential schemas
On 24.10 (Electric Eel) credentials["provider"] is the type string with account/key in credentials["attributes"]; 25.04+ moved them into a provider dict. The injected get_restic_config only handled the newer shape and raised TypeError on 24.10 at task creation (#1). The method now detects the schema and reads credentials from the right place on both. create_task.py list-credentials and list-tasks use the same schema-agnostic lookup.
This commit is contained in:
@@ -186,6 +186,11 @@ B2_BLOCK = """
|
||||
# TRUECLOUD_PATCH — added by truenas-truecloud-patch/patch/apply.sh
|
||||
def _tc_get_restic_config(task):
|
||||
p = task["credentials"]["provider"]
|
||||
if not isinstance(p, dict):
|
||||
# TrueNAS <= 24.10: provider is the type string ("B2") and the
|
||||
# account/key live in the credential's attributes dict. 25.04+
|
||||
# moved them into a provider dict.
|
||||
p = task["credentials"]["attributes"]
|
||||
return "", {"B2_ACCOUNT_ID": p["account"], "B2_ACCOUNT_KEY": p["key"]}
|
||||
|
||||
B2RcloneRemote.get_restic_config = staticmethod(_tc_get_restic_config)
|
||||
|
||||
Reference in New Issue
Block a user