Skip to content

Commit 5773efa

Browse files
BaptisteGidgarros
authored andcommitted
Remove default value "main" for branch parameter from all Infrahub CTL commands (#270)
* Remove default value main for branch parameter * Changelog * Remove branch parameter from repository commands as node is branch agnostic * Add None for username * Remove branch parameter from tests * Remove branch parameter from test * Add option to list repository by branch * Adjust parameter help
1 parent 41912d5 commit 5773efa

File tree

9 files changed

+12
-19
lines changed

9 files changed

+12
-19
lines changed

changelog/264.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove default value "main" for branch parameter from all Infrahub CTL commands.

infrahub_sdk/ctl/cli_commands.py

Lines changed: 1 addition & 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."), # TODO: Replace main by None
132+
branch: str = typer.Option(None, help="Branch on which to run the script."),
133133
concurrent: int | None = typer.Option(
134134
None,
135135
help="Maximum number of requests to execute at the same time.",

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"), # TODO: Replace main by None
25+
branch: str = typer.Option(None, help="Branch from which to export"),
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"), # TODO: Replace main by None
28+
branch: str = typer.Option(None, help="Branch from which to export"),
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."), # TODO: Replace main by None
30+
branch: str = typer.Option(None, help="Branch on which to load the menu."),
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."), # TODO: Replace main by None
30+
branch: str = typer.Option(None, help="Branch on which to load the objects."),
3131
_: str = CONFIG_PARAM,
3232
) -> None:
3333
"""Load one or multiple objects files into Infrahub."""

infrahub_sdk/ctl/repository.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ async def add(
7373
ref: str = "",
7474
read_only: bool = False,
7575
debug: bool = False,
76-
branch: str = typer.Option("main", help="Branch on which to add the repository."), # TODO: Replace main by None
7776
_: str = CONFIG_PARAM,
7877
) -> None:
7978
"""Add a new repository."""
@@ -110,18 +109,18 @@ async def add(
110109
query={"ok": None},
111110
)
112111

113-
await client.execute_graphql(query=query.render(), branch_name=branch, tracker="mutation-repository-create")
112+
await client.execute_graphql(query=query.render(), tracker="mutation-repository-create")
114113

115114

116115
@app.command()
117116
async def list(
118-
branch: str | None = None,
117+
branch: str = typer.Option(None, help="Branch on which to list repositories."),
119118
debug: bool = False,
120119
_: str = CONFIG_PARAM,
121120
) -> None:
122121
init_logging(debug=debug)
123122

124-
client = initialize_client(branch=branch)
123+
client = initialize_client()
125124

126125
repo_status_query = {
127126
"CoreGenericRepository": {

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."), # TODO: Replace main by None
111+
branch: str = typer.Option(None, help="Branch on which to load the schema."),
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."), # TODO: Replace main by None
162+
branch: str = typer.Option(None, help="Branch on which to check the schema."),
163163
_: str = CONFIG_PARAM,
164164
) -> None:
165165
"""Check if schema files are valid and what would be the impact of loading them with Infrahub."""

tests/unit/ctl/test_repository_app.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def test_repo_no_username_or_password(self, mock_init_client, mock_client) -> No
7474
}
7575
}
7676
""",
77-
branch_name="main",
7877
tracker="mutation-repository-create",
7978
)
8079

@@ -135,7 +134,6 @@ def test_repo_no_username(self, mock_init_client, mock_client) -> None:
135134
}
136135
}
137136
""",
138-
branch_name="main",
139137
tracker="mutation-repository-create",
140138
)
141139

@@ -198,7 +196,6 @@ def test_repo_username(self, mock_init_client, mock_client) -> None:
198196
}
199197
}
200198
""",
201-
branch_name="main",
202199
tracker="mutation-repository-create",
203200
)
204201

@@ -260,7 +257,6 @@ def test_repo_readonly_true(self, mock_init_client, mock_client) -> None:
260257
}
261258
}
262259
""",
263-
branch_name="main",
264260
tracker="mutation-repository-create",
265261
)
266262

@@ -288,8 +284,6 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) ->
288284
"This is a test description",
289285
"--ref",
290286
"my-custom-branch",
291-
"--branch",
292-
"develop",
293287
],
294288
)
295289
assert output.exit_code == 0
@@ -329,11 +323,10 @@ def test_repo_description_commit_branch(self, mock_init_client, mock_client) ->
329323
}
330324
}
331325
""",
332-
branch_name="develop",
333326
tracker="mutation-repository-create",
334327
)
335328

336329
def test_repo_list(self, mock_repositories_list) -> None:
337-
result = runner.invoke(app, ["repository", "list", "--branch", "main"])
330+
result = runner.invoke(app, ["repository", "list"])
338331
assert result.exit_code == 0
339332
assert strip_color(result.stdout) == read_fixture("output.txt", "integration/test_infrahubctl/repository_list")

0 commit comments

Comments
 (0)