Skip to content

Commit c0634af

Browse files
BaptisteGidgarros
authored andcommitted
Protocols command consumes default branch from env (#263)
* Get default branch from env * Add comment on all hardcoded main branch to be fixed later * Add release note
1 parent 756ca5d commit c0634af

File tree

8 files changed

+10
-8
lines changed

8 files changed

+10
-8
lines changed

changelog/104.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `protocols` CTL command properly gets default branch setting from environment variable

infrahub_sdk/ctl/cli_commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async def run(
129129
method: str = "run",
130130
debug: bool = False,
131131
_: str = CONFIG_PARAM,
132-
branch: str = typer.Option("main", help="Branch on which to run the script."),
132+
branch: str = typer.Option("main", help="Branch on which to run the script."), # TODO: Replace main by None
133133
concurrent: int | None = typer.Option(
134134
None,
135135
help="Maximum number of requests to execute at the same time.",
@@ -383,6 +383,7 @@ def protocols(
383383

384384
else:
385385
client = initialize_client_sync()
386+
branch = branch or client.default_branch
386387
schema.update(client.schema.fetch(branch=branch))
387388

388389
code_generator = CodeGenerator(schema=schema)

infrahub_sdk/ctl/exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def dump(
2222
directory: Path = typer.Option(directory_name_with_timestamp, help="Directory path to store export"),
2323
quiet: bool = typer.Option(False, help="No console output"),
2424
_: str = CONFIG_PARAM,
25-
branch: str = typer.Option("main", help="Branch from which to export"),
25+
branch: str = typer.Option("main", help="Branch from which to export"), # TODO: Replace main by None
2626
concurrent: int = typer.Option(
2727
4,
2828
help="Maximum number of requests to execute at the same time.",

infrahub_sdk/ctl/importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def load(
2525
),
2626
quiet: bool = typer.Option(False, help="No console output"),
2727
_: str = CONFIG_PARAM,
28-
branch: str = typer.Option("main", help="Branch from which to export"),
28+
branch: str = typer.Option("main", help="Branch from which to export"), # TODO: Replace main by None
2929
concurrent: int | None = typer.Option(
3030
None,
3131
help="Maximum number of requests to execute at the same time.",

infrahub_sdk/ctl/menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def callback() -> None:
2727
async def load(
2828
menus: list[Path],
2929
debug: bool = False,
30-
branch: str = typer.Option("main", help="Branch on which to load the menu."),
30+
branch: str = typer.Option("main", help="Branch on which to load the menu."), # TODO: Replace main by None
3131
_: str = CONFIG_PARAM,
3232
) -> None:
3333
"""Load one or multiple menu files into Infrahub."""

infrahub_sdk/ctl/object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def callback() -> None:
2727
async def load(
2828
paths: list[Path],
2929
debug: bool = False,
30-
branch: str = typer.Option("main", help="Branch on which to load the objects."),
30+
branch: str = typer.Option("main", help="Branch on which to load the objects."), # TODO: Replace main by None
3131
_: str = CONFIG_PARAM,
3232
) -> None:
3333
"""Load one or multiple objects files into Infrahub."""

infrahub_sdk/ctl/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def add(
7474
commit: str = "",
7575
read_only: bool = False,
7676
debug: bool = False,
77-
branch: str = typer.Option("main", help="Branch on which to add the repository."),
77+
branch: str = typer.Option("main", help="Branch on which to add the repository."), # TODO: Replace main by None
7878
_: str = CONFIG_PARAM,
7979
) -> None:
8080
"""Add a new repository."""

infrahub_sdk/ctl/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> di
108108
async def load(
109109
schemas: list[Path],
110110
debug: bool = False,
111-
branch: str = typer.Option("main", help="Branch on which to load the schema."),
111+
branch: str = typer.Option("main", help="Branch on which to load the schema."), # TODO: Replace main by None
112112
wait: int = typer.Option(0, help="Time in seconds to wait until the schema has converged across all workers"),
113113
_: str = CONFIG_PARAM,
114114
) -> None:
@@ -159,7 +159,7 @@ async def load(
159159
async def check(
160160
schemas: list[Path],
161161
debug: bool = False,
162-
branch: str = typer.Option("main", help="Branch on which to check the schema."),
162+
branch: str = typer.Option("main", help="Branch on which to check the schema."), # TODO: Replace main by None
163163
_: str = CONFIG_PARAM,
164164
) -> None:
165165
"""Check if schema files are valid and what would be the impact of loading them with Infrahub."""

0 commit comments

Comments
 (0)