mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #39340 from terminalmage/issue39334
Fix gpg renderer breakage from bef5e66
This commit is contained in:
commit
4f8edc36a2
@ -175,12 +175,9 @@ import salt.loader
|
||||
import salt.utils
|
||||
import salt.utils.dictupdate
|
||||
import salt.utils.minions
|
||||
import salt.utils.stringio
|
||||
import salt.template
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext.six.moves import cStringIO
|
||||
|
||||
|
||||
# Set up logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -275,7 +272,7 @@ def _construct_pillar(top_dir,
|
||||
default=render_default,
|
||||
blacklist=renderer_blacklist,
|
||||
whitelist=renderer_whitelist)
|
||||
if isinstance(data, cStringIO.InputType):
|
||||
if salt.utils.stringio.is_readable(data):
|
||||
pillar_node[file_name] = data.getvalue()
|
||||
else:
|
||||
pillar_node[file_name] = data
|
||||
|
@ -217,12 +217,12 @@ from subprocess import Popen, PIPE
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
import salt.utils.stringio
|
||||
import salt.syspaths
|
||||
from salt.exceptions import SaltRenderError
|
||||
|
||||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
from salt.ext.six.moves import cStringIO
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -279,7 +279,7 @@ def _decrypt_object(obj, translate_newlines=False):
|
||||
(string or unicode), and it contains a valid GPG header, decrypt it,
|
||||
otherwise keep going until a string is found.
|
||||
'''
|
||||
if isinstance(obj, cStringIO.InputType):
|
||||
if salt.utils.stringio.is_readable(obj):
|
||||
return _decrypt_object(obj.getvalue(), translate_newlines)
|
||||
if isinstance(obj, six.string_types):
|
||||
if GPG_HEADER.search(obj):
|
||||
|
39
salt/utils/stringio.py
Normal file
39
salt/utils/stringio.py
Normal file
@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Functions for StringIO objects
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
|
||||
# Not using six's fake cStringIO since we need to be able to tell if the object
|
||||
# is readable, and this can't be done via what six exposes.
|
||||
if six.PY2:
|
||||
import StringIO
|
||||
import cStringIO
|
||||
readable_types = (StringIO.StringIO, cStringIO.InputType)
|
||||
writable_types = (StringIO.StringIO, cStringIO.OutputType)
|
||||
else:
|
||||
import io
|
||||
readable_types = (io.StringIO,)
|
||||
writable_types = (io.StringIO,)
|
||||
|
||||
|
||||
def is_stringio(obj):
|
||||
return isinstance(obj, readable_types)
|
||||
|
||||
|
||||
def is_readable(obj):
|
||||
if six.PY2:
|
||||
return isinstance(obj, readable_types)
|
||||
else:
|
||||
return isinstance(obj, readable_types) and obj.readable()
|
||||
|
||||
|
||||
def is_writable(obj):
|
||||
if six.PY2:
|
||||
return isinstance(obj, writable_types)
|
||||
else:
|
||||
return isinstance(obj, writable_types) and obj.writable()
|
Loading…
Reference in New Issue
Block a user