Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/264.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove default value "main" for branch parameter from all Infrahub CTL commands.
2 changes: 1 addition & 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."), # 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.",
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"), # 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.",
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"), # 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.",
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."), # 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."""
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."), # 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."""
Expand Down
8 changes: 3 additions & 5 deletions infrahub_sdk/ctl/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -111,18 +110,17 @@ 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,
debug: bool = False,
_: str = CONFIG_PARAM,
) -> None:
init_logging(debug=debug)

client = initialize_client(branch=branch)
client = initialize_client()

repo_status_query = {
"CoreGenericRepository": {
Expand All @@ -142,7 +140,7 @@ async def list(
}

query = Query(name="GetRepositoryStatus", query=repo_status_query)
resp = await client.execute_graphql(query=query.render(), branch_name=branch, tracker="query-repository-list")
resp = await client.execute_graphql(query=query.render(), tracker="query-repository-list")

table = Table(title="List of all Repositories")

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."), # 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:
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."), # 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."""
Expand Down
9 changes: 1 addition & 8 deletions tests/unit/ctl/test_repository_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down Expand Up @@ -135,7 +134,6 @@ def test_repo_no_username(self, mock_init_client, mock_client) -> None:
}
}
""",
branch_name="main",
tracker="mutation-repository-create",
)

Expand Down Expand Up @@ -198,7 +196,6 @@ def test_repo_username(self, mock_init_client, mock_client) -> None:
}
}
""",
branch_name="main",
tracker="mutation-repository-create",
)

Expand Down Expand Up @@ -260,7 +257,6 @@ def test_repo_readonly_true(self, mock_init_client, mock_client) -> None:
}
}
""",
branch_name="main",
tracker="mutation-repository-create",
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")