diff --git a/changelog/264.fixed.md b/changelog/264.fixed.md new file mode 100644 index 00000000..da596b06 --- /dev/null +++ b/changelog/264.fixed.md @@ -0,0 +1 @@ +Remove default value "main" for branch parameter from all Infrahub CTL commands. \ No newline at end of file diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py index 568e02c8..19980eb2 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."), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch on which to run the script."), 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 c1e81412..ae5e5d18 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"), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch from which to export"), 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 00d88db5..4645fa06 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"), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch from which to export"), 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 533c0d0d..560564ed 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."), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch on which to load the menu."), _: 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 e619e229..b589fcc2 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."), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch on which to load the objects."), _: 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 8f793946..d999eabc 100644 --- a/infrahub_sdk/ctl/repository.py +++ b/infrahub_sdk/ctl/repository.py @@ -74,7 +74,6 @@ async def add( ref: str = "", read_only: bool = False, debug: bool = False, - 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.""" @@ -111,18 +110,18 @@ async def add( query={"ok": None}, ) - await client.execute_graphql(query=query.render(), branch_name=branch, tracker="mutation-repository-create") + await client.execute_graphql(query=query.render(), tracker="mutation-repository-create") @app.command() async def list( - branch: str | None = None, + branch: str = typer.Option(None, help="Branch on which to list repositories."), debug: bool = False, _: str = CONFIG_PARAM, ) -> None: init_logging(debug=debug) - client = initialize_client(branch=branch) + client = initialize_client() repo_status_query = { "CoreGenericRepository": { diff --git a/infrahub_sdk/ctl/schema.py b/infrahub_sdk/ctl/schema.py index c3a2e794..6e9ff994 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."), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch on which to load the schema."), 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."), # TODO: Replace main by None + branch: str = typer.Option(None, help="Branch on which to check the schema."), _: str = CONFIG_PARAM, ) -> None: """Check if schema files are valid and what would be the impact of loading them with Infrahub.""" diff --git a/tests/unit/ctl/test_repository_app.py b/tests/unit/ctl/test_repository_app.py index 04d05ed4..7fb01ee1 100644 --- a/tests/unit/ctl/test_repository_app.py +++ b/tests/unit/ctl/test_repository_app.py @@ -74,7 +74,6 @@ def test_repo_no_username_or_password(self, mock_init_client, mock_client) -> No } } """, - branch_name="main", tracker="mutation-repository-create", ) @@ -135,7 +134,6 @@ def test_repo_no_username(self, mock_init_client, mock_client) -> None: } } """, - branch_name="main", tracker="mutation-repository-create", ) @@ -198,7 +196,6 @@ def test_repo_username(self, mock_init_client, mock_client) -> None: } } """, - branch_name="main", tracker="mutation-repository-create", ) @@ -260,7 +257,6 @@ def test_repo_readonly_true(self, mock_init_client, mock_client) -> None: } } """, - branch_name="main", tracker="mutation-repository-create", ) @@ -288,8 +284,6 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) -> "This is a test description", "--ref", "my-custom-branch", - "--branch", - "develop", ], ) assert output.exit_code == 0 @@ -329,11 +323,10 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) -> } } """, - branch_name="develop", tracker="mutation-repository-create", ) def test_repo_list(self, mock_repositories_list) -> None: - result = runner.invoke(app, ["repository", "list", "--branch", "main"]) + result = runner.invoke(app, ["repository", "list"]) assert result.exit_code == 0 assert strip_color(result.stdout) == read_fixture("output.txt", "integration/test_infrahubctl/repository_list")