Skip to content

Commit

Permalink
Retrun opts because they get modified often
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Sep 16, 2024
1 parent d4ee873 commit 0897afc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions salt/loader/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import collections.abc
import contextlib
import copy
import logging
import traceback

try:
# Try the stdlib C extension first
Expand All @@ -15,6 +17,8 @@

import salt.exceptions

log = logging.getLogger(__name__)

DEFAULT_CTX_VAR = "loader_ctxvar"

loader_ctxvar = contextvars.ContextVar(DEFAULT_CTX_VAR)
Expand Down Expand Up @@ -71,20 +75,12 @@ def value(self):
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:
Expand Down

0 comments on commit 0897afc

Please sign in to comment.