Skip to content

Commit

Permalink
Merge pull request #55614 from Ch3LL/issue_49428
Browse files Browse the repository at this point in the history
Deprecate jinja filters for neon
  • Loading branch information
dwoz authored Dec 21, 2019
2 parents 42b8d42 + 0b25aca commit cea3fe0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
8 changes: 4 additions & 4 deletions doc/topics/jinja/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ Example:
Renamed from ``json_decode_list`` to ``json_encode_list``. When you encode
something you get bytes, and when you decode, you get your locale's
encoding (usually a ``unicode`` type). This filter was incorrectly-named
when it was added. ``json_decode_list`` will be supported until the Neon
when it was added. ``json_decode_list`` will be supported until the Aluminium
release.
.. deprecated:: 2018.3.3,2019.2.0
The :jinja_ref:`tojson` filter accomplishes what this filter was designed
Expand Down Expand Up @@ -947,7 +947,7 @@ Returns:
Renamed from ``json_decode_dict`` to ``json_encode_dict``. When you encode
something you get bytes, and when you decode, you get your locale's
encoding (usually a ``unicode`` type). This filter was incorrectly-named
when it was added. ``json_decode_dict`` will be supported until the Neon
when it was added. ``json_decode_dict`` will be supported until the Aluminium
release.
.. deprecated:: 2018.3.3,2019.2.0
The :jinja_ref:`tojson` filter accomplishes what this filter was designed
Expand Down Expand Up @@ -995,8 +995,8 @@ installed, then the upstream version of the filter will be used. See the
.. versionadded:: 2017.7.0
.. versionadded:: 2018.3.0
Renamed from ``rand_str`` to ``random_hash`` to more accurately describe
what the filter does. ``rand_str`` will be supported until the Neon
release.
what the filter does. ``rand_str`` will be supported to ensure backwards
compatibility but please use the preferred ``random_hash``.

Generates a random number between 1 and the number passed to the filter, and
then hashes it. The default hash type is the one specified by the minion's
Expand Down
8 changes: 4 additions & 4 deletions salt/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ def encode(data, encoding=None, errors='strict', keep=False,
return data


@jinja_filter('json_decode_dict') # Remove this for Neon
@jinja_filter('json_encode_dict') # Remove this for Neon
@jinja_filter('json_decode_dict') # Remove this for Aluminium
@jinja_filter('json_encode_dict')
def encode_dict(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False, preserve_tuples=False):
'''
Expand Down Expand Up @@ -412,8 +412,8 @@ def encode_dict(data, encoding=None, errors='strict', keep=False,
return rv


@jinja_filter('json_decode_list') # Remove this for Neon
@jinja_filter('json_encode_list') # Remove this for Neon
@jinja_filter('json_decode_list') # Remove this for Aluminium
@jinja_filter('json_encode_list')
def encode_list(data, encoding=None, errors='strict', keep=False,
preserve_dict_class=False, preserve_tuples=False):
'''
Expand Down
1 change: 1 addition & 0 deletions salt/utils/hashutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def hmac_compute(string, shared_secret):
return hmac_hash


@jinja_filter('rand_str')
@jinja_filter('random_hash')
def random_hash(size=9999999999, hash_type=None):
'''
Expand Down
8 changes: 0 additions & 8 deletions salt/utils/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,6 @@ def lst_avg(lst):
2.5
'''
salt.utils.versions.warn_until(
'Neon',
'This results of this function are currently being rounded.'
'Beginning in the Salt Neon release, results will no longer be '
'rounded and this warning will be removed.',
stacklevel=3
)

if not isinstance(lst, collections.Hashable):
return float(sum(lst)/len(lst))
return float(lst)
Expand Down
2 changes: 1 addition & 1 deletion salt/utils/stringutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _normalize(s):
raise TypeError('expected str, bytes, or bytearray not {}'.format(type(s)))


@jinja_filter('str_to_num') # Remove this for Neon
@jinja_filter('str_to_num')
@jinja_filter('to_num')
def to_num(text):
'''
Expand Down

0 comments on commit cea3fe0

Please sign in to comment.