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
9 changes: 9 additions & 0 deletions getdeck/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion getdeck/api/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
27 changes: 15 additions & 12 deletions getdeck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down