Fix for __env__ in legacy git_pillar

When the __env__ branch is used, the branch needs to be checked out
late. Failing to do so, an old version of the pillar (or even an
empty version) will be used.
This commit is contained in:
Kees Bos 2015-10-24 15:17:10 +02:00
parent 87d86e4b3e
commit d46e09afc6

View file

@ -388,9 +388,9 @@ def _legacy_git_pillar(minion_id, repo_string, pillar_dirs):
log.warning('Unrecognized extra parameter: {0}'.format(key))
# environment is "different" from the branch
branch, _, environment = branch_env.partition(':')
cfg_branch, _, environment = branch_env.partition(':')
gitpil = _LegacyGitPillar(branch, repo_location, __opts__)
gitpil = _LegacyGitPillar(cfg_branch, repo_location, __opts__)
branch = gitpil.branch
if environment == '':
@ -404,7 +404,9 @@ def _legacy_git_pillar(minion_id, repo_string, pillar_dirs):
pillar_dirs.setdefault(pillar_dir, {})
if pillar_dirs[pillar_dir].get(branch, False):
if cfg_branch == '__env__' and branch not in ['master', 'base']:
gitpil.update()
elif pillar_dirs[pillar_dir].get(branch, False):
return {} # we've already seen this combo
pillar_dirs[pillar_dir].setdefault(branch, True)