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

make file envs compatible with fileclient formats #49389

Merged
merged 5 commits into from Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions salt/fileserver/__init__.py
Expand Up @@ -490,6 +490,14 @@ def envs(self, back=None, sources=False):
return ret
return list(ret)

def file_envs(self, load=None):
'''
Return environments for all backends for requests from fileclient
'''
if load is None:
load = {}
return self.envs(**load)

def init(self, back=None):
'''
Initialize the backend, only do so if the fs supports an init function
Expand Down
2 changes: 1 addition & 1 deletion salt/master.py
Expand Up @@ -963,7 +963,7 @@ def __setup_fileserver(self):
self._file_list_emptydirs = self.fs_.file_list_emptydirs
self._dir_list = self.fs_.dir_list
self._symlink_list = self.fs_.symlink_list
self._file_envs = self.fs_.envs
self._file_envs = self.fs_.file_envs

def __verify_minion(self, id_, token):
'''
Expand Down
13 changes: 13 additions & 0 deletions salt/modules/cp.py
Expand Up @@ -296,6 +296,19 @@ def get_file(path,
gzip)


def envs():
'''
List available environments for fileserver

CLI Example

.. code-block:: bash

salt '*' cp.envs
'''
return _client().envs()


def get_template(path,
dest,
template='jinja',
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/modules/test_cp.py
Expand Up @@ -614,3 +614,6 @@ def test_push(self):
self.assertTrue(os.path.isfile(tgt_cache_file), 'File was not cached on the master')
finally:
os.unlink(tgt_cache_file)

def test_envs(self):
self.assertEqual(self.run_function('cp.envs'), ['base', 'prod'])