From b20738a5a1ec4d60553ad74ebeb1359d88e54b1b Mon Sep 17 00:00:00 2001 From: abednarik Date: Sun, 7 Feb 2016 22:24:38 -0300 Subject: [PATCH] File state born deprecations. Removed all Boron warning and deprecated code. --- salt/modules/file.py | 12 +++--- salt/states/file.py | 63 +------------------------------- tests/integration/states/file.py | 8 ++-- 3 files changed, 12 insertions(+), 71 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 90d4632aee..080bc5efe7 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -3999,7 +3999,7 @@ def manage_file(name, backup, makedirs=False, template=None, # pylint: disable=W0613 - show_diff=True, + show_changes=True, contents=None, dir_mode=None, follow_symlinks=True): @@ -4044,7 +4044,7 @@ def manage_file(name, template format of templating - show_diff + show_changes Include diff in state return contents: @@ -4107,8 +4107,8 @@ def manage_file(name, # Print a diff equivalent to diff -u old new if __salt__['config.option']('obfuscate_templates'): ret['changes']['diff'] = '' - elif not show_diff: - ret['changes']['diff'] = '' + elif not show_changes: + ret['changes']['diff'] = '' else: # Check to see if the files are bins bdiff = _binary_replace(real_name, sfn) @@ -4155,8 +4155,8 @@ def manage_file(name, if different: if __salt__['config.option']('obfuscate_templates'): ret['changes']['diff'] = '' - elif not show_diff: - ret['changes']['diff'] = '' + elif not show_changes: + ret['changes']['diff'] = '' else: if salt.utils.istextfile(real_name): ret['changes']['diff'] = \ diff --git a/salt/states/file.py b/salt/states/file.py index 7247f5bff6..f5792ac4c3 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -1087,7 +1087,6 @@ def managed(name, defaults=None, env=None, backup='', - show_diff=None, show_changes=True, create=True, contents=None, @@ -1254,12 +1253,6 @@ def managed(name, backup Overrides the default backup mode for this specific file. - show_diff - DEPRECATED: Please use show_changes. - - If set to ``False``, the diff will not be shown in the return data if - changes are made. - show_changes Output a unified diff of the old file and the new file. If ``False`` return a boolean if any changes were made. @@ -1530,17 +1523,6 @@ def managed(name, return _error( ret, 'Specified file {0} is not an absolute path'.format(name)) - if isinstance(env, six.string_types): - msg = ( - 'Passing a salt environment should be done using \'saltenv\' not ' - '\'env\'. This warning will go away in Salt Boron and this ' - 'will be the default and expected behavior. Please update your ' - 'state files.' - ) - salt.utils.warn_until('Boron', msg) - ret.setdefault('warnings', []).append(msg) - # No need to set __env__ = env since that's done in the state machinery - if os.path.isdir(name): ret['comment'] = 'Specified target {0} is a directory'.format(name) ret['result'] = False @@ -1589,14 +1571,6 @@ def managed(name, else: ret['pchanges'] = {} - if show_diff is not None: - show_changes = show_diff - msg = ( - 'The \'show_diff\' argument to the file.managed state has been ' - 'deprecated, please use \'show_changes\' instead.' - ) - salt.utils.warn_until('Boron', msg) - try: if __opts__['test']: if ret['pchanges']: @@ -1674,7 +1648,7 @@ def managed(name, backup, makedirs, template, - show_diff, + show_changes, contents, dir_mode, follow_symlinks) @@ -1730,7 +1704,7 @@ def managed(name, backup, makedirs, template, - show_diff, + show_changes, contents, dir_mode, follow_symlinks) @@ -2284,17 +2258,6 @@ def recurse(name, return _error( ret, 'Specified file {0} is not an absolute path'.format(name)) - if isinstance(env, six.string_types): - msg = ( - 'Passing a salt environment should be done using \'saltenv\' not ' - '\'env\'. This warning will go away in Salt Boron and this ' - 'will be the default and expected behavior. Please update your ' - 'state files.' - ) - salt.utils.warn_until('Boron', msg) - ret.setdefault('warnings', []).append(msg) - # No need to set __env__ = env since that's done in the state machinery - # expand source into source_list source_list = _validate_str_list(source) @@ -3776,17 +3739,6 @@ def patch(name, ret.update(result=True, comment='Patch is already applied') return ret - if isinstance(env, six.string_types): - msg = ( - 'Passing a salt environment should be done using \'saltenv\' not ' - '\'env\'. This warning will go away in Salt Boron and this ' - 'will be the default and expected behavior. Please update your ' - 'state files.' - ) - salt.utils.warn_until('Boron', msg) - ret.setdefault('warnings', []).append(msg) - # No need to set __env__ = env since that's done in the state machinery - # get cached file or copy it to cache cached_source_path = __salt__['cp.cache_file'](source, __env__) if not cached_source_path: @@ -4422,17 +4374,6 @@ def serialize(name, if not name: return _error(ret, 'Must provide name to file.serialize') - if isinstance(env, six.string_types): - msg = ( - 'Passing a salt environment should be done using \'saltenv\' not ' - '\'env\'. This warning will go away in Salt Boron and this ' - 'will be the default and expected behavior. Please update your ' - 'state files.' - ) - salt.utils.warn_until('Boron', msg) - ret.setdefault('warnings', []).append(msg) - # No need to set __env__ = env since that's done in the state machinery - if not create: if not os.path.isfile(name): # Don't create a file that is not already present diff --git a/tests/integration/states/file.py b/tests/integration/states/file.py index 0d71933aad..ad0da2fd75 100644 --- a/tests/integration/states/file.py +++ b/tests/integration/states/file.py @@ -233,21 +233,21 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn): self.assertSaltNoneReturn(ret) self.assertFalse(os.path.isfile(name)) - def test_managed_show_diff_false(self): + def test_managed_show_changes_false(self): ''' file.managed test interface ''' name = os.path.join(integration.TMP, 'grail_not_scene33') with salt.utils.fopen(name, 'wb') as fp_: - fp_.write('test_managed_show_diff_false\n') + fp_.write('test_managed_show_changes_false\n') ret = self.run_state( 'file.managed', name=name, source='salt://grail/scene33', - show_diff=False + show_changes=False ) changes = next(six.itervalues(ret))['changes'] - self.assertEqual('', changes['diff']) + self.assertEqual('', changes['diff']) def test_managed_escaped_file_path(self): '''