From ddcccde8f1dd1528fe90467bb92dcb56db039787 Mon Sep 17 00:00:00 2001 From: Conor Date: Fri, 24 Jan 2020 16:23:36 +0100 Subject: [PATCH] -e creds file fixes in docker --- credentials.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/credentials.py b/credentials.py index 7f2e3e8..81430be 100644 --- a/credentials.py +++ b/credentials.py @@ -3,6 +3,8 @@ import workspaces, sys, os def generate(args): current_workspace = workspaces.get_env() workspaces_names = ['default'] + aws_creds_dir = '~/.aws' + aws_creds_file = 'credentials' if current_workspace != 'default': workspaces_names.append(current_workspace) @@ -36,11 +38,14 @@ def generate(args): except: print("[ERROR]: Env Variable " + secret_key_name + " not found.") sys.exit(1) - with open(os.path.expanduser('~/.aws/credentials'), 'w+') as f: - if os.path.isfile(f.name): - answer = input("Found aws creds file already, do you want to override? [y/n]") - if not answer or answer[0].lower() != 'y': - print("File not changed. This flag is for CI/CD only") - exit(1) - else: - f.write(contents) \ No newline at end of file + + if os.path.isfile(aws_creds_dir + aws_creds_file): + answer = input("Found aws creds file already, do you want to override? [y/n]") + if not answer or answer[0].lower() != 'y': + print("File not changed. This flag is for CI/CD only") + exit(1) + else: + os.makedirs(os.path.expanduser(aws_creds_dir)) + + with open(os.path.expanduser(aws_creds_dir + aws_creds_file), 'w+') as f: + f.write(contents) \ No newline at end of file