mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Fix some regressions in recent legacy git_pillar deprecation
These didn't get caught in PR 42823 because of how we invoke the git_pillar code. Firstly, the "pillar" argument needed to stay. This is because even though we're not using it, _external_pillar_data() is still passing it now that git_pillar is not specially invoked there. Secondly, since the input comes in as a list, and _external_pillar_data uses single-asterisk expansion, the repos are passed separately when they should be passed as a single list. To fix these issues, I've done the following: 1. Re-introduced the "pillar" argument in git_pillar's ext_pillar function. 2. Changed the "pillar" variable to avoid confusion with the (unused) "pillar" argument being passed in. 3. Instead of git_pillar accepting the repos as a list, the ext_pillar function now uses single-asterisk expansion to make it conform with how _external_pillar_data() invokes it.
This commit is contained in:
parent
d8f371b8b1
commit
8b16300495
2 changed files with 10 additions and 9 deletions
|
@ -374,20 +374,20 @@ def __virtual__():
|
|||
return False
|
||||
|
||||
|
||||
def ext_pillar(minion_id, repo):
|
||||
def ext_pillar(minion_id, pillar, *repos): # pylint: disable=unused-argument
|
||||
'''
|
||||
Checkout the ext_pillar sources and compile the resulting pillar SLS
|
||||
'''
|
||||
opts = copy.deepcopy(__opts__)
|
||||
opts['pillar_roots'] = {}
|
||||
opts['__git_pillar'] = True
|
||||
pillar = salt.utils.gitfs.GitPillar(opts)
|
||||
pillar.init_remotes(repo, PER_REMOTE_OVERRIDES, PER_REMOTE_ONLY)
|
||||
git_pillar = salt.utils.gitfs.GitPillar(opts)
|
||||
git_pillar.init_remotes(repos, PER_REMOTE_OVERRIDES, PER_REMOTE_ONLY)
|
||||
if __opts__.get('__role') == 'minion':
|
||||
# If masterless, fetch the remotes. We'll need to remove this once
|
||||
# we make the minion daemon able to run standalone.
|
||||
pillar.fetch_remotes()
|
||||
pillar.checkout()
|
||||
git_pillar.fetch_remotes()
|
||||
git_pillar.checkout()
|
||||
ret = {}
|
||||
merge_strategy = __opts__.get(
|
||||
'pillar_source_merging_strategy',
|
||||
|
@ -397,7 +397,7 @@ def ext_pillar(minion_id, repo):
|
|||
'pillar_merge_lists',
|
||||
False
|
||||
)
|
||||
for pillar_dir, env in six.iteritems(pillar.pillar_dirs):
|
||||
for pillar_dir, env in six.iteritems(git_pillar.pillar_dirs):
|
||||
# If pillarenv is set, only grab pillars with that match pillarenv
|
||||
if opts['pillarenv'] and env != opts['pillarenv']:
|
||||
log.debug(
|
||||
|
@ -406,7 +406,7 @@ def ext_pillar(minion_id, repo):
|
|||
env, pillar_dir, opts['pillarenv']
|
||||
)
|
||||
continue
|
||||
if pillar_dir in pillar.pillar_linked_dirs:
|
||||
if pillar_dir in git_pillar.pillar_linked_dirs:
|
||||
log.debug(
|
||||
'git_pillar is skipping processing on %s as it is a '
|
||||
'mounted repo', pillar_dir
|
||||
|
@ -433,7 +433,7 @@ def ext_pillar(minion_id, repo):
|
|||
# list, so that its top file is sourced from the correct
|
||||
# location and not from another git_pillar remote.
|
||||
pillar_roots.extend(
|
||||
[d for (d, e) in six.iteritems(pillar.pillar_dirs)
|
||||
[d for (d, e) in six.iteritems(git_pillar.pillar_dirs)
|
||||
if env == e and d != pillar_dir]
|
||||
)
|
||||
|
||||
|
|
|
@ -341,7 +341,8 @@ class GitPillarTestBase(GitTestBase, LoaderModuleMockMixin):
|
|||
with patch.dict(git_pillar.__opts__, ext_pillar_opts):
|
||||
return git_pillar.ext_pillar(
|
||||
'minion',
|
||||
ext_pillar_opts['ext_pillar'][0]['git'],
|
||||
{},
|
||||
*ext_pillar_opts['ext_pillar'][0]['git']
|
||||
)
|
||||
|
||||
def make_repo(self, root_dir, user='root'):
|
||||
|
|
Loading…
Add table
Reference in a new issue