formatting
This commit is contained in:
parent
437caa437e
commit
9d867dd420
|
|
@ -1,10 +1,16 @@
|
|||
# tenant/commands/certrenew.py
|
||||
from tenant.utils.common import get_secure_password
|
||||
|
||||
|
||||
def add_subparser(subparsers):
|
||||
certrenew_parser = subparsers.add_parser("certrenew", help="Renew certificates for a tenant")
|
||||
certrenew_parser = subparsers.add_parser(
|
||||
"certrenew", help="Renew certificates for a tenant"
|
||||
)
|
||||
certrenew_parser.add_argument("tenant_name", help="Name of the tenant")
|
||||
certrenew_parser.add_argument("--force", action="store_true", help="Force certificate renewal")
|
||||
certrenew_parser.add_argument(
|
||||
"--force", action="store_true", help="Force certificate renewal"
|
||||
)
|
||||
|
||||
|
||||
def execute(args):
|
||||
tenant_name = args.tenant_name
|
||||
|
|
|
|||
|
|
@ -2,13 +2,31 @@
|
|||
import os
|
||||
from tenant.utils.common import get_secure_password
|
||||
|
||||
|
||||
def add_subparser(subparsers):
|
||||
init_parser = subparsers.add_parser("init", help="Initialize a new tenant")
|
||||
init_parser.add_argument("tenant_name", help="Name of the tenant")
|
||||
init_parser.add_argument("--target", default=".", help="Target directory (default: current directory)")
|
||||
default_tenant_name = os.getenv("TENANT_NAME", None)
|
||||
init_parser.add_argument(
|
||||
"tenant_name", help="Name of the tenant", default=default_tenant_name, nargs="?"
|
||||
)
|
||||
init_parser.add_argument(
|
||||
"--target", default=".", help="Target directory (default: current directory)"
|
||||
)
|
||||
|
||||
|
||||
def execute(args):
|
||||
tenant_name = args.tenant_name
|
||||
# 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:
|
||||
tenant_name = input("Please enter the tenant name: ")
|
||||
|
||||
# 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:
|
||||
user_confirmation = input(
|
||||
f"Use '{os.getenv('TENANT_NAME')}' as the tenant name? (yes/no): "
|
||||
).lower()
|
||||
if user_confirmation in ("yes", "y"):
|
||||
tenant_name = os.getenv("TENANT_NAME")
|
||||
|
||||
target_directory = args.target
|
||||
|
||||
tenant_directory = os.path.join(target_directory, tenant_name)
|
||||
|
|
@ -19,7 +37,9 @@ def execute(args):
|
|||
return
|
||||
|
||||
# Prompt the user for the GitSync password securely
|
||||
git_sync_password = get_secure_password(prompt="Please insert known password for GitSync: ")
|
||||
git_sync_password = get_secure_password(
|
||||
prompt="Please insert known password for GitSync: "
|
||||
)
|
||||
|
||||
terraform_directory = os.path.join(tenant_directory, "terraform")
|
||||
kubernetes_directory = os.path.join(tenant_directory, "kubernetes")
|
||||
|
|
@ -42,5 +62,9 @@ def execute(args):
|
|||
relative_path = os.path.relpath(source_path, target_tf_dir)
|
||||
os.symlink(relative_path, target_path)
|
||||
else:
|
||||
print(f"Warning: Source file '{filename}' not found in '{source_tf_dir}'.")
|
||||
print(f"Tenant '{tenant_name}' initialized in '{tenant_directory}' with GitSync password provided.")
|
||||
print(
|
||||
f"Warning: Source file '{filename}' not found in '{source_tf_dir}'."
|
||||
)
|
||||
print(
|
||||
f"Tenant '{tenant_name}' initialized in '{tenant_directory}' with GitSync password provided."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
# tenant/commands/resize.py
|
||||
from tenant.utils.common import get_secure_password
|
||||
|
||||
|
||||
def add_subparser(subparsers):
|
||||
resize_parser = subparsers.add_parser("resize", help="Resize resources for a tenant")
|
||||
resize_parser = subparsers.add_parser(
|
||||
"resize", help="Resize resources for a tenant"
|
||||
)
|
||||
resize_parser.add_argument("tenant_name", help="Name of the tenant")
|
||||
resize_parser.add_argument("--new-size", type=int, help="New size for resources")
|
||||
|
||||
|
||||
def execute(args):
|
||||
tenant_name = args.tenant_name
|
||||
new_size = args.new_size
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@
|
|||
import argparse
|
||||
from tenant.commands import init, certrenew, resize
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="TenantGenerator - Generate tenant folder structure")
|
||||
parser = argparse.ArgumentParser(
|
||||
description="TenantGenerator - Generate tenant folder structure"
|
||||
)
|
||||
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
||||
|
||||
# Add subparsers for each command
|
||||
|
|
@ -22,5 +25,6 @@ def main():
|
|||
else:
|
||||
print("Unknown command")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# tenant/utils/common.py
|
||||
import getpass
|
||||
|
||||
|
||||
def get_secure_password(prompt="Enter password: "):
|
||||
# Use getpass to securely input a password without displaying it
|
||||
return getpass.getpass(prompt=prompt)
|
||||
|
|
|
|||
Loading…
Reference in New Issue