mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix fileserver.update for VCS backends
This ensures that this runner function works irrespective of using gitfs/git, hgfs/hg, svnfs/svn.
This commit is contained in:
parent
fcb44c47d6
commit
a341eccc55
6 changed files with 44 additions and 6 deletions
|
@ -387,15 +387,11 @@ class Fileserver(object):
|
|||
for sub in back:
|
||||
if "{0}.envs".format(sub[1:]) in server_funcs:
|
||||
ret.remove(sub[1:])
|
||||
elif "{0}.envs".format(sub[1:-2]) in server_funcs:
|
||||
ret.remove(sub[1:-2])
|
||||
return ret
|
||||
|
||||
for sub in back:
|
||||
if "{0}.envs".format(sub) in server_funcs:
|
||||
ret.append(sub)
|
||||
elif "{0}.envs".format(sub[:-2]) in server_funcs:
|
||||
ret.append(sub[:-2])
|
||||
return ret
|
||||
|
||||
def master_opts(self, load):
|
||||
|
|
|
@ -81,6 +81,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = "gitfs"
|
||||
__virtual_aliases__ = ("git",)
|
||||
|
||||
|
||||
def _gitfs(init_remotes=True):
|
||||
|
|
|
@ -82,7 +82,8 @@ except ImportError:
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = "hg"
|
||||
__virtualname__ = "hgfs"
|
||||
__virtual_aliases__ = ("hg",)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
|
|
@ -78,7 +78,8 @@ except ImportError:
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = "svn"
|
||||
__virtualname__ = "svnfs"
|
||||
__virtual_aliases__ = ("svn",)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
|
|
@ -498,6 +498,23 @@ def fileserver(opts, backends):
|
|||
Returns the file server modules
|
||||
"""
|
||||
_utils = utils(opts)
|
||||
|
||||
if backends is not None:
|
||||
if not isinstance(backends, list):
|
||||
backends = [backends]
|
||||
# Make sure that the VCS backends work either with git or gitfs, hg or
|
||||
# hgfs, etc.
|
||||
vcs_re = re.compile("^(git|svn|hg)")
|
||||
fs_re = re.compile("fs$")
|
||||
vcs = []
|
||||
non_vcs = []
|
||||
for back in [fs_re.sub("", x) for x in backends]:
|
||||
if vcs_re.match(back):
|
||||
vcs.extend((back, back + "fs"))
|
||||
else:
|
||||
non_vcs.append(back)
|
||||
backends = vcs + non_vcs
|
||||
|
||||
return LazyLoader(
|
||||
_module_dirs(opts, "fileserver"),
|
||||
opts,
|
||||
|
|
|
@ -9,6 +9,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
from salt import fileserver
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
|
||||
|
@ -28,3 +29,24 @@ class MapDiffTestCase(TestCase):
|
|||
map1 = {"file1": 12345}
|
||||
map2 = {"file1": 1234}
|
||||
assert fileserver.diff_mtime_map(map1, map2) is True
|
||||
|
||||
|
||||
class VCSBackendWhitelistCase(TestCase, LoaderModuleMockMixin):
|
||||
def setup_loader_modules(self):
|
||||
return {fileserver: {}}
|
||||
|
||||
def test_whitelist(self):
|
||||
opts = {
|
||||
"fileserver_backend": ["roots", "git", "hgfs", "svn"],
|
||||
"extension_modules": "",
|
||||
}
|
||||
fs = fileserver.Fileserver(opts)
|
||||
assert fs.servers.whitelist == [
|
||||
"git",
|
||||
"gitfs",
|
||||
"hg",
|
||||
"hgfs",
|
||||
"svn",
|
||||
"svnfs",
|
||||
"roots",
|
||||
], fs.servers.whitelist
|
||||
|
|
Loading…
Add table
Reference in a new issue