Copy config files into logs/global/config-copy/ directory

Fixes: https://pagure.io/pungi/issue/994
Merges: https://pagure.io/pungi/pull-request/1013
Signed-off-by: Mohan Boddu <mboddu@bhujji.com>
This commit is contained in:
Mohan Boddu 2018-07-26 17:55:13 -04:00 committed by Lubomír Sedlář
parent 7e923d3823
commit 4864a0f58e
1 changed files with 5 additions and 6 deletions

View File

@ -13,6 +13,7 @@ import socket
import signal
import sys
import traceback
import shutil
from six.moves import shlex_quote
@ -285,13 +286,11 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None):
compose.read_variants()
# dump the config file
config_copy_path = os.path.join(compose.paths.log.topdir(), "config-copy")
if not os.path.exists(config_copy_path):
os.makedirs(config_copy_path)
for config_file in compose.conf.opened_files:
config_dump = compose.paths.log.log_file(
"global", "config-copy_%s" % os.path.basename(config_file)
)
with open(config_dump, "w") as dest:
with open(config_file, 'r') as src:
dest.write(src.read())
shutil.copy2(config_file, config_copy_path)
config_dump_full = compose.paths.log.log_file("global", "config-dump")
with open(config_dump_full, "w") as f:
json.dump(compose.conf, f, sort_keys=True, indent=4)