Skip to content

Commit

Permalink
config: fix missing "instance_path" usage
Browse files Browse the repository at this point in the history
  • Loading branch information
slint committed Jun 5, 2024
1 parent 596db45 commit dcbc39e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions invenio_cli/commands/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ def ensure_containers_running(self):
"""Ensures containers are running."""
project_shortname = self.cli_config.get_project_shortname()

instance_path = self.cli_config.get_instance_path()
cmd_env = {}
instance_path = self.cli_config.get_instance_path(throw=False)
if instance_path:
cmd_env = {"INSTANCE_PATH": str(instance_path)}
# Set environment variable for the instance path, it might be needed by docker services
with env(INSTANCE_PATH=str(instance_path)):

with env(**cmd_env):
self.docker_helper.start_containers()

services = ["redis", self.cli_config.get_db_type(), "search"]
Expand Down
4 changes: 2 additions & 2 deletions invenio_cli/helpers/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ def get_project_dir(self):
"""Returns path to project directory."""
return self.config_path.parent.resolve()

def get_instance_path(self):
def get_instance_path(self, throw=True):
"""Returns path to application instance directory.
If not set yet, raises an InvenioCLIConfigError.
"""
path = self.private_config[CLIConfig.CLI_SECTION].get("instance_path")
if path:
return Path(path)
else:
elif throw:
raise InvenioCLIConfigError("Accessing unset 'instance_path'")

def update_instance_path(self, new_instance_path):
Expand Down

0 comments on commit dcbc39e

Please sign in to comment.