File fix-calculation-of-sls-context-vars-when-trailing-do.patch of Package salt

From de4d6b9ff66004740ff306c16762522c2eb909ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
 <psuarezhernandez@suse.com>
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 +++--
 2 files changed, 4 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 d9204cf715..a3dc10b2e1 100644
--- a/salt/utils/templates.py
+++ b/salt/utils/templates.py
@@ -105,8 +105,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
-- 
2.47.0

openSUSE Build Service is sponsored by