Skip to content
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
10 changes: 9 additions & 1 deletion invenio_cli/cli/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import click

from ..commands import ServicesCommands
from ..helpers.docker_helper import NoOpDockerHelper
from .utils import pass_cli_config, run_steps


Expand Down Expand Up @@ -61,7 +62,14 @@ def setup(cli_config, force, no_demo_data, stop_services, services):
"""Setup local services."""
# no_demo_data = False (default) means "YES to demo_data"
demo_data = not no_demo_data
commands = ServicesCommands(cli_config)
if services:
# use the default docker helper
docker_helper = None
else:
# create a no-op docker helper as services are disabled
docker_helper = NoOpDockerHelper()

commands = ServicesCommands(cli_config, docker_helper=docker_helper)
steps = commands.setup(force, demo_data, stop_services, services)
on_fail = "Failed to setup services."
on_success = "Successfully setup all services."
Expand Down
27 changes: 27 additions & 0 deletions invenio_cli/helpers/docker_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,30 @@ def execute_cli_command(self, project_shortname, command):
output="Web UI container not found. Is it up and running?",
status_code=1,
)


class NoOpDockerHelper:
"""A no-op implementation of DockerHelper that does nothing.

It is used when services can not be started with docker (e.g. in CI/CD environments)
and has the same interface as DockerHelper.
"""

def build_images(self, pull=False, cache=True):
"""Build images action. Not implemented in NoOpDockerHelper."""
raise NotImplementedError("Build images is not implemented in NoOpDockerHelper")

def start_containers(self, app_only=False):
"""Start containers according to the specified environment.

:param app_only: Boot up only ui and api containers.
"""
return ProcessResponse()

def stop_containers(self):
"""Stop currently running containers."""
return ProcessResponse()

def destroy_containers(self):
"""Stop and remove all containers, volumes and images."""
return ProcessResponse()