Skip to content

Commit a15f86d

Browse files
authored
Merge pull request #1599 from arash77/add-vault_config_file
Add vault configuration file option
2 parents 9af750e + d78bd50 commit a15f86d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

planemo/galaxy/config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
TYPE_CHECKING,
2626
)
2727

28+
from cryptography.fernet import Fernet
2829
from galaxy.tool_util.deps import docker_util
2930
from galaxy.util.commands import argv_to_str
3031
from gxjobconfinit.generate import (
@@ -137,6 +138,12 @@
137138
genomes: null
138139
"""
139140

141+
VAULT_CONFIG_TEMPLATE = """
142+
type: database
143+
encryption_keys:
144+
- ${encryption_key}
145+
"""
146+
140147
EMPTY_TOOL_CONF_TEMPLATE = """<toolbox></toolbox>"""
141148
GX_TEST_TOOL_PATH = "$GALAXY_FUNCTIONAL_TEST_TOOLS"
142149

@@ -348,6 +355,7 @@ def config_join(*args):
348355
_handle_job_config_file(config_directory, server_name, test_data_dir, all_tool_paths, kwds)
349356
_handle_file_sources(config_directory, test_data_dir, kwds)
350357
_handle_refgenie_config(config_directory, galaxy_root, kwds)
358+
_handle_vault_config(config_directory, kwds)
351359
file_path = kwds.get("file_path") or config_join("files")
352360
_ensure_directory(file_path)
353361

@@ -1436,12 +1444,25 @@ def _handle_refgenie_config(config_directory, galaxy_root, kwds):
14361444
kwds["refgenie_config_file"] = refgenie_config_file
14371445

14381446

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+
14391459
def _handle_kwd_overrides(properties, kwds):
14401460
kwds_gx_properties = [
14411461
"tool_data_path",
14421462
"job_config_file",
14431463
"job_metrics_config_file",
14441464
"dependency_resolvers_config_file",
1465+
"vault_config_file",
14451466
]
14461467
for prop in kwds_gx_properties:
14471468
val = kwds.get(prop, None)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
allure-python-commons
22
bioblend>=1.6.0
33
click!=8.0.2
4+
cryptography>=46.0.3
45
cwltool>=1.0.20191225192155
56
ephemeris>=0.10.3
67
galaxy-job-config-init>=0.1.3

0 commit comments

Comments
 (0)