diff --git a/_lastrevision b/_lastrevision index 578f3b8..86a5427 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -3becea2e5b00beff724c22a8ae320d4567031c7b \ No newline at end of file +d9e734d2a130c3a4f5e14f8e2e00be98052a41f9 \ No newline at end of file diff --git a/fix-calculation-of-sls-context-vars-when-trailing-do.patch b/fix-calculation-of-sls-context-vars-when-trailing-do.patch new file mode 100644 index 0000000..690026a --- /dev/null +++ b/fix-calculation-of-sls-context-vars-when-trailing-do.patch @@ -0,0 +1,69 @@ +From 3403a7391df785be31b6fbe401a8229c2007ac19 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= + +Date: Mon, 2 Oct 2023 10:44:05 +0100 +Subject: [PATCH] Fix calculation of SLS context vars when trailing dots + on targetted sls/state (bsc#1213518) (#598) + +* Fix calculation of SLS context vars when trailing dots on targetted state + +* Add changelog file +--- + changelog/63411.fixed.md | 1 + + salt/utils/templates.py | 5 +++-- + tests/unit/utils/test_templates.py | 14 ++++++++++++++ + 3 files changed, 18 insertions(+), 2 deletions(-) + create mode 100644 changelog/63411.fixed.md + +diff --git a/changelog/63411.fixed.md b/changelog/63411.fixed.md +new file mode 100644 +index 0000000000..65340e3652 +--- /dev/null ++++ b/changelog/63411.fixed.md +@@ -0,0 +1 @@ ++Fix calculation of SLS context vars when trailing dots on targetted state +diff --git a/salt/utils/templates.py b/salt/utils/templates.py +index 4a8adf2a14..8639ea703e 100644 +--- a/salt/utils/templates.py ++++ b/salt/utils/templates.py +@@ -113,8 +113,9 @@ def generate_sls_context(tmplpath, sls): + + sls_context = {} + +- # Normalize SLS as path. +- slspath = sls.replace(".", "/") ++ # Normalize SLS as path and remove possible trailing slashes ++ # to prevent matching issues and wrong vars calculation ++ slspath = sls.replace(".", "/").rstrip("/") + + if tmplpath: + # Normalize template path +diff --git a/tests/unit/utils/test_templates.py b/tests/unit/utils/test_templates.py +index 4ba2f52d7b..264b4ae801 100644 +--- a/tests/unit/utils/test_templates.py ++++ b/tests/unit/utils/test_templates.py +@@ -320,6 +320,20 @@ class WrapRenderTestCase(TestCase): + slspath="foo", + ) + ++ def test_generate_sls_context__one_level_init_implicit_with_trailing_dot(self): ++ """generate_sls_context - Basic one level with implicit init.sls with trailing dot""" ++ self._test_generated_sls_context( ++ "/tmp/foo/init.sls", ++ "foo.", ++ tplfile="foo/init.sls", ++ tpldir="foo", ++ tpldot="foo", ++ slsdotpath="foo", ++ slscolonpath="foo", ++ sls_path="foo", ++ slspath="foo", ++ ) ++ + def test_generate_sls_context__one_level_init_explicit(self): + """generate_sls_context - Basic one level with explicit init.sls""" + self._test_generated_sls_context( +-- +2.42.0 + + diff --git a/salt.changes b/salt.changes index 1675027..c0cfea3 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Mon Oct 2 09:50:00 UTC 2023 - Pablo Suárez Hernández + +- Fix calculation of SLS context vars when trailing dots + on targetted sls/state (bsc#1213518) + +- Added: + * fix-calculation-of-sls-context-vars-when-trailing-do.patch + +------------------------------------------------------------------- +Fri Sep 29 08:47:48 UTC 2023 - Pablo Suárez Hernández + +- Rename salt-tests to python3-salt-testsuite + ------------------------------------------------------------------- Wed Sep 20 12:17:44 UTC 2023 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index c52d911..757d9fc 100644 --- a/salt.spec +++ b/salt.spec @@ -304,6 +304,8 @@ Patch78: fixed-gitfs-cachedir_basename-to-avoid-hash-collisio.patch Patch79: revert-usage-of-long-running-req-channel-bsc-1213960.patch # PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/65238 Patch80: write-salt-version-before-building-when-using-with-s.patch +# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/65036 +Patch81: fix-calculation-of-sls-context-vars-when-trailing-do.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END @@ -659,12 +661,28 @@ Requires(pre): %fillup_prereq Salt ssh is a master running without zmq. it enables the management of minions over a ssh connection. -%package tests +%package -n python3-salt-testsuite Summary: Unit and integration tests for Salt Requires: %{name} = %{version}-%{release} +Requires: python3-CherryPy +Requires: python3-Genshi +Requires: python3-Mako +Requires: python3-boto +Requires: python3-boto3 +Requires: python3-docker +Requires: python3-mock +Requires: python3-pygit2 +Requires: python3-pytest >= 7.0.1 +Requires: python3-pytest-httpserver +Requires: python3-pytest-salt-factories >= 1.0.0~rc21 +Requires: python3-pytest-subtests +Requires: python3-testinfra +Requires: python3-yamllint -%description tests -Collections of unit and integration tests for Salt +Obsoletes: %{name}-tests + +%description -n python3-salt-testsuite +Collection of unit, functional, and integration tests for %{name}. %if %{with bash_completion} %package bash-completion @@ -812,10 +830,12 @@ install -Dd -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d/ install -Dpm 0644 salt/cli/support/profiles/* %{buildroot}%{python3_sitelib}/salt/cli/support/profiles # Install Salt tests -install -Dd -m 0750 %{buildroot}%{_datadir}/salt -install -Dd -m 0750 %{buildroot}%{_datadir}/salt/tests -cp -a tests/* %{buildroot}%{_datadir}/salt/tests/ -sed -i '1s=^#!/usr/bin/\(python\|env python\)[0-9.]*=#!/usr/bin/python3=' %{buildroot}%{_datadir}/salt/tests/runtests.py +install -Dd %{buildroot}%{python3_sitelib}/salt-testsuite +cp -a tests %{buildroot}%{python3_sitelib}/salt-testsuite/ +# Remove runtests.py which is not used as deprecated method of running the tests +rm %{buildroot}%{python3_sitelib}/salt-testsuite/tests/runtests.py +# Copy conf files to the testsuite as they are used by the tests +cp -a conf %{buildroot}%{python3_sitelib}/salt-testsuite/ ## Install Zypper plugins only on SUSE machines %if 0%{?suse_version} @@ -1392,7 +1412,10 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version %files -n python3-salt %defattr(-,root,root,-) -%{python3_sitelib}/* +%dir %{python3_sitelib}/salt +%dir %{python3_sitelib}/salt-*.egg-info +%{python3_sitelib}/salt/* +%{python3_sitelib}/salt-*.egg-info/* %exclude %{python3_sitelib}/salt/cloud/deploy/*.sh %if %{with docs} @@ -1401,10 +1424,8 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version %doc doc/_build/html %endif -%files tests -%dir %{_datadir}/salt/ -%dir %{_datadir}/salt/tests/ -%{_datadir}/salt/tests/* +%files -n python3-salt-testsuite +%{python3_sitelib}/salt-testsuite %if %{with bash_completion} %files bash-completion