|
25 | 25 | TYPE_CHECKING, |
26 | 26 | ) |
27 | 27 |
|
| 28 | +from cryptography.fernet import Fernet |
28 | 29 | from galaxy.tool_util.deps import docker_util |
29 | 30 | from galaxy.util.commands import argv_to_str |
30 | 31 | from gxjobconfinit.generate import ( |
|
137 | 138 | genomes: null |
138 | 139 | """ |
139 | 140 |
|
| 141 | +VAULT_CONFIG_TEMPLATE = """ |
| 142 | +type: database |
| 143 | +encryption_keys: |
| 144 | + - ${encryption_key} |
| 145 | +""" |
| 146 | + |
140 | 147 | EMPTY_TOOL_CONF_TEMPLATE = """<toolbox></toolbox>""" |
141 | 148 | GX_TEST_TOOL_PATH = "$GALAXY_FUNCTIONAL_TEST_TOOLS" |
142 | 149 |
|
@@ -348,6 +355,7 @@ def config_join(*args): |
348 | 355 | _handle_job_config_file(config_directory, server_name, test_data_dir, all_tool_paths, kwds) |
349 | 356 | _handle_file_sources(config_directory, test_data_dir, kwds) |
350 | 357 | _handle_refgenie_config(config_directory, galaxy_root, kwds) |
| 358 | + _handle_vault_config(config_directory, kwds) |
351 | 359 | file_path = kwds.get("file_path") or config_join("files") |
352 | 360 | _ensure_directory(file_path) |
353 | 361 |
|
@@ -1436,12 +1444,25 @@ def _handle_refgenie_config(config_directory, galaxy_root, kwds): |
1436 | 1444 | kwds["refgenie_config_file"] = refgenie_config_file |
1437 | 1445 |
|
1438 | 1446 |
|
| 1447 | +def _handle_vault_config(config_directory, kwds): |
| 1448 | + """Generate a default vault configuration file if not provided.""" |
| 1449 | + vault_config_file = kwds.get("vault_config_file", None) |
| 1450 | + if not vault_config_file: |
| 1451 | + # Generate a Fernet encryption key for the database vault |
| 1452 | + encryption_key = Fernet.generate_key().decode("utf-8") |
| 1453 | + vault_config_contents = _sub(VAULT_CONFIG_TEMPLATE, {"encryption_key": encryption_key}) |
| 1454 | + vault_config_file = os.path.join(config_directory, "vault_conf.yml") |
| 1455 | + write_file(vault_config_file, vault_config_contents) |
| 1456 | + kwds["vault_config_file"] = vault_config_file |
| 1457 | + |
| 1458 | + |
1439 | 1459 | def _handle_kwd_overrides(properties, kwds): |
1440 | 1460 | kwds_gx_properties = [ |
1441 | 1461 | "tool_data_path", |
1442 | 1462 | "job_config_file", |
1443 | 1463 | "job_metrics_config_file", |
1444 | 1464 | "dependency_resolvers_config_file", |
| 1465 | + "vault_config_file", |
1445 | 1466 | ] |
1446 | 1467 | for prop in kwds_gx_properties: |
1447 | 1468 | val = kwds.get(prop, None) |
|
0 commit comments