Skip to content

Commit

Permalink
Allow non-interactive migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Sticky-Bits committed Apr 17, 2020
1 parent bb1c358 commit faccfe9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions gitops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,24 @@ def bump(ctx, filter, exclude='', image_tag=None, prefix=None, autoexclude_inact


@task
def command(ctx, filter, command, exclude='', cleanup=True, sequential=True):
def command(ctx, filter, command, exclude='', cleanup=True, sequential=True, interactive=True):
""" Run command on selected app(s).
eg. inv command customer,sandbox -e aesg "python manage.py migrate"
"""
try:
apps = get_apps(filter=filter, exclude=exclude, message=f"{colourise('The command', Fore.LIGHTBLUE_EX)} {colourise(command, Fore.LIGHTYELLOW_EX)} {colourise('will be run on the following apps:', Fore.LIGHTBLUE_EX)}")
apps = get_apps(
filter=filter,
exclude=exclude,
message=f"{colourise('The command', Fore.LIGHTBLUE_EX)} {colourise(command, Fore.LIGHTYELLOW_EX)} {colourise('will be run on the following apps:', Fore.LIGHTBLUE_EX)}",
mode='PROMPT' if interactive else 'SILENT',
)
except AppOperationAborted:
print(success_negative('Aborted.'))
return

if sequential or len(apps) == 1:
# async output is by nature interactive
if sequential or (not interactive) or len(apps) == 1:
for app in apps:
# For each app, just run the coroutine and print the output
print(asyncio.run(run_job(app, command, cleanup=cleanup, sequential=sequential)))
Expand Down
4 changes: 2 additions & 2 deletions gitops/shorthands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def shell_plus(ctx, app, cleanup=True):


@task
def migrate(ctx, filter, exclude='', cleanup=True, sequential=False):
def migrate(ctx, filter, exclude='', cleanup=True, sequential=False, interactive=True):
""" Runs migrations for selected app.
eg. inv migrate workforce,sandbox
"""
return command(ctx, filter, f'python manage.py migrate', exclude=exclude, cleanup=cleanup, sequential=sequential)
return command(ctx, filter, f'python manage.py migrate', exclude=exclude, cleanup=cleanup, sequential=sequential, interactive=interactive)

0 comments on commit faccfe9

Please sign in to comment.