Created
July 25, 2018 09:21
-
-
Save sideshowbandana/a631c1bf59f52fafb2359ac1f2d08898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
import pathlib | |
from subprocess import call | |
ENV_DIR = ".env" | |
ENV = os.environ.get('ENV') | |
SERVICE = os.environ.get('SERVICE') | |
NAMESPACE = os.environ.get('NAMESPACE') | |
FILE= os.environ.get('FILE') | |
CONFIG_FILES = [ | |
os.path.join(ENV_DIR, "{}.env".format(ENV)), | |
os.path.join(ENV_DIR, "{}.env".format(SERVICE)), | |
os.path.join(ENV_DIR, "{}.env".format(NAMESPACE)), | |
os.path.join(ENV_DIR, ENV, "{}.env".format(SERVICE)), | |
os.path.join(ENV_DIR, ENV, NAMESPACE, "{}.env".format(SERVICE)) | |
] | |
values = dict() | |
for file in CONFIG_FILES: | |
if os.path.isfile(file): | |
for line in open(file, 'r'): | |
key, value = line.rstrip().split("=", 1) | |
values[key] = value | |
with open(FILE, 'w') as f: | |
for key, value in values.items(): | |
f.write("{}={}\n".format(key, value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment