Ignore path starting with _ on compose_node_name
https://github.com/salt-formulas/reclass/pull/48#issuecomment-406823623
diff --git a/README-extentions.rst b/README-extentions.rst
index 2053a2d..2bc4816 100644
--- a/README-extentions.rst
+++ b/README-extentions.rst
@@ -536,3 +536,5 @@
...
staging.mysql:
...
+
+If the subfolder path starts with the underscore character ``_``, then the subfolder path is NOT added to the node name.
diff --git a/reclass/storage/common.py b/reclass/storage/common.py
index 7de71d0..13db7ec 100644
--- a/reclass/storage/common.py
+++ b/reclass/storage/common.py
@@ -14,6 +14,17 @@
return relpath, name
@staticmethod
+ def composed_nodes(relpath, name):
+ if relpath == '.' or relpath == '':
+ # './' is converted to None
+ return None, name
+ parts = relpath.split(os.path.sep)
+ if parts[0].startswith("_"):
+ return relpath, name
+ parts.append(name)
+ return relpath, '.'.join(parts)
+
+ @staticmethod
def classes(relpath, name):
if relpath == '.' or relpath == '':
# './' is converted to None
diff --git a/reclass/storage/yaml_fs/__init__.py b/reclass/storage/yaml_fs/__init__.py
index 88f0ec4..7ed3fe4 100644
--- a/reclass/storage/yaml_fs/__init__.py
+++ b/reclass/storage/yaml_fs/__init__.py
@@ -61,7 +61,7 @@
if nodes_uri is not None:
self._nodes_uri = nodes_uri
if compose_node_name:
- self._nodes = self._enumerate_inventory(nodes_uri, NameMangler.classes)
+ self._nodes = self._enumerate_inventory(nodes_uri, NameMangler.composed_nodes)
else:
self._nodes = self._enumerate_inventory(nodes_uri, NameMangler.nodes)