Open BaptisteGi opened 1 month ago
Looking at this I'd argue that it's also incorrect for infrahubctl schema load schema.yml
with regards to the branch being hardcoded to main. Something like this would be more correct. We can perhaps add it for the protocols for now and then review the other commands for the next release.
diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py
index fde4b16..3e4059b 100644
--- a/infrahub_sdk/ctl/cli_commands.py
+++ b/infrahub_sdk/ctl/cli_commands.py
@@ -366,9 +366,9 @@ def transform(
@app.command(name="protocols")
@catch_exception(console=console)
-def protocols( # noqa: PLR0915
+def protocols(
schemas: list[Path] = typer.Option(None, help="List of schemas or directory to load."),
- branch: str = typer.Option(None, help="Branch of schema to export Python protocols for."),
+ branch: Optional[str] = typer.Option(None, help="Branch of schema to export Python protocols for."),
sync: bool = typer.Option(False, help="Generate for sync or async."),
_: str = CONFIG_PARAM,
out: str = typer.Option("schema_protocols.py", help="Path to a file to save the result."),
@@ -388,6 +388,7 @@ def protocols( # noqa: PLR0915
else:
client = initialize_client_sync()
+ branch = branch or client.default_branch
Component
infrahubctl
Infrahub SDK version
0.14.1
Current Behavior
Expected Behavior
I would expect the command to get the default branch from my environment.
The same way I could do
infrahubctl schema load schema.yml
without having to specify the branchSteps to Reproduce
Doesn't work:
Works:
Additional Information
No response