Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TTY check for providing missing config values #2850

Merged
merged 7 commits into from
Sep 7, 2023
Merged
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
10 changes: 10 additions & 0 deletions api_client/python/timesketch_api_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import configparser
import logging
import os
import sys
import requests

from google.auth.transport import requests as auth_requests
Expand Down Expand Up @@ -493,6 +494,15 @@ def configure_missing_parameters(
"""
just_configured = []

if config_assistant.missing:
if not sys.stdout.isatty() or not sys.stdin.isatty():
msg = (
"You will be asked to provide config values, but the session"
" doesn't have a tty. Please set up your config file, or "
"rerun in a tty."
)
raise RuntimeError(msg)

for field in config_assistant.missing:
hint = config_assistant.CONFIG_HINTS.get(field, "")
value = cli_input.ask_question(
Expand Down