From cc03854e4ca997b95664c3e00448c2583e8595ab Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 6 Feb 2025 17:31:40 +0100 Subject: [PATCH 1/3] Get default branch from env --- infrahub_sdk/ctl/cli_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py index 3cb23a55..e6599307 100644 --- a/infrahub_sdk/ctl/cli_commands.py +++ b/infrahub_sdk/ctl/cli_commands.py @@ -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) From d7fbb2192b88153b9b76b8921226d73a1b5a47c7 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 6 Feb 2025 17:32:31 +0100 Subject: [PATCH 2/3] Add comment on all hardcoded main branch to be fixed later --- infrahub_sdk/ctl/cli_commands.py | 2 +- infrahub_sdk/ctl/exporter.py | 2 +- infrahub_sdk/ctl/importer.py | 2 +- infrahub_sdk/ctl/menu.py | 2 +- infrahub_sdk/ctl/object.py | 2 +- infrahub_sdk/ctl/repository.py | 2 +- infrahub_sdk/ctl/schema.py | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py index e6599307..568e02c8 100644 --- a/infrahub_sdk/ctl/cli_commands.py +++ b/infrahub_sdk/ctl/cli_commands.py @@ -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.", diff --git a/infrahub_sdk/ctl/exporter.py b/infrahub_sdk/ctl/exporter.py index 50be3282..c1e81412 100644 --- a/infrahub_sdk/ctl/exporter.py +++ b/infrahub_sdk/ctl/exporter.py @@ -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.", diff --git a/infrahub_sdk/ctl/importer.py b/infrahub_sdk/ctl/importer.py index be087361..00d88db5 100644 --- a/infrahub_sdk/ctl/importer.py +++ b/infrahub_sdk/ctl/importer.py @@ -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.", diff --git a/infrahub_sdk/ctl/menu.py b/infrahub_sdk/ctl/menu.py index fe9798fa..533c0d0d 100644 --- a/infrahub_sdk/ctl/menu.py +++ b/infrahub_sdk/ctl/menu.py @@ -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.""" diff --git a/infrahub_sdk/ctl/object.py b/infrahub_sdk/ctl/object.py index 5f8e71cf..e619e229 100644 --- a/infrahub_sdk/ctl/object.py +++ b/infrahub_sdk/ctl/object.py @@ -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.""" diff --git a/infrahub_sdk/ctl/repository.py b/infrahub_sdk/ctl/repository.py index e57ee6bf..09003f6e 100644 --- a/infrahub_sdk/ctl/repository.py +++ b/infrahub_sdk/ctl/repository.py @@ -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.""" diff --git a/infrahub_sdk/ctl/schema.py b/infrahub_sdk/ctl/schema.py index 3c9557c5..c3a2e794 100644 --- a/infrahub_sdk/ctl/schema.py +++ b/infrahub_sdk/ctl/schema.py @@ -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: @@ -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.""" From 37e85689d52f068cb8e8192dcb20a17ced15c301 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 6 Feb 2025 17:40:53 +0100 Subject: [PATCH 3/3] Add release note --- changelog/104.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/104.fixed.md diff --git a/changelog/104.fixed.md b/changelog/104.fixed.md new file mode 100644 index 00000000..e6e64a72 --- /dev/null +++ b/changelog/104.fixed.md @@ -0,0 +1 @@ +- `protocols` CTL command properly gets default branch setting from environment variable \ No newline at end of file