Skip to content

Commit

Permalink
Converts Docker Compose to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanderaa committed Aug 1, 2023
1 parent 64162c6 commit a3d1961
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,26 @@ def task_wrapper(function=None):


def docker_compose(context, command, **kwargs):
"""Helper function for running a specific docker-compose command with all appropriate parameters and environment.
"""Helper function for running a specific docker compose command with all appropriate parameters and environment.
Args:
context (obj): Used to run specific commands
command (str): Command string to append to the "docker-compose ..." command, such as "build", "up", etc.
command (str): Command string to append to the "docker compose ..." command, such as "build", "up", etc.
**kwargs: Passed through to the context.run() call.
"""
build_env = {
# Note: 'docker-compose logs' will stop following after 60 seconds by default,
# Note: 'docker compose logs' will stop following after 60 seconds by default,
# so we are overriding that by setting this environment variable.
"COMPOSE_HTTP_TIMEOUT": context.design_builder.compose_http_timeout,
"NAUTOBOT_VER": context.design_builder.nautobot_ver,
"PYTHON_VER": context.design_builder.python_ver,
}
compose_command = f'docker-compose --project-name {context.design_builder.project_name} --project-directory "{context.design_builder.compose_dir}"'
compose_command = f'docker compose --project-name {context.design_builder.project_name} --project-directory "{context.design_builder.compose_dir}"'
for compose_file in context.design_builder.compose_files:
compose_file_path = os.path.join(context.design_builder.compose_dir, compose_file)
compose_command += f' -f "{compose_file_path}"'
compose_command += f" {command}"
print(f'Running docker-compose command "{command}"')
print(f'Running docker compose command "{command}"')
return context.run(compose_command, env=build_env, **kwargs)


Expand Down Expand Up @@ -193,13 +193,13 @@ def vscode(context):

@task(
help={
"service": "Docker-compose service name to view (default: nautobot)",
"service": "docker compose service name to view (default: nautobot)",
"follow": "Follow logs",
"tail": "Tail N number of lines or 'all'",
}
)
def logs(context, service="nautobot", follow=False, tail=None):
"""View the logs of a docker-compose service."""
"""View the logs of a docker compose service."""
command = "logs "

if follow:
Expand Down

0 comments on commit a3d1961

Please sign in to comment.