edge cases

This commit is contained in:
Karsten Gorskowski 2023-11-26 23:09:04 +01:00
parent 9d867dd420
commit c5ee561bbd
1 changed files with 10 additions and 1 deletions

View File

@ -15,15 +15,24 @@ def add_subparser(subparsers):
def execute(args): def execute(args):
if args.tenant_name is not None:
tenant_name = args.tenant_name
# If tenant_name is not provided and TENANT_NAME is not set, prompt the user # If tenant_name is not provided and TENANT_NAME is not set, prompt the user
if args.tenant_name is None and os.getenv("TENANT_NAME") is None: if args.tenant_name is None and os.getenv("TENANT_NAME") is None:
tenant_name = input("Please enter the tenant name: ") tenant_name = input("Please enter the tenant name: ")
# Ask the user to confirm the tenant name if the environment variable is set # Ask the user to confirm the tenant name if the environment variable is set
if os.getenv("TENANT_NAME") and args.tenant_name is not None: if os.getenv("TENANT_NAME") == args.tenant_name:
user_confirmation = input( user_confirmation = input(
f"Use '{os.getenv('TENANT_NAME')}' as the tenant name? (yes/no): " f"Use '{os.getenv('TENANT_NAME')}' as the tenant name? (yes/no): "
).lower() ).lower()
if user_confirmation not in ("yes", "y"):
tenant_name = input("Please enter the desired tenant name: ")
if os.getenv("TENANT_NAME") and args.tenant_name != os.getenv("TENANT_NAME"):
user_confirmation = input(
f"Both env var TENANT_NAME and tenant_name argument are set. Use '{os.getenv('TENANT_NAME')}' as the tenant name? (If no, '{tenant_name}' will be used) (yes/no): "
).lower()
if user_confirmation in ("yes", "y"): if user_confirmation in ("yes", "y"):
tenant_name = os.getenv("TENANT_NAME") tenant_name = os.getenv("TENANT_NAME")