mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Get rid of additional newline append
This looks like it was just incorrectly done before. writelines() expects you to take care of newlines yourself, so each element should end in a newline. But we were doing two separate writes, one with the key=value pair and one with a newline
This commit is contained in:
parent
7427e192ba
commit
db19636f56
2 changed files with 1 additions and 5 deletions
|
@ -179,13 +179,10 @@ def persist(name, value, config='/etc/sysctl.conf', apply_change=False):
|
|||
rest = rest[len(rest_v):]
|
||||
if rest_v == value:
|
||||
return 'Already set'
|
||||
new_line = '{0}={1}\n'.format(name, value)
|
||||
nlines.append(new_line)
|
||||
nlines.append('\n')
|
||||
nlines.append('{0}={1}\n'.format(name, value))
|
||||
edited = True
|
||||
if not edited:
|
||||
nlines.append('{0}={1}\n'.format(name, value))
|
||||
nlines.append('\n')
|
||||
nlines = [salt.utils.stringutils.to_str(_l) for _l in nlines]
|
||||
with salt.utils.files.fopen(config, 'w+') as ofile:
|
||||
ofile.writelines(nlines)
|
||||
|
|
|
@ -96,7 +96,6 @@ class DarwinSysctlTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'# Kernel sysctl configuration\n',
|
||||
'#\n',
|
||||
'net.inet.icmp.icmplim=50\n',
|
||||
'\n',
|
||||
])]
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=to_write)) as m_open, \
|
||||
patch('os.path.isfile', MagicMock(return_value=True)):
|
||||
|
|
Loading…
Add table
Reference in a new issue