mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge 3006.x into 3007.x
This commit is contained in:
commit
ed2548d52a
9 changed files with 88 additions and 11 deletions
6
.github/workflows/build-docs.yml
vendored
6
.github/workflows/build-docs.yml
vendored
|
@ -76,10 +76,10 @@ jobs:
|
|||
|
||||
- name: Prepare Docs Build
|
||||
run: |
|
||||
git clone https://gitlab.com/saltstack/open/docs/builddocs.git .builddocs
|
||||
git clone https://gitlab.com/saltstack/open/docs/builddocs-fonts.git .builddocs-fonts
|
||||
sudo mkdir -p /usr/share/fonts/truetype /usr/share/fonts/opentype
|
||||
sudo cp -rfv .builddocs/builddocs/files/fonts/truetype/*.ttf /usr/share/fonts/truetype/
|
||||
sudo cp -rfv .builddocs/builddocs/files/fonts/opentype/*.otf /usr/share/fonts/opentype/
|
||||
sudo cp -rfv .builddocs-fonts/truetype/*.ttf /usr/share/fonts/truetype/
|
||||
sudo cp -rfv .builddocs-fonts/opentype/*.otf /usr/share/fonts/opentype/
|
||||
sudo fc-cache -f -v
|
||||
|
||||
- name: Build Documentation (${{ matrix.docs-output }})
|
||||
|
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -96,6 +96,7 @@ jobs:
|
|||
docs:
|
||||
- added|modified:
|
||||
- doc/**
|
||||
- .github/workflows/build-docs.yml
|
||||
- *doc_requirements
|
||||
workflows:
|
||||
- added|modified:
|
||||
|
|
1
.github/workflows/nightly.yml
vendored
1
.github/workflows/nightly.yml
vendored
|
@ -148,6 +148,7 @@ jobs:
|
|||
docs:
|
||||
- added|modified:
|
||||
- doc/**
|
||||
- .github/workflows/build-docs.yml
|
||||
- *doc_requirements
|
||||
workflows:
|
||||
- added|modified:
|
||||
|
|
1
.github/workflows/scheduled.yml
vendored
1
.github/workflows/scheduled.yml
vendored
|
@ -138,6 +138,7 @@ jobs:
|
|||
docs:
|
||||
- added|modified:
|
||||
- doc/**
|
||||
- .github/workflows/build-docs.yml
|
||||
- *doc_requirements
|
||||
workflows:
|
||||
- added|modified:
|
||||
|
|
1
.github/workflows/staging.yml
vendored
1
.github/workflows/staging.yml
vendored
|
@ -126,6 +126,7 @@ jobs:
|
|||
docs:
|
||||
- added|modified:
|
||||
- doc/**
|
||||
- .github/workflows/build-docs.yml
|
||||
- *doc_requirements
|
||||
workflows:
|
||||
- added|modified:
|
||||
|
|
1
.github/workflows/templates/layout.yml.jinja
vendored
1
.github/workflows/templates/layout.yml.jinja
vendored
|
@ -144,6 +144,7 @@ jobs:
|
|||
docs:
|
||||
- added|modified:
|
||||
- doc/**
|
||||
- .github/workflows/build-docs.yml
|
||||
- *doc_requirements
|
||||
workflows:
|
||||
- added|modified:
|
||||
|
|
1
changelog/65938.changed.md
Normal file
1
changelog/65938.changed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Change module search path priority, so Salt extensions can be overridden by syncable modules and module_dirs. You can switch back to the old logic by setting features.enable_deprecated_module_search_path_priority to true, but it will be removed in Salt 3008.
|
|
@ -130,17 +130,18 @@ def _module_dirs(
|
|||
):
|
||||
if tag is None:
|
||||
tag = ext_type
|
||||
sys_types = os.path.join(base_path or str(SALT_BASE_PATH), int_type or ext_type)
|
||||
return_types = [sys_types]
|
||||
if opts.get("extension_modules"):
|
||||
ext_types = os.path.join(opts["extension_modules"], ext_type)
|
||||
return_types.insert(0, ext_types)
|
||||
sys_types = [os.path.join(base_path or str(SALT_BASE_PATH), int_type or ext_type)]
|
||||
|
||||
if not sys_types.startswith(SALT_INTERNAL_LOADERS_PATHS):
|
||||
if opts.get("extension_modules"):
|
||||
ext_types = [os.path.join(opts["extension_modules"], ext_type)]
|
||||
else:
|
||||
ext_types = []
|
||||
|
||||
if not sys_types[0].startswith(SALT_INTERNAL_LOADERS_PATHS):
|
||||
raise RuntimeError(
|
||||
"{!r} is not considered a salt internal loader path. If this "
|
||||
"is a new loader being added, please also add it to "
|
||||
"{}.SALT_INTERNAL_LOADERS_PATHS.".format(sys_types, __name__)
|
||||
"{}.SALT_INTERNAL_LOADERS_PATHS.".format(sys_types[0], __name__)
|
||||
)
|
||||
|
||||
ext_type_types = []
|
||||
|
@ -250,7 +251,17 @@ def _module_dirs(
|
|||
if os.path.isdir(maybe_dir):
|
||||
cli_module_dirs.insert(0, maybe_dir)
|
||||
|
||||
return cli_module_dirs + ext_type_types + return_types
|
||||
if opts.get("features", {}).get(
|
||||
"enable_deprecated_module_search_path_priority", False
|
||||
):
|
||||
salt.utils.versions.warn_until(
|
||||
3008,
|
||||
"The old module search path priority will be removed in Salt 3008. "
|
||||
"For more information see https://github.com/saltstack/salt/pull/65938.",
|
||||
)
|
||||
return cli_module_dirs + ext_type_types + ext_types + sys_types
|
||||
else:
|
||||
return cli_module_dirs + ext_types + ext_type_types + sys_types
|
||||
|
||||
|
||||
def minion_mods(
|
||||
|
|
|
@ -26,6 +26,66 @@ def venv(tmp_path):
|
|||
yield _venv
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def module_dirs(tmp_path):
|
||||
module_dir = tmp_path / "module-dir-base"
|
||||
module_dir.joinpath("modules").mkdir(parents=True)
|
||||
return [str(module_dir)]
|
||||
|
||||
|
||||
def test_module_dirs_priority(venv, salt_extension, minion_opts, module_dirs):
|
||||
# Install our extension into the virtualenv
|
||||
venv.install(str(salt_extension.srcdir))
|
||||
installed_packages = venv.get_installed_packages()
|
||||
assert salt_extension.name in installed_packages
|
||||
code = """
|
||||
import sys
|
||||
import json
|
||||
import salt._logging
|
||||
import salt.loader
|
||||
|
||||
minion_config = json.loads(sys.stdin.read())
|
||||
salt._logging.set_logging_options_dict(minion_config)
|
||||
salt._logging.setup_logging()
|
||||
mod_dirs = salt.loader._module_dirs(minion_config, "modules", "module")
|
||||
print(json.dumps(mod_dirs))
|
||||
"""
|
||||
minion_opts["module_dirs"] = module_dirs
|
||||
ret = venv.run_code(code, input=json.dumps(minion_opts))
|
||||
module_dirs_return = json.loads(ret.stdout)
|
||||
assert len(module_dirs_return) == 5
|
||||
for i, tail in enumerate(
|
||||
[
|
||||
"/module-dir-base/modules",
|
||||
"/var/cache/salt/minion/extmods/modules",
|
||||
"/module-dir-base",
|
||||
"/site-packages/salt_ext_loader_test/modules",
|
||||
"/site-packages/salt/modules",
|
||||
]
|
||||
):
|
||||
assert module_dirs_return[i].endswith(
|
||||
tail
|
||||
), f"{module_dirs_return[i]} does not end with {tail}"
|
||||
|
||||
# Test the deprecated mode as well
|
||||
minion_opts["features"] = {"enable_deprecated_module_search_path_priority": True}
|
||||
ret = venv.run_code(code, input=json.dumps(minion_opts))
|
||||
module_dirs_return = json.loads(ret.stdout)
|
||||
assert len(module_dirs_return) == 5
|
||||
for i, tail in enumerate(
|
||||
[
|
||||
"/module-dir-base/modules",
|
||||
"/module-dir-base",
|
||||
"/site-packages/salt_ext_loader_test/modules",
|
||||
"/var/cache/salt/minion/extmods/modules",
|
||||
"/site-packages/salt/modules",
|
||||
]
|
||||
):
|
||||
assert module_dirs_return[i].endswith(
|
||||
tail
|
||||
), f"{module_dirs_return[i]} does not end with {tail}"
|
||||
|
||||
|
||||
def test_new_entry_points_passing_module(venv, salt_extension, salt_minion_factory):
|
||||
# Install our extension into the virtualenv
|
||||
venv.install(str(salt_extension.srcdir))
|
||||
|
|
Loading…
Add table
Reference in a new issue