Merge branch '2018.3.4' into bp-51170

This commit is contained in:
Daniel Wozniak 2019-01-27 16:44:10 -07:00 committed by GitHub
commit 4e855050e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 12 deletions

View file

@ -2421,7 +2421,6 @@ def managed(name,
'to True to allow the managed file to be empty.'
.format(contents_id)
)
if isinstance(use_contents, six.binary_type) and b'\0' in use_contents:
contents = use_contents
elif isinstance(use_contents, six.text_type) and str('\0') in use_contents:
@ -2435,9 +2434,10 @@ def managed(name,
'contents_grains is not a string or list of strings, and '
'is not binary data. SLS is likely malformed.'
)
contents = os.linesep.join(
[line.rstrip('\n').rstrip('\r') for line in validated_contents]
)
contents = ''
for part in validated_contents:
for line in part.splitlines():
contents += line.rstrip('\n').rstrip('\r') + os.linesep
if contents_newline and not contents.endswith(os.linesep):
contents += os.linesep
if template:

View file

@ -1935,7 +1935,7 @@ def parse_host_port(host_port):
if _s_[0] == "[":
if "]" in host_port:
host, _s_ = _s_.lstrip("[").rsplit("]", 1)
host = ipaddress.IPv6Address(host)
host = ipaddress.IPv6Address(host).compressed
if _s_[0] == ":":
port = int(_s_.lstrip(":"))
else:
@ -1953,7 +1953,7 @@ def parse_host_port(host_port):
host = _s_
try:
if not isinstance(host, ipaddress._BaseAddress):
host_ip = ipaddress.ip_address(host)
host_ip = ipaddress.ip_address(host).compressed
host = host_ip
except ValueError:
log.debug('"%s" Not an IP address? Assuming it is a hostname.', host)

View file

@ -743,6 +743,12 @@ class TestDaemon(object):
master_opts['root_dir'] = os.path.join(TMP, 'rootdir')
master_opts['pki_dir'] = os.path.join(TMP, 'rootdir', 'pki', 'master')
master_opts['syndic_master'] = 'localhost'
file_tree = {
'root_dir': os.path.join(FILES, 'pillar', 'base', 'file_tree'),
'follow_dir_links': False,
'keep_newline': True,
}
master_opts['ext_pillar'].append({'file_tree': file_tree})
# This is the syndic for master
# Let's start with a copy of the syndic master configuration

View file

@ -0,0 +1,3 @@
{{ pillar['name'] }}:
file.managed:
- contents_pillar: issue-50221

View file

@ -2530,6 +2530,26 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'',
]).encode('utf-8'))
@with_tempfile()
def test_issue_50221(self, name):
expected = 'abc{0}{0}{0}'.format(os.linesep)
ret = self.run_function(
'pillar.get',
['issue-50221']
)
assert ret == expected
ret = self.run_function(
'state.apply',
['issue-50221'],
pillar={
'name': name
},
)
self.assertSaltTrueReturn(ret)
with salt.utils.files.fopen(name, 'r') as fp:
contents = fp.read()
assert contents == expected
class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin):
marker_start = '# start'

View file

@ -206,12 +206,12 @@ class NetworkTestCase(TestCase):
def test_parse_host_port(self):
_ip = ipaddress.ip_address
good_host_ports = {
'10.10.0.3': (_ip('10.10.0.3'), None),
'10.10.0.3:1234': (_ip('10.10.0.3'), 1234),
'2001:0db8:85a3::8a2e:0370:7334': (_ip('2001:0db8:85a3::8a2e:0370:7334'), None),
'[2001:0db8:85a3::8a2e:0370:7334]:1234': (_ip('2001:0db8:85a3::8a2e:0370:7334'), 1234),
'2001:0db8:85a3::7334': (_ip('2001:0db8:85a3::7334'), None),
'[2001:0db8:85a3::7334]:1234': (_ip('2001:0db8:85a3::7334'), 1234)
'10.10.0.3': (_ip('10.10.0.3').compressed, None),
'10.10.0.3:1234': (_ip('10.10.0.3').compressed, 1234),
'2001:0db8:85a3::8a2e:0370:7334': (_ip('2001:0db8:85a3::8a2e:0370:7334').compressed, None),
'[2001:0db8:85a3::8a2e:0370:7334]:1234': (_ip('2001:0db8:85a3::8a2e:0370:7334').compressed, 1234),
'2001:0db8:85a3::7334': (_ip('2001:0db8:85a3::7334').compressed, None),
'[2001:0db8:85a3::7334]:1234': (_ip('2001:0db8:85a3::7334').compressed, 1234)
}
bad_host_ports = [
'10.10.0.3/24',