From 8d2ca9b5bfd5f69ca01399bd7d4294426603cf2c Mon Sep 17 00:00:00 2001 From: Zak Wheaton Date: Wed, 13 Sep 2017 23:55:55 -0700 Subject: [PATCH 1/4] moves the encrypt block above where config gets reassigned for a proper path, referece to Secrets class properly --- dojo/run.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dojo/run.py b/dojo/run.py index 99c21da..b784433 100644 --- a/dojo/run.py +++ b/dojo/run.py @@ -25,15 +25,15 @@ class Entrypoint(object): jobs_config = self._read_yaml(config_file) base_config['jobs'].update(jobs_config['jobs']) + # Build secrets by decrypting available JSONs + env_json_secrets_path = os.path.join(config, 'secrets.%s.json.enc' % (env, )) + secrets = Secrets().decrypt(env_json_secrets_path) + # Build the envionment-specific config, and merged to rendered config.json. env_config_path = os.path.join(config, 'config.%s.yml' % (env, )) env_config = self._read_yaml(env_config_path) or {} config = deep_merge(base_config, env_config) - # Build secrets by decrypting available JSONs - env_json_secrets_path = os.path.join(base_config_path, 'secrets.%s.json.enc' % (env, )) - secrets = Secrets.decrypt(env_json_secrets_path) - # Build the job. job = self._build_job(name, config, secrets, runner) -- GitLab From 184e51697f3f4793eab638c7cfe87c74866f9c3b Mon Sep 17 00:00:00 2001 From: Zak Wheaton Date: Thu, 14 Sep 2017 00:00:45 -0700 Subject: [PATCH 2/4] moves a variable to be reference, adds the unencrypted json to be wrote to file for changing and later encrypting --- dojo/secrets.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dojo/secrets.py b/dojo/secrets.py index ee4b09a..09e24ba 100644 --- a/dojo/secrets.py +++ b/dojo/secrets.py @@ -32,9 +32,10 @@ class Secrets(object): secrets_file = self._read_file(json_secrets_path) # If there aren't any encrypted files, try loading the unecrypted file instead - if os.path.isfile(json_secrets_path.split('.enc')[0]) and not os.path.isfile(json_secrets_path): + unecrypted_secrets_file = json_secrets_path.split('.enc')[0] + if os.path.isfile(unecrypted_secrets_file) and not os.path.isfile(json_secrets_path): try: - secrets = json.loads(open(json_secrets_path.split('.enc')[0]).read()) + secrets = json.loads(open(unecrypted_secrets_file).read()) except ValueError as e: raise ValueError(e) else: @@ -46,6 +47,9 @@ class Secrets(object): raise ValueError(e) try: secrets = json.loads(out) + # TODO perhaps only write to file in the dev enviroment + with open(unecrypted_secrets_file, 'w') as f: + json.dump(secrets, f, sort_keys=True, indent=4) except ValueError as e: raise ValueError(e, out) @@ -56,4 +60,4 @@ class Secrets(object): with open(path, 'r') as f: return f.read() else: - return {} + return {} \ No newline at end of file -- GitLab From 1d4cd31d8f3db474fa648c3ae68d844487d7d70e Mon Sep 17 00:00:00 2001 From: Zak Wheaton Date: Thu, 14 Sep 2017 00:44:44 -0700 Subject: [PATCH 3/4] autolint --- dojo/secrets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dojo/secrets.py b/dojo/secrets.py index 09e24ba..d79fa4d 100644 --- a/dojo/secrets.py +++ b/dojo/secrets.py @@ -60,4 +60,4 @@ class Secrets(object): with open(path, 'r') as f: return f.read() else: - return {} \ No newline at end of file + return {} -- GitLab From 571f89819b55a19dd465ad17c9380a16cf0451fd Mon Sep 17 00:00:00 2001 From: Zak Wheaton Date: Thu, 14 Sep 2017 12:49:10 -0700 Subject: [PATCH 4/4] version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9afdf28..56f9c6a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup( name='dojo', - version='0.0.41', + version='0.0.42', description='A framework for building and running your data platform.', author='Data Up', author_email='dojo@dataup.me', -- GitLab