Merge "Prevent trailing whitespace in rendered JSON"

This commit is contained in:
Jenkins 2017-01-23 21:36:44 +00:00 committed by Gerrit Code Review
commit a49c1f6d5e
7 changed files with 13 additions and 9 deletions

View File

@ -128,7 +128,7 @@ def main(argv=sys.argv):
node_file = os.path.join(node_path, "%s.json" % fqdn)
with os.fdopen(os.open(node_file, os.O_CREAT | os.O_WRONLY, 0o600),
'w') as f:
f.write(json.dumps(node_config, indent=4))
f.write(json.dumps(node_config, indent=4, separators=(',', ': ')))
client_config += "\nnode_path '%s'" % node_path
# write out the completed client config

View File

@ -138,7 +138,7 @@ def write_project(c):
with os.fdopen(os.open(
proj_file, os.O_CREAT | os.O_WRONLY | os.O_TRUNC, 0o600),
'w') as f:
json.dump(proj_data, f, indent=2)
json.dump(proj_data, f, indent=2, separators=(',', ': '))
if __name__ == '__main__':

View File

@ -69,7 +69,8 @@ def main(argv=sys.argv):
os.O_CREAT | os.O_TRUNC | os.O_WRONLY,
0o600),
'w') as hiera_data_file:
json.dump(data, hiera_data_file, indent=4, sort_keys=True)
json.dump(data, hiera_data_file, indent=4, sort_keys=True,
separators=(',', ': '))
response = {
'deploy_stdout': '',

View File

@ -38,7 +38,8 @@ def main(argv=sys.argv):
prepare_dir(os.path.dirname(fname))
data = c.get(fname)
with open(fname, 'w') as json_data_file:
json.dump(data, json_data_file, indent=4, sort_keys=True)
json.dump(data, json_data_file, indent=4, sort_keys=True,
separators=(',', ': '))
response = {
'deploy_stdout': '',

View File

@ -66,7 +66,7 @@ def write_manifest(c):
fn = os.path.join(MANIFESTS_DIR, '%s.json' % c['id'])
with os.fdopen(os.open(fn, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
json.dump(c['config'], f, indent=2)
json.dump(c['config'], f, indent=2, separators=(',', ': '))
if __name__ == '__main__':
sys.exit(main(sys.argv))

View File

@ -138,7 +138,7 @@ def invoke_hook(c, log):
# subsequent hook success
with os.fdopen(os.open(
deployed_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
json.dump(c, f, indent=2)
json.dump(c, f, indent=2, separators=(',', ': '))
log.debug('Running %s < %s' % (hook_path, deployed_path))
subproc = subprocess.Popen([hook_path],
@ -170,7 +170,7 @@ def invoke_hook(c, log):
# write out notify data for debugging
with os.fdopen(os.open(
signal_data_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
json.dump(signal_data, f, indent=2)
json.dump(signal_data, f, indent=2, separators=(',', ': '))
log.debug('Running %s %s < %s' % (
HEAT_CONFIG_NOTIFY, deployed_path, signal_data_path))

View File

@ -91,7 +91,8 @@ class HookChefTest(common.RunScriptTest):
'fooval': {u'bar': u'baz'},
'run_list': [u'recipe[apache]']
}
exp_node = json.dumps(exp_node, indent=4)
exp_node = json.dumps(exp_node, indent=4,
separators=(',', ': '))
exp_cfg = ("log_level :debug\n"
"log_location STDOUT\n"
"local_mode true\n"
@ -188,7 +189,8 @@ class HookChefTest(common.RunScriptTest):
'fooval': {u'bar': u'baz'},
'run_list': [u'recipe[apache]']
}
exp_node = json.dumps(exp_node, indent=4)
exp_node = json.dumps(exp_node, indent=4,
separators=(',', ': '))
exp_cfg = ("log_level :debug\n"
"log_location STDOUT\n"
"local_mode true\n"