Browse Source

ref(devservices): Add --skip-only-if flag to devservices up (#24653)

Evan Purkhiser 4 years ago
parent
commit
562cf77dbc
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/sentry/runner/commands/devservices.py

+ 7 - 4
src/sentry/runner/commands/devservices.py

@@ -159,8 +159,11 @@ def attach(ctx, project, fast, service):
 @click.option("--project", default="sentry")
 @click.option("--exclude", multiple=True, help="Service to ignore and not run. Repeatable option.")
 @click.option("--fast", is_flag=True, default=False, help="Never pull and reuse containers.")
+@click.option(
+    "--skip-only-if", is_flag=True, default=False, help="Skip 'only_if' checks for services"
+)
 @click.pass_context
-def up(ctx, services, project, exclude, fast):
+def up(ctx, services, project, exclude, fast, skip_only_if):
     """
     Run/update all devservices in the background.
 
@@ -173,7 +176,7 @@ def up(ctx, services, project, exclude, fast):
 
     configure()
 
-    containers = _prepare_containers(project, silent=True)
+    containers = _prepare_containers(project, skip_only_if=skip_only_if, silent=True)
     selected_services = set()
 
     if services:
@@ -216,7 +219,7 @@ def up(ctx, services, project, exclude, fast):
         )
 
 
-def _prepare_containers(project, silent=False):
+def _prepare_containers(project, skip_only_if=False, silent=False):
     from django.conf import settings
     from sentry import options as sentry_options
 
@@ -225,7 +228,7 @@ def _prepare_containers(project, silent=False):
     for name, options in settings.SENTRY_DEVSERVICES.items():
         options = options.copy()
         test_fn = options.pop("only_if", None)
-        if test_fn and not test_fn(settings, sentry_options):
+        if not skip_only_if and test_fn and not test_fn(settings, sentry_options):
             if not silent:
                 click.secho(f"! Skipping {name} due to only_if condition", err=True, fg="cyan")
             continue