Add a fallback branch when no matching branch is found. Example:
```yaml
gitfs_remotes:
- http://foo.com/states/top.git:
- all_saltenvs: master
- http://foo.com/states/apache.git:
- fallback: master
- http://foo.com/states/nginx.git:
- fallback: master
- http://foo.com/states/webapp.git:
- fallback: develop
```
Where a state in `webapp` includes a state of `apache`.
With this change, one can test a feature branch of `webapp` without
needing to create the same branch in `apache`. Similarly, one can test a
feature branch of `apache` without needing to create the same branch in
`webapp`.
This is a forward port of pull request #51971 from Mathieu Parent.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This fixes the following when running `python tests/runtests.py --ext-pillar`:
-------- Tests with Errors ------------------------------------------------------------------------------------------------------------------------
-> tearDownClass (integration.pillar.test_git_pillar.TestGitPythonSSH) ...........................................................................
Traceback (most recent call last):
File ".../salt/tests/support/gitfs.py", line 481, in tearDownClass
if cls.case.sshd_proc is not None:
AttributeError: 'NoneType' object has no attribute 'sshd_proc'
...................................................................................................................................................
-> tearDownClass (integration.pillar.test_git_pillar.TestPygit2SSH) ..............................................................................
Traceback (most recent call last):
File ".../salt/tests/support/gitfs.py", line 481, in tearDownClass
if cls.case.sshd_proc is not None:
AttributeError: 'NoneType' object has no attribute 'sshd_proc'
...................................................................................................................................................
-----------------------------------------------------------------------------------------------------------------------------------------------------
Signed-off-by: Mathieu Parent <math.parent@gmail.com>
(cherry picked from commit 84e9fce9bb)
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.
To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.
Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
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.