diff --git a/getdeck/__main__.py b/getdeck/__main__.py index e5e1976..793bc09 100755 --- a/getdeck/__main__.py +++ b/getdeck/__main__.py @@ -63,6 +63,14 @@ def check_positive(value): type=check_positive, required=False, ) +get_parser.add_argument( + "-y", + "--no-input", + help="Disable prompting for input", + action="store_true", + default=False, + required=False, +) get_parser.add_argument("Deckfile", help=ARGUMENT_DECKFILE_HELP, nargs="?", default=".") remove_parser = action.add_parser("remove") @@ -170,6 +178,7 @@ def main(): ignore_cluster=args.no_cluster, wait=wait, timeout=timeout, + no_input=args.no_input, ) elif args.action == "remove": if args.cluster: diff --git a/getdeck/api/get.py b/getdeck/api/get.py index 5012401..a81b84c 100644 --- a/getdeck/api/get.py +++ b/getdeck/api/get.py @@ -17,6 +17,7 @@ def run_deck( # noqa: C901 ignore_cluster: bool = False, wait: bool = False, timeout: int = 120, + no_input: bool = False, config=default_configuration, progress_callback: Callable = None, ) -> bool: @@ -36,7 +37,11 @@ def run_deck( # noqa: C901 # 1. set up a local K8s cluster # k8s_provider = ensure_cluster( - data_aux.deckfile, config, ignore_cluster, do_install=True + data_aux.deckfile, + config, + ignore_cluster, + do_install=True, + no_input=no_input, ) if progress_callback: progress_callback(10) diff --git a/getdeck/utils.py b/getdeck/utils.py index b467afb..6443413 100644 --- a/getdeck/utils.py +++ b/getdeck/utils.py @@ -20,6 +20,7 @@ def ensure_cluster( config: ClientConfiguration, ignore_cluster: bool = False, do_install: bool = True, + no_input: bool = False, ) -> AbstractProvider: from kubernetes.client.rest import ApiException from getdeck.provider.factory import cluster_factory @@ -68,12 +69,13 @@ def ensure_cluster( f"but minVersion is {cluster_config.minVersion}" ) if do_install: - confirm = input( - f"Do you want to update your local {cluster_config.provider}? [y/N] " - ) - if confirm.lower() != "y": - logger.info("Operation aborted") - exit() + if not no_input: + confirm = input( + f"Do you want to update your local {cluster_config.provider}? [y/N] " + ) + if confirm.lower() != "y": + logger.info("Operation aborted") + exit() k8s_provider.update() else: logger.debug( @@ -86,12 +88,13 @@ def ensure_cluster( f"installed on your system" ) if do_install: - confirm = input( - f"Do you want to install {cluster_config.provider} on your local system? [y/N] " - ) - if confirm.lower() != "y": - logger.info("Operation aborted") - exit() + if not no_input: + confirm = input( + f"Do you want to install {cluster_config.provider} on your local system? [y/N] " + ) + if confirm.lower() != "y": + logger.info("Operation aborted") + exit() k8s_provider.install() except KeyboardInterrupt: print() # add a newline