Remove enable_slsvars_fixes feature flag and enable behavior by default

This commit is contained in:
Megan Wilhite 2022-02-24 11:23:31 -07:00
parent 14ad6958ea
commit b16ad8ea87
4 changed files with 8 additions and 70 deletions

5
changelog/61697.removed Normal file
View file

@ -0,0 +1,5 @@
Remove the feature flag feature.enable_slsvars_fixes and enable the fixes for `sls_path`, `tpl_file`, and `tpldir` by default.
Enabling this behavior by default will fix the following:
- tpldir: If your directory name and your SLS file name are the same tpldir used to return a ., now it returns the correct directory name.
- slspath,slsdotpath,slscolonpath,sls_path: If an init.sls file is accessed by its explicit name path.to.init instead of path.to, init shows up as a directory for in various sls context parameters, now it will only show as a file.
- tplfile: When using tplfile in a SLS file in the root directory of file roots it returns empty. Now it returns the filename.

View file

@ -4,17 +4,9 @@ SLS Template Variable Reference
.. warning::
In the 3002 release ``sls_path``, ``tplfile``, and ``tpldir`` have had some significant
In the 3005 release ``sls_path``, ``tplfile``, and ``tpldir`` have had some significant
improvements which have the potential to break states that rely on old and
broken functionality. These fixes can be enabled by setting the
``enable_slsvars_fixes`` feature flag to ``True`` in your minion's config file.
This functionality will become the default in the 3005 release.
.. code-block:: yaml
features:
enable_slsvars_fixes: True
broken functionality.
The template engines available to sls files and file templates come loaded

View file

@ -24,7 +24,6 @@ import salt.utils.stringutils
import salt.utils.yamlencoding
from salt import __path__ as saltpath
from salt.exceptions import CommandExecutionError, SaltInvocationError, SaltRenderError
from salt.features import features
from salt.loader.context import NamedLoaderContext
from salt.utils.decorators.jinja import JinjaFilter, JinjaGlobal, JinjaTest
from salt.utils.odict import OrderedDict
@ -93,43 +92,7 @@ class AliasedModule:
return getattr(self.wrapped, name)
def _generate_sls_context_legacy(tmplpath, sls):
"""
Legacy version of generate_sls_context, this method should be remove in the
Phosphorus release.
"""
salt.utils.versions.warn_until(
"Phosphorus",
"There have been significant improvement to template variables. "
"To enable these improvements set features.enable_slsvars_fixes "
"to True in your config file. This feature will become the default "
"in the Phoshorus release.",
)
context = {}
slspath = sls.replace(".", "/")
if tmplpath is not None:
context["tplpath"] = tmplpath
if not tmplpath.lower().replace("\\", "/").endswith("/init.sls"):
slspath = os.path.dirname(slspath)
template = tmplpath.replace("\\", "/")
i = template.rfind(slspath.replace(".", "/"))
if i != -1:
template = template[i:]
tpldir = os.path.dirname(template).replace("\\", "/")
tpldata = {
"tplfile": template,
"tpldir": "." if tpldir == "" else tpldir,
"tpldot": tpldir.replace("/", "."),
}
context.update(tpldata)
context["slsdotpath"] = slspath.replace("/", ".")
context["slscolonpath"] = slspath.replace("/", ":")
context["sls_path"] = slspath.replace("/", "_")
context["slspath"] = slspath
return context
def _generate_sls_context(tmplpath, sls):
def generate_sls_context(tmplpath, sls):
"""
Generate SLS/Template Context Items
@ -190,27 +153,6 @@ def _generate_sls_context(tmplpath, sls):
return sls_context
def generate_sls_context(tmplpath, sls):
"""
Generate SLS/Template Context Items
Return values:
tplpath - full path to template on filesystem including filename
tplfile - relative path to template -- relative to file roots
tpldir - directory of the template relative to file roots. If none, "."
tpldot - tpldir using dots instead of slashes, if none, ""
slspath - directory containing current sls - (same as tpldir), if none, ""
sls_path - slspath with underscores separating parts, if none, ""
slsdotpath - slspath with dots separating parts, if none, ""
slscolonpath- slspath with colons separating parts, if none, ""
"""
if not features.get("enable_slsvars_fixes", False):
return _generate_sls_context_legacy(tmplpath, sls)
return _generate_sls_context(tmplpath, sls)
def wrap_tmpl_func(render_str):
"""
Each template processing function below, ``render_*_tmpl``, is wrapped by

View file

@ -62,7 +62,6 @@ def minion_opts(
{
"file_client": "local",
"file_roots": {"base": [str(state_tree)], "prod": [str(state_tree_prod)]},
"features": {"enable_slsvars_fixes": True},
}
)
factory = salt_factories.salt_minion_daemon(