Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate gitfs_env_whitelist and gitfs_env_blacklist #55725

Merged
merged 4 commits into from
Dec 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/ref/states/top.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ disregarded:
With :ref:`GitFS <tutorial-gitfs>`, it can also be helpful to simply manage
each environment's top file separately, and/or manually specify the environment
when executing the highstate to avoid any complicated merging scenarios.
:conf_master:`gitfs_env_whitelist` and :conf_master:`gitfs_env_blacklist` can
:conf_master:`gitfs_saltenv_whitelist` and :conf_master:`gitfs_saltenv_blacklist` can
also be used to hide unneeded branches and tags from GitFS to reduce the number
of top files in play.

Expand Down
6 changes: 0 additions & 6 deletions salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,6 @@ def _gather_buffer_space():
'gitfs_privkey': six.string_types,
'gitfs_pubkey': six.string_types,
'gitfs_passphrase': six.string_types,
'gitfs_env_whitelist': list,
'gitfs_env_blacklist': list,
'gitfs_saltenv_whitelist': list,
'gitfs_saltenv_blacklist': list,
'gitfs_ssl_verify': bool,
Expand Down Expand Up @@ -1318,8 +1316,6 @@ def _gather_buffer_space():
'gitfs_privkey': '',
'gitfs_pubkey': '',
'gitfs_passphrase': '',
'gitfs_env_whitelist': [],
'gitfs_env_blacklist': [],
'gitfs_saltenv_whitelist': [],
'gitfs_saltenv_blacklist': [],
'gitfs_global_lock': True,
Expand Down Expand Up @@ -1563,8 +1559,6 @@ def _gather_buffer_space():
'gitfs_privkey': '',
'gitfs_pubkey': '',
'gitfs_passphrase': '',
'gitfs_env_whitelist': [],
'gitfs_env_blacklist': [],
'gitfs_saltenv_whitelist': [],
'gitfs_saltenv_blacklist': [],
'gitfs_global_lock': True,
Expand Down
4 changes: 2 additions & 2 deletions salt/fileserver/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
PER_REMOTE_OVERRIDES = (
'base', 'mountpoint', 'root', 'ssl_verify',
'saltenv_whitelist', 'saltenv_blacklist',
'env_whitelist', 'env_blacklist', 'refspecs',
'disable_saltenv_mapping', 'ref_types', 'update_interval',
'refspecs', 'disable_saltenv_mapping',
'ref_types', 'update_interval',
)
PER_REMOTE_ONLY = ('all_saltenvs', 'name', 'saltenv')

Expand Down
13 changes: 0 additions & 13 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ def enforce_types(key, val):
'ssl_verify': bool,
'insecure_auth': bool,
'disable_saltenv_mapping': bool,
'env_whitelist': 'stringlist',
'env_blacklist': 'stringlist',
'saltenv_whitelist': 'stringlist',
'saltenv_blacklist': 'stringlist',
'refspecs': 'stringlist',
Expand Down Expand Up @@ -391,17 +389,6 @@ def __init__(self, opts, remote, per_remote_defaults, per_remote_only,
'\'%s\'.', default_refspecs, self.role, self.id
)

for item in ('env_whitelist', 'env_blacklist'):
val = getattr(self, item, None)
if val:
salt.utils.versions.warn_until(
'Neon',
'The gitfs_{0} config option (and {0} per-remote config '
'option) have been renamed to gitfs_salt{0} (and '
'salt{0}). Please update your configuration.'.format(item)
)
setattr(self, 'salt{0}'.format(item), val)

# Discard the conf dictionary since we have set all of the config
# params as attributes
delattr(self, 'conf')
Expand Down
51 changes: 45 additions & 6 deletions tests/unit/fileserver/test_gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ def setup_loader_modules(self):
'transport': 'zeromq',
'gitfs_mountpoint': '',
'gitfs_saltenv': [],
'gitfs_env_whitelist': [],
'gitfs_env_blacklist': [],
'gitfs_saltenv_whitelist': [],
'gitfs_saltenv_blacklist': [],
'gitfs_user': '',
Expand Down Expand Up @@ -316,6 +314,51 @@ def test_disable_saltenv_mapping_global_with_mapping_defined_globally(self):
# the envs list, but the branches should not.
self.assertEqual(ret, ['base', 'foo'])

def test_saltenv_blacklist(self):
'''
test saltenv_blacklist
'''
opts = salt.utils.yaml.safe_load(textwrap.dedent('''\
gitfs_saltenv_blacklist: base
'''))
with patch.dict(gitfs.__opts__, opts):
gitfs.update()
ret = gitfs.envs(ignore_cache=True)
assert 'base' not in ret
assert UNICODE_ENVNAME in ret
assert 'mytag' in ret

def test_saltenv_whitelist(self):
'''
test saltenv_whitelist
'''
opts = salt.utils.yaml.safe_load(textwrap.dedent('''\
gitfs_saltenv_whitelist: base
'''))
with patch.dict(gitfs.__opts__, opts):
gitfs.update()
ret = gitfs.envs(ignore_cache=True)
assert 'base' in ret
assert UNICODE_ENVNAME not in ret
assert 'mytag' not in ret

def test_env_deprecated_opts(self):
'''
ensure deprecated options gitfs_env_whitelist
and gitfs_env_blacklist do not cause gitfs to
not load.
'''
opts = salt.utils.yaml.safe_load(textwrap.dedent('''\
gitfs_env_whitelist: base
gitfs_env_blacklist: ''
'''))
with patch.dict(gitfs.__opts__, opts):
gitfs.update()
ret = gitfs.envs(ignore_cache=True)
assert 'base' in ret
assert UNICODE_ENVNAME in ret
assert 'mytag' in ret

def test_disable_saltenv_mapping_global_with_mapping_defined_per_remote(self):
'''
Test the global gitfs_disable_saltenv_mapping config option, combined
Expand Down Expand Up @@ -488,8 +531,6 @@ def setup_loader_modules(self):
'transport': 'zeromq',
'gitfs_mountpoint': '',
'gitfs_saltenv': [],
'gitfs_env_whitelist': [],
'gitfs_env_blacklist': [],
'gitfs_saltenv_whitelist': [],
'gitfs_saltenv_blacklist': [],
'gitfs_user': '',
Expand Down Expand Up @@ -534,8 +575,6 @@ def setup_loader_modules(self):
'transport': 'zeromq',
'gitfs_mountpoint': '',
'gitfs_saltenv': [],
'gitfs_env_whitelist': [],
'gitfs_env_blacklist': [],
'gitfs_saltenv_whitelist': [],
'gitfs_saltenv_blacklist': [],
'gitfs_user': '',
Expand Down