mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Retrun opts because they get modified often
This commit is contained in:
parent
d4ee87338b
commit
0897afcc21
1 changed files with 7 additions and 11 deletions
|
@ -5,6 +5,8 @@ Manage the context a module loaded by Salt's loader
|
|||
import collections.abc
|
||||
import contextlib
|
||||
import copy
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
try:
|
||||
# Try the stdlib C extension first
|
||||
|
@ -15,6 +17,8 @@ except ImportError:
|
|||
|
||||
import salt.exceptions
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_CTX_VAR = "loader_ctxvar"
|
||||
|
||||
loader_ctxvar = contextvars.ContextVar(DEFAULT_CTX_VAR)
|
||||
|
@ -71,20 +75,12 @@ class NamedLoaderContext(collections.abc.MutableMapping):
|
|||
loader = self.loader()
|
||||
if loader is None:
|
||||
return self.default
|
||||
if self.name == loader.pack_self:
|
||||
return loader
|
||||
elif self.name == "__context__":
|
||||
return loader.pack[self.name]
|
||||
elif self.name == "__opts__":
|
||||
# XXX: This behaviour tires to mimick what the loader does when
|
||||
# __opts__ was not imported from dunder. It would be nice to just
|
||||
# pass the value of __opts__ here. However, un-winding this
|
||||
# behavior will be tricky.
|
||||
opts = {}
|
||||
if self.default:
|
||||
opts.update(copy.deepcopy(self.default))
|
||||
opts.update(copy.deepcopy(loader.opts))
|
||||
return opts
|
||||
elif self.name == loader.pack_self:
|
||||
return loader
|
||||
return loader.pack[self.name]
|
||||
try:
|
||||
return loader.pack[self.name]
|
||||
except KeyError:
|
||||
|
|
Loading…
Add table
Reference in a new issue