mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Deprecate and stop using salt.features
Fixes https://github.com/saltstack/salt/issues/65951
This commit is contained in:
parent
3e5c7213d1
commit
ecf154ca51
7 changed files with 39 additions and 45 deletions
1
changelog/65951.deprecated.md
Normal file
1
changelog/65951.deprecated.md
Normal file
|
@ -0,0 +1 @@
|
|||
Deprecate and stop using ``salt.features``
|
|
@ -14,6 +14,7 @@ from copy import deepcopy
|
|||
|
||||
import salt.defaults.exitcodes
|
||||
import salt.exceptions
|
||||
import salt.features
|
||||
import salt.syspaths
|
||||
import salt.utils.data
|
||||
import salt.utils.dictupdate
|
||||
|
@ -1302,6 +1303,7 @@ DEFAULT_MINION_OPTS = immutabletypes.freeze(
|
|||
"global_state_conditions": None,
|
||||
"reactor_niceness": None,
|
||||
"fips_mode": False,
|
||||
"features": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1647,6 +1649,7 @@ DEFAULT_MASTER_OPTS = immutabletypes.freeze(
|
|||
"netapi_enable_clients": [],
|
||||
"maintenance_interval": 3600,
|
||||
"fileserver_interval": 3600,
|
||||
"features": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1681,6 +1684,7 @@ DEFAULT_PROXY_MINION_OPTS = immutabletypes.freeze(
|
|||
"pki_dir": os.path.join(salt.syspaths.LIB_STATE_DIR, "pki", "proxy"),
|
||||
"cachedir": os.path.join(salt.syspaths.CACHE_DIR, "proxy"),
|
||||
"sock_dir": os.path.join(salt.syspaths.SOCK_DIR, "proxy"),
|
||||
"features": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1714,6 +1718,7 @@ DEFAULT_CLOUD_OPTS = immutabletypes.freeze(
|
|||
"log_rotate_backup_count": 0,
|
||||
"bootstrap_delay": 0,
|
||||
"cache": "localfs",
|
||||
"features": {},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -2324,6 +2329,7 @@ def minion_config(
|
|||
if role != "master":
|
||||
apply_sdb(opts)
|
||||
_validate_opts(opts)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -2335,6 +2341,7 @@ def mminion_config(path, overrides, ignore_config_errors=True):
|
|||
_validate_opts(opts)
|
||||
opts["grains"] = salt.loader.grains(opts)
|
||||
opts["pillar"] = {}
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -2421,6 +2428,7 @@ def proxy_config(
|
|||
|
||||
apply_sdb(opts)
|
||||
_validate_opts(opts)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -2498,6 +2506,7 @@ def syndic_config(
|
|||
if urllib.parse.urlparse(opts.get(config_key, "")).scheme == "":
|
||||
prepend_root_dirs.append(config_key)
|
||||
prepend_root_dir(opts, prepend_root_dirs)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -2750,6 +2759,7 @@ def cloud_config(
|
|||
prepend_root_dirs.append(opts["log_file"])
|
||||
prepend_root_dir(opts, prepend_root_dirs)
|
||||
|
||||
salt.features.setup_features(opts)
|
||||
# Return the final options
|
||||
return opts
|
||||
|
||||
|
@ -3923,6 +3933,7 @@ def master_config(
|
|||
if salt.utils.data.is_dictlist(opts["nodegroups"]):
|
||||
opts["nodegroups"] = salt.utils.data.repack_dictlist(opts["nodegroups"])
|
||||
apply_sdb(opts)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -4162,6 +4173,7 @@ def client_config(path, env_var="SALT_CLIENT_CONFIG", defaults=None):
|
|||
|
||||
# Return the client options
|
||||
_validate_opts(opts)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
@ -4185,6 +4197,7 @@ def api_config(path):
|
|||
)
|
||||
|
||||
prepend_root_dir(opts, ["api_pidfile", "api_logfile", "log_file", "pidfile"])
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,14 @@ class Features:
|
|||
log.warning("Features already setup")
|
||||
|
||||
def get(self, key, default=None):
|
||||
import salt.utils.versions
|
||||
|
||||
salt.utils.versions.warn_until(
|
||||
3008,
|
||||
"Please stop checking feature flags using 'salt.features' and instead "
|
||||
"check the 'features' keyword on the configuration dictionary. The "
|
||||
"'salt.features' module will go away in {version}.",
|
||||
)
|
||||
return self.features.get(key, default)
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import salt.syspaths
|
|||
import salt.utils.data
|
||||
import salt.utils.event
|
||||
import salt.utils.versions
|
||||
from salt.features import features
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -812,11 +811,11 @@ def runner(name, **kwargs):
|
|||
"executed" if success else "failed",
|
||||
)
|
||||
|
||||
if features.get("enable_deprecated_orchestration_flag", False):
|
||||
if __opts__["features"].get("enable_deprecated_orchestration_flag", False):
|
||||
ret["__orchestration__"] = True
|
||||
salt.utils.versions.warn_until(
|
||||
"Argon",
|
||||
"The __orchestration__ return flag will be removed in Salt Argon. "
|
||||
3008,
|
||||
"The __orchestration__ return flag will be removed in {version}. "
|
||||
"For more information see https://github.com/saltstack/salt/pull/59917.",
|
||||
)
|
||||
|
||||
|
@ -1061,7 +1060,7 @@ def wheel(name, **kwargs):
|
|||
"executed" if success else "failed",
|
||||
)
|
||||
|
||||
if features.get("enable_deprecated_orchestration_flag", False):
|
||||
if __opts__["features"].get("enable_deprecated_orchestration_flag", False):
|
||||
ret["__orchestration__"] = True
|
||||
salt.utils.versions.warn_until(
|
||||
"Argon",
|
||||
|
|
|
@ -191,7 +191,6 @@ import re
|
|||
|
||||
import salt.exceptions
|
||||
import salt.utils.versions
|
||||
from salt.features import features
|
||||
|
||||
try:
|
||||
from M2Crypto.RSA import RSAError
|
||||
|
@ -205,7 +204,7 @@ def __virtual__():
|
|||
"""
|
||||
only load this module if the corresponding execution module is loaded
|
||||
"""
|
||||
if features.get("x509_v2"):
|
||||
if __opts__["features"].get("x509_v2"):
|
||||
return (False, "Superseded, using x509_v2")
|
||||
if "x509.get_pem_entry" in __salt__:
|
||||
salt.utils.versions.warn_until(
|
||||
|
|
|
@ -188,7 +188,6 @@ import os.path
|
|||
|
||||
import salt.utils.files
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
from salt.features import features
|
||||
from salt.state import STATE_INTERNAL_KEYWORDS as _STATE_INTERNAL_KEYWORDS
|
||||
|
||||
try:
|
||||
|
@ -211,7 +210,7 @@ __virtualname__ = "x509"
|
|||
def __virtual__():
|
||||
if not HAS_CRYPTOGRAPHY:
|
||||
return (False, "Could not load cryptography")
|
||||
if not features.get("x509_v2"):
|
||||
if not __opts__["features"].get("x509_v2"):
|
||||
return (
|
||||
False,
|
||||
"x509_v2 needs to be explicitly enabled by setting `x509_v2: true` "
|
||||
|
|
|
@ -25,7 +25,6 @@ import salt._logging
|
|||
import salt.config as config
|
||||
import salt.defaults.exitcodes
|
||||
import salt.exceptions
|
||||
import salt.features
|
||||
import salt.syspaths as syspaths
|
||||
import salt.utils.args
|
||||
import salt.utils.data
|
||||
|
@ -1937,9 +1936,7 @@ class MasterOptionParser(
|
|||
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS["log_file"]
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.master_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return config.master_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class MinionOptionParser(
|
||||
|
@ -1954,13 +1951,11 @@ class MinionOptionParser(
|
|||
_default_logging_logfile_ = config.DEFAULT_MINION_OPTS["log_file"]
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.minion_config(
|
||||
return config.minion_config(
|
||||
self.get_config_file_path(), # pylint: disable=no-member
|
||||
cache_minion_id=True,
|
||||
ignore_config_errors=False,
|
||||
)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
class ProxyMinionOptionParser(
|
||||
|
@ -1991,11 +1986,9 @@ class ProxyMinionOptionParser(
|
|||
except AttributeError:
|
||||
minion_id = None
|
||||
|
||||
opts = config.proxy_config(
|
||||
return config.proxy_config(
|
||||
self.get_config_file_path(), cache_minion_id=False, minion_id=minion_id
|
||||
)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
class SyndicOptionParser(
|
||||
|
@ -2025,11 +2018,9 @@ class SyndicOptionParser(
|
|||
]
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.syndic_config(
|
||||
return config.syndic_config(
|
||||
self.get_config_file_path(), self.get_config_file_path("minion")
|
||||
)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
class SaltCMDOptionParser(
|
||||
|
@ -2368,9 +2359,7 @@ class SaltCMDOptionParser(
|
|||
self.exit(42, "\nIncomplete options passed.\n\n")
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.client_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return config.client_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class SaltCPOptionParser(
|
||||
|
@ -2441,9 +2430,7 @@ class SaltCPOptionParser(
|
|||
self.config["dest"] = self.args[-1]
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.master_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return config.master_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class SaltKeyOptionParser(
|
||||
|
@ -2735,7 +2722,6 @@ class SaltKeyOptionParser(
|
|||
# Since we're generating the keys, some defaults can be assumed
|
||||
# or tweaked
|
||||
keys_config["pki_dir"] = self.options.gen_keys_dir
|
||||
salt.features.setup_features(keys_config)
|
||||
return keys_config
|
||||
|
||||
def process_rotate_aes_key(self):
|
||||
|
@ -2984,7 +2970,6 @@ class SaltCallOptionParser(
|
|||
opts = config.minion_config(
|
||||
self.get_config_file_path(), cache_minion_id=True
|
||||
)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
def process_module_dirs(self):
|
||||
|
@ -3086,9 +3071,7 @@ class SaltRunOptionParser(
|
|||
self.config["arg"] = []
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.client_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return config.client_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class SaltSSHOptionParser(
|
||||
|
@ -3428,9 +3411,7 @@ class SaltSSHOptionParser(
|
|||
break
|
||||
|
||||
def setup_config(self):
|
||||
opts = config.master_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return config.master_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class SaltCloudParser(
|
||||
|
@ -3491,11 +3472,9 @@ class SaltCloudParser(
|
|||
|
||||
def setup_config(self):
|
||||
try:
|
||||
opts = config.cloud_config(self.get_config_file_path())
|
||||
return config.cloud_config(self.get_config_file_path())
|
||||
except salt.exceptions.SaltCloudConfigError as exc:
|
||||
self.error(exc)
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
||||
|
||||
class SPMParser(
|
||||
|
@ -3551,9 +3530,7 @@ class SPMParser(
|
|||
self.error("Insufficient arguments")
|
||||
|
||||
def setup_config(self):
|
||||
opts = salt.config.spm_config(self.get_config_file_path())
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
return salt.config.spm_config(self.get_config_file_path())
|
||||
|
||||
|
||||
class SaltAPIParser(
|
||||
|
@ -3579,8 +3556,6 @@ class SaltAPIParser(
|
|||
_default_logging_logfile_ = config.DEFAULT_API_OPTS[_logfile_config_setting_name_]
|
||||
|
||||
def setup_config(self):
|
||||
opts = salt.config.api_config(
|
||||
return salt.config.api_config(
|
||||
self.get_config_file_path()
|
||||
) # pylint: disable=no-member
|
||||
salt.features.setup_features(opts)
|
||||
return opts
|
||||
|
|
Loading…
Add table
Reference in a new issue