-
Notifications
You must be signed in to change notification settings - Fork 246
Feature/vcluster #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature/vcluster #421
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,6 +320,18 @@ def run_strategy( | |
help="A list of sinks to send the scan to", | ||
rich_help_panel="Publish Scan Settings", | ||
), | ||
vcluster_namespace: str = typer.Option( | ||
None, | ||
"--vcluster-namespace", | ||
help="The vcluster namespace on physical cluster", | ||
rich_help_panel="VCluster Settings", | ||
), | ||
vcluster_name: str = typer.Option( | ||
None, | ||
"--vcluster-name", | ||
help="The vcluster name on physical cluster", | ||
rich_help_panel="VCluster Settings", | ||
), | ||
Comment on lines
+323
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make vcluster CLI options Optional[str] and clarify help about paired usage Both options default to None but are annotated as str. Align to Optional[str] and clarify help that both must be provided together when using VCluster to avoid misconfiguration. Apply this diff: - vcluster_namespace: str = typer.Option(
+ vcluster_namespace: Optional[str] = typer.Option(
None,
"--vcluster-namespace",
- help="The vcluster namespace on physical cluster",
+ help="The vcluster namespace on the physical cluster (required when using --vcluster-name).",
rich_help_panel="VCluster Settings",
),
- vcluster_name: str = typer.Option(
+ vcluster_name: Optional[str] = typer.Option(
None,
"--vcluster-name",
- help="The vcluster name on physical cluster",
+ help="The vcluster name on the physical cluster (required when using --vcluster-namespace).",
rich_help_panel="VCluster Settings",
), As a follow-up, add a paired-args validation right before constructing Config to prevent partial configuration: # Enforce that either both vcluster_* are provided or neither
if bool(vcluster_name) ^ bool(vcluster_namespace):
raise click.BadOptionUsage(
"--vcluster-name/--vcluster-namespace",
"Both --vcluster-name and --vcluster-namespace must be provided together when using VCluster."
) 🤖 Prompt for AI Agents
|
||
**strategy_args, | ||
) -> None: | ||
f"""Run KRR using the `{_strategy_name}` strategy""" | ||
|
@@ -373,7 +385,9 @@ def run_strategy( | |
start_time=start_time, | ||
scan_id=scan_id, | ||
named_sinks=named_sinks, | ||
) | ||
vcluster_namespace=vcluster_namespace, | ||
vcluster_name=vcluster_name, | ||
) | ||
Config.set_config(config) | ||
except ValidationError as e: | ||
logger.exception("Error occured while parsing arguments") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Escape pod names for regex and anchor matches; minor logging nit
Unescaped pod names in a regex matcher can overmatch (e.g., dots in names). Anchor the regex to avoid partial matches and escape pod names. Also, avoid unnecessary f-string in logger.debug.
Apply this diff:
Notes:
Also applies to: 46-67, 77-95