Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: fix missing "instance_path" usage #369

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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