Skip to content

Commit

Permalink
Use --cachedir parameter for extension_modules with salt-call
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhestkov committed Jul 9, 2024
1 parent e24c5db commit d0418f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion salt/cli/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import salt.cli.caller
import salt.defaults.exitcodes
import salt.utils.parsers
from salt.config import _expand_glob_path
from salt.config import _expand_glob_path, prepend_root_dir


class SaltCall(salt.utils.parsers.SaltCallOptionParser):
Expand Down Expand Up @@ -37,6 +37,15 @@ def run(self):
if self.options.master:
self.config["master"] = self.options.master

if self.options.cachedir and self.config.get(
"extension_modules"
) == os.path.join(self.config.get("__cachedir"), "extmods"):
# Override `extension_modules`, but only in case if it was autogenerated
cache_dir = os.path.abspath(self.options.cachedir)
self.config["cachedir"] = cache_dir
self.config["extension_modules"] = os.path.join(cache_dir, "extmods")
prepend_root_dir(self.config, ["cachedir", "extension_modules"])

caller = salt.cli.caller.Caller.factory(self.config)

if self.options.doc:
Expand Down
6 changes: 6 additions & 0 deletions salt/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
All salt configuration loading and defaults should be in this module
"""

import codecs
import glob
import logging
Expand Down Expand Up @@ -3841,6 +3842,11 @@ def apply_minion_config(
_update_ssl_config(opts)
_update_discovery_config(opts)

# Store original `cachedir` value, before overriding,
# to make overriding more accurate.
if "__cachedir" not in opts:
opts["__cachedir"] = opts["cachedir"]

return opts


Expand Down

0 comments on commit d0418f6

Please sign in to comment.