Fix issue with -e flag not generating file correctly

This commit is contained in:
Conor McManus 2023-01-24 16:50:12 +01:00
parent 4829fe8f54
commit 9491a890ab

View file

@ -7,6 +7,15 @@ def generate(args):
aws_creds_file = 'credentials' aws_creds_file = 'credentials'
aws_creds_full = aws_creds_dir + '/' + aws_creds_file aws_creds_full = aws_creds_dir + '/' + aws_creds_file
if os.path.isfile(os.path.expanduser(aws_creds_full)):
answer = input(f"[WARNING] File {aws_creds_full} already exists. Atmos will generate a new credentials file from your env vars. \nDo you want to override {aws_creds_full}? [y/N]")
if not answer or answer[0].lower() != 'y':
print("File not changed. This flag is for CI/CD only")
exit(1)
else:
if not os.path.isdir(os.path.expanduser(aws_creds_dir)):
os.makedirs(os.path.expanduser(aws_creds_dir))
if current_workspace != 'default': if current_workspace != 'default':
workspaces_names.append(current_workspace) workspaces_names.append(current_workspace)
@ -40,14 +49,5 @@ def generate(args):
print("[ERROR]: Env Variable " + secret_key_name + " not found.") print("[ERROR]: Env Variable " + secret_key_name + " not found.")
sys.exit(1) sys.exit(1)
if os.path.isfile(os.path.expanduser(aws_creds_full)):
answer = input(f"[WARNING] File {aws_creds_full} already exists. Atmos will generate a new credentials file from your env vars. \nDo you want to override {aws_creds_full}? [y/N]")
if not answer or answer[0].lower() != 'y':
print("File not changed. This flag is for CI/CD only")
exit(1)
else:
if not os.path.isdir(os.path.expanduser(aws_creds_dir)):
os.makedirs(os.path.expanduser(aws_creds_dir))
with open(os.path.expanduser(aws_creds_full), 'w+') as f: with open(os.path.expanduser(aws_creds_full), 'w+') as f:
f.write(contents) f.write(contents)