Skip to content

Commit 7c09f66

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
sambacc: do not raise a KeyError if a config lacks globals
In the case of AD DC it's pretty normal for there to be no globals key in the instance configuration. If we want to optionally support global configuration params for addc it's convenient to simply return an empty list rather than raise an exception in this case. If the globals list refers to global configs that don't exist exceptions will continue to be raised which seem like the right thing to do. Signed-off-by: John Mulligan <[email protected]>
1 parent 23c8026 commit 7c09f66

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sambacc/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ def __init__(self, conf: GlobalConfig, iconfig: dict):
237237
def global_options(self) -> typing.Iterable[typing.Tuple[str, str]]:
238238
"""Iterate over global options."""
239239
# Pull in all global sections that apply
240-
gnames = self.iconfig["globals"]
240+
try:
241+
gnames = self.iconfig["globals"]
242+
except KeyError:
243+
# no globals section in the instance means no global options
244+
return
241245
for gname in gnames:
242246
global_section = self.gconfig.data["globals"][gname]
243247
for k, v in global_section.get("options", {}).items():

0 commit comments

Comments
 (0)