Skip to content

Commit 428e036

Browse files
commands: extend the context protocol with a require_validation method
The require_validation property/method is used to determine if sambacc commands should enable validation of the config or just try to use whatever was provided. Signed-off-by: John Mulligan <[email protected]>
1 parent 8dce8c8 commit 428e036

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

sambacc/commands/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def cli(self) -> argparse.Namespace:
141141
def instance_config(self) -> config.InstanceConfig:
142142
... # pragma: no cover
143143

144+
@property
145+
def require_validation(self) -> typing.Optional[bool]:
146+
... # pragma: no cover
147+
144148

145149
def best_waiter(
146150
filename: typing.Optional[str] = None,

sambacc/commands/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ def _update_config_args(parser: argparse.ArgumentParser) -> None:
7272

7373
def _read_config(ctx: Context) -> config.InstanceConfig:
7474
cfgs = ctx.cli.config or []
75-
return config.read_config_files(cfgs).get(ctx.cli.identity)
75+
return config.read_config_files(
76+
cfgs, require_validation=ctx.require_validation
77+
).get(ctx.cli.identity)
7678

7779

7880
def _update_config(

tests/test_commands_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(self, opts, instance_config):
9494
self.instance_config = instance_config
9595
for k, v in opts.items():
9696
setattr(self.cli, k, v)
97+
self.require_validation = False
9798

9899
@classmethod
99100
def defaults(cls, cfg_path, watch=False):

0 commit comments

Comments
 (0)