Skip to content

Commit

Permalink
Protocols command consumes default branch from env (#263)
Browse files Browse the repository at this point in the history
* Get default branch from env

* Add comment on all hardcoded main branch to be fixed later

* Add release note
  • Loading branch information
BaptisteGi authored Feb 11, 2025
1 parent 0d491c0 commit aa65bb0
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog/104.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `protocols` CTL command properly gets default branch setting from environment variable
3 changes: 2 additions & 1 deletion infrahub_sdk/ctl/cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def run(
method: str = "run",
debug: bool = False,
_: str = CONFIG_PARAM,
branch: str = typer.Option("main", help="Branch on which to run the script."),
branch: str = typer.Option("main", help="Branch on which to run the script."), # TODO: Replace main by None
concurrent: int | None = typer.Option(
None,
help="Maximum number of requests to execute at the same time.",
Expand Down Expand Up @@ -383,6 +383,7 @@ def protocols(

else:
client = initialize_client_sync()
branch = branch or client.default_branch
schema.update(client.schema.fetch(branch=branch))

code_generator = CodeGenerator(schema=schema)
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def dump(
directory: Path = typer.Option(directory_name_with_timestamp, help="Directory path to store export"),
quiet: bool = typer.Option(False, help="No console output"),
_: str = CONFIG_PARAM,
branch: str = typer.Option("main", help="Branch from which to export"),
branch: str = typer.Option("main", help="Branch from which to export"), # TODO: Replace main by None
concurrent: int = typer.Option(
4,
help="Maximum number of requests to execute at the same time.",
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def load(
),
quiet: bool = typer.Option(False, help="No console output"),
_: str = CONFIG_PARAM,
branch: str = typer.Option("main", help="Branch from which to export"),
branch: str = typer.Option("main", help="Branch from which to export"), # TODO: Replace main by None
concurrent: int | None = typer.Option(
None,
help="Maximum number of requests to execute at the same time.",
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def callback() -> None:
async def load(
menus: list[Path],
debug: bool = False,
branch: str = typer.Option("main", help="Branch on which to load the menu."),
branch: str = typer.Option("main", help="Branch on which to load the menu."), # TODO: Replace main by None
_: str = CONFIG_PARAM,
) -> None:
"""Load one or multiple menu files into Infrahub."""
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def callback() -> None:
async def load(
paths: list[Path],
debug: bool = False,
branch: str = typer.Option("main", help="Branch on which to load the objects."),
branch: str = typer.Option("main", help="Branch on which to load the objects."), # TODO: Replace main by None
_: str = CONFIG_PARAM,
) -> None:
"""Load one or multiple objects files into Infrahub."""
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def add(
commit: str = "",
read_only: bool = False,
debug: bool = False,
branch: str = typer.Option("main", help="Branch on which to add the repository."),
branch: str = typer.Option("main", help="Branch on which to add the repository."), # TODO: Replace main by None
_: str = CONFIG_PARAM,
) -> None:
"""Add a new repository."""
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/ctl/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> di
async def load(
schemas: list[Path],
debug: bool = False,
branch: str = typer.Option("main", help="Branch on which to load the schema."),
branch: str = typer.Option("main", help="Branch on which to load the schema."), # TODO: Replace main by None
wait: int = typer.Option(0, help="Time in seconds to wait until the schema has converged across all workers"),
_: str = CONFIG_PARAM,
) -> None:
Expand Down Expand Up @@ -159,7 +159,7 @@ async def load(
async def check(
schemas: list[Path],
debug: bool = False,
branch: str = typer.Option("main", help="Branch on which to check the schema."),
branch: str = typer.Option("main", help="Branch on which to check the schema."), # TODO: Replace main by None
_: str = CONFIG_PARAM,
) -> None:
"""Check if schema files are valid and what would be the impact of loading them with Infrahub."""
Expand Down

0 comments on commit aa65bb0

Please sign in to comment.