示例#1
0
 def test_get_salt_root_dir(self, mock_config):
     self.assertEqual(['/srv/pillar/base',
                       '/srv/pillar/dev',
                       '/srv/pillar/prod',
                       '/srv/salt/base',
                       '/srv/salt/prod/srv/formulas/nginx-formula'],
                      get_salt_root_dirs())
示例#2
0
文件: git.py 项目: rmatulat/nacl
def get_all_possible_git_dirs():
    """
    There are two ways in getting git repo locations

    There are two ways to locate salt related git repos:
    1. Via the salt config when looking into file_root and pillar_root and
    2. via get_dir_list_from_filesystem

    We have to go both paths and then unify the results
    """
    salt_root_dir = get_salt_root_dirs()
    all_git_dirs_found = [x[:-5] for x in get_dir_list_from_filesystem()]
    possible_git_dirs = set(salt_root_dir + all_git_dirs_found)
    checked_git_dirs = [x for x in possible_git_dirs if is_git_repo(x)]
    return sorted(checked_git_dirs)
示例#3
0
def get_dir_list_from_filesystem(filter='*.git'):
    """
    Returns a list of salt directories

    Its default purpose is to return a list of pillar- and state
    git directories.
    Maybe we like to use this function later on to find directories with *.sls
    files in them.
    """

    matches = []
    starter = get_salt_root_dirs()

    for start in starter:
        for root, dirnames, filenames in os.walk(start):
            if fnmatch.fnmatch(root, filter):
                matches.append(root)

    return matches