diff --git a/avrea_cli/commands/repo.py b/avrea_cli/commands/repo.py index 4dc144a5..9fc53266 100644 --- a/avrea_cli/commands/repo.py +++ b/avrea_cli/commands/repo.py @@ -708,7 +708,7 @@ def _put_git_mirror_placement( handle_http_error( exc, "place the git mirror", - hint="run `avr repo mirror clusters` to list valid cluster ids", + hint="run `avr repo mirror locations` to list valid cluster ids", hints={404: hint} if (hint := _gitlab_mirror_hint(source)) else None, ) except httpx.HTTPError: @@ -742,20 +742,20 @@ def _git_clusters_list(client: ApiClient, org_id: str) -> list[dict[str, Any]]: except httpx.HTTPError: raise click.ClickException("Could not reach Avrea to list mirror locations.") from None if not isinstance(response, dict): - raise click.ClickException("Unexpected response while listing git clusters.") + raise click.ClickException("Unexpected response while listing mirror locations.") page = response.get("data") if not isinstance(page, list) or not all(isinstance(item, dict) for item in page): - raise click.ClickException("Unexpected response while listing git clusters.") + raise click.ClickException("Unexpected response while listing mirror locations.") clusters.extend(page) pagination = response.get("pagination") if not isinstance(pagination, dict) or "next_cursor" not in pagination: - raise click.ClickException("Unexpected pagination response while listing git clusters.") + raise click.ClickException("Unexpected pagination response while listing mirror locations.") next_cursor = pagination["next_cursor"] if next_cursor is None: return clusters if not isinstance(next_cursor, str) or not next_cursor or next_cursor in seen_cursors: - raise click.ClickException("Unexpected pagination response while listing git clusters.") + raise click.ClickException("Unexpected pagination response while listing mirror locations.") seen_cursors.add(next_cursor) cursor = next_cursor @@ -1027,7 +1027,7 @@ def mirror_disable(ctx, repo_id, org_id, yes, source, json_fields, jq_expr): def mirror_place(ctx, cluster_id, repo_id, org_id, source, json_fields, jq_expr): """Place the repository's mirror in a git cluster. - CLUSTER_ID is one of the ids from `avr repo mirror clusters`. Placing is + CLUSTER_ID is one of the ids from `avr repo mirror locations`. Placing is idempotent; a new placement syncs from the upstream platform copy. Mirroring must be enabled first. Requires the organization admin role. @@ -1122,19 +1122,19 @@ def mirror_unplace(ctx, cluster_id, repo_id, org_id, yes, source, json_fields, j _print_git_mirror(mirror) -@mirror.command("clusters") -@click.option( - "--org", "org_id", help="Organization ID or slug. Uses default org if not specified (see: avr config set org)." -) +@mirror.command("locations") +@click.option("--org", "org_id", help="Organization ID or slug. Uses the default organization.") @json_options @click.pass_context -def mirror_clusters(ctx, org_id, json_fields, jq_expr): - """List the git clusters a mirror can be placed in. +def mirror_locations(ctx, org_id, json_fields, jq_expr): + """List available mirror locations and their cluster IDs. + + Use a cluster ID, datacenter ID, or unique name with `mirror create --location`. \b Examples: - avr repo mirror clusters - avr repo mirror clusters --json cluster_id,datacenter_id + avr repo mirror locations + avr repo mirror locations --json cluster_id,name \b JSON FIELDS @@ -1155,7 +1155,7 @@ def mirror_clusters(ctx, org_id, json_fields, jq_expr): return if not clusters: - click.echo("No git clusters available.") + click.echo("No mirror locations available.") return output_list( @@ -1163,24 +1163,3 @@ def mirror_clusters(ctx, org_id, json_fields, jq_expr): columns=["cluster_id", "datacenter_id", "name"], column_labels=["Cluster", "Datacenter", "Name"], ) - - -@mirror.command("locations") -@click.option("--org", "org_id", help="Organization ID or slug. Uses the default organization.") -@json_options -@click.pass_context -def mirror_locations(ctx, org_id, json_fields, jq_expr): - """List available mirror locations and their cluster IDs. - - Use a cluster ID, datacenter ID, or unique name with `mirror create --location`. - - \b - Examples: - avr repo mirror locations - avr repo mirror locations --json cluster_id,name - - \b - JSON FIELDS - cluster_id, datacenter_id, name - """ - ctx.invoke(mirror_clusters, org_id=org_id, json_fields=json_fields, jq_expr=jq_expr) diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index a05b6e74..99cd9728 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -2400,31 +2400,6 @@ Manage this repository's avrea-git mirror (feature-flagged). avr repo mirror [OPTIONS] COMMAND [ARGS]... ``` -##### `avr repo mirror clusters` - -List the git clusters a mirror can be placed in. - -```sh -avr repo mirror clusters [OPTIONS] -``` - -```sh -Examples: - avr repo mirror clusters - avr repo mirror clusters --json cluster_id,datacenter_id -``` - -```sh -JSON FIELDS - cluster_id, datacenter_id, name -``` - -**Options** - -- `--org ` — Organization ID or slug. Uses default org if not specified (see: avr config set org). -- `--json ` — Output JSON. Pass comma-separated field names, "*" for all fields, or "?" to list available fields. -- `-q, --jq ` — Filter --json output through a jq expression. - ##### `avr repo mirror create` Enable mirroring and place a connected repository at a location. @@ -2564,7 +2539,7 @@ Place the repository's mirror in a git cluster. avr repo mirror place [OPTIONS] CLUSTER_ID ``` -CLUSTER_ID is one of the ids from `avr repo mirror clusters`. Placing is +CLUSTER_ID is one of the ids from `avr repo mirror locations`. Placing is idempotent; a new placement syncs from the upstream platform copy. Mirroring must be enabled first. Requires the organization admin role. diff --git a/docs/reference.json b/docs/reference.json index 02f8e01e..914982b3 100644 --- a/docs/reference.json +++ b/docs/reference.json @@ -10397,81 +10397,6 @@ "usage": "avr repo mirror [OPTIONS] COMMAND [ARGS]...", "params": [], "subcommands": [ - { - "name": "clusters", - "path": [ - "avr", - "repo", - "mirror", - "clusters" - ], - "full": "avr repo mirror clusters", - "is_group": false, - "short_help": "List the git clusters a mirror can be placed in.", - "help": "List the git clusters a mirror can be placed in.\n\n\b\nExamples:\n avr repo mirror clusters\n avr repo mirror clusters --json cluster_id,datacenter_id\n\n\b\nJSON FIELDS\n cluster_id, datacenter_id, name\n", - "epilog": null, - "deprecated": false, - "hidden": false, - "usage": "avr repo mirror clusters [OPTIONS]", - "params": [ - { - "name": "org_id", - "kind": "option", - "opts": [ - "--org" - ], - "secondary_opts": [], - "type": "text", - "required": false, - "multiple": false, - "nargs": 1, - "is_flag": false, - "envvar": null, - "help": "Organization ID or slug. Uses default org if not specified (see: avr config set org).", - "hidden": false, - "show_default": false, - "default": null - }, - { - "name": "json_fields", - "kind": "option", - "opts": [ - "--json" - ], - "secondary_opts": [], - "type": "text", - "required": false, - "multiple": false, - "nargs": 1, - "is_flag": false, - "envvar": null, - "help": "Output JSON. Pass comma-separated field names, \"*\" for all fields, or \"?\" to list available fields.", - "hidden": false, - "show_default": false, - "default": null - }, - { - "name": "jq_expr", - "kind": "option", - "opts": [ - "-q", - "--jq" - ], - "secondary_opts": [], - "type": "text", - "required": false, - "multiple": false, - "nargs": 1, - "is_flag": false, - "envvar": null, - "help": "Filter --json output through a jq expression.", - "hidden": false, - "show_default": false, - "default": null - } - ], - "subcommands": [] - }, { "name": "create", "path": [ @@ -10940,7 +10865,7 @@ "full": "avr repo mirror place", "is_group": false, "short_help": "Place the repository's mirror in a git cluster.", - "help": "Place the repository's mirror in a git cluster.\n\nCLUSTER_ID is one of the ids from `avr repo mirror clusters`. Placing is\nidempotent; a new placement syncs from the upstream platform copy.\nMirroring must be enabled first. Requires the organization admin role.\n\n\b\nExamples:\n avr repo mirror place gsc-fi\n avr repo mirror place gsc-fi --repo acme/widgets\n\n\b\nJSON FIELDS\n enabled, full_name, placements, repository_id\n", + "help": "Place the repository's mirror in a git cluster.\n\nCLUSTER_ID is one of the ids from `avr repo mirror locations`. Placing is\nidempotent; a new placement syncs from the upstream platform copy.\nMirroring must be enabled first. Requires the organization admin role.\n\n\b\nExamples:\n avr repo mirror place gsc-fi\n avr repo mirror place gsc-fi --repo acme/widgets\n\n\b\nJSON FIELDS\n enabled, full_name, placements, repository_id\n", "epilog": null, "deprecated": false, "hidden": false, diff --git a/docs/starlight/reference/repo.md b/docs/starlight/reference/repo.md index 482f670e..5bc77ff3 100644 --- a/docs/starlight/reference/repo.md +++ b/docs/starlight/reference/repo.md @@ -82,31 +82,6 @@ Manage this repository's avrea-git mirror (feature-flagged). avr repo mirror [OPTIONS] COMMAND [ARGS]... ``` -#### `avr repo mirror clusters` - -List the git clusters a mirror can be placed in. - -```sh -avr repo mirror clusters [OPTIONS] -``` - -```sh -Examples: - avr repo mirror clusters - avr repo mirror clusters --json cluster_id,datacenter_id -``` - -```sh -JSON FIELDS - cluster_id, datacenter_id, name -``` - -**Options** - -- --org <TEXT> — Organization ID or slug. Uses default org if not specified (see: avr config set org). -- --json <TEXT> — Output JSON. Pass comma-separated field names, "*" for all fields, or "?" to list available fields. -- -q, --jq <TEXT> — Filter --json output through a jq expression. - #### `avr repo mirror create` Enable mirroring and place a connected repository at a location. @@ -246,7 +221,7 @@ Place the repository's mirror in a git cluster. avr repo mirror place [OPTIONS] CLUSTER_ID ``` -CLUSTER_ID is one of the ids from `avr repo mirror clusters`. Placing is +CLUSTER_ID is one of the ids from `avr repo mirror locations`. Placing is idempotent; a new placement syncs from the upstream platform copy. Mirroring must be enabled first. Requires the organization admin role. diff --git a/man/man1/avr-repo-mirror-clusters.1 b/man/man1/avr-repo-mirror-clusters.1 deleted file mode 100644 index 3f7ada81..00000000 --- a/man/man1/avr-repo-mirror-clusters.1 +++ /dev/null @@ -1,43 +0,0 @@ -.TH AVR\-REPO\-MIRROR\-CLUSTERS 1 "" "avr 0.5.0" "Avrea CLI" -.SH NAME -avr-repo-mirror-clusters \- List the git clusters a mirror can be placed in. -.SH SYNOPSIS -.B avr repo mirror clusters -[OPTIONS] -.SH DESCRIPTION -List the git clusters a mirror can be placed in. -.PP -.RS 4 -.nf -Examples: - avr repo mirror clusters - avr repo mirror clusters --json cluster_id,datacenter_id -.fi -.RE -.PP -.RS 4 -.nf -JSON FIELDS - cluster_id, datacenter_id, name -.fi -.RE -.SH OPTIONS -.TP -\fB\-\-org\fR \fITEXT\fR -Organization ID or slug. Uses default org if not specified (see: avr config set org). -.TP -\fB\-\-json\fR \fITEXT\fR -Output JSON. Pass comma-separated field names, "*" for all fields, or "?" to list available fields. -.TP -\fB\-q\fR, \fB\-\-jq\fR \fITEXT\fR -Filter --json output through a jq expression. -.SH SEE ALSO -.BR avr (1), -.BR avr-repo-mirror (1), -.BR avr-repo-mirror-create (1), -.BR avr-repo-mirror-disable (1), -.BR avr-repo-mirror-enable (1), -.BR avr-repo-mirror-locations (1), -.BR avr-repo-mirror-place (1), -.BR avr-repo-mirror-status (1), -.BR avr-repo-mirror-unplace (1) diff --git a/man/man1/avr-repo-mirror-create.1 b/man/man1/avr-repo-mirror-create.1 index 071e7d8d..0450b6b4 100644 --- a/man/man1/avr-repo-mirror-create.1 +++ b/man/man1/avr-repo-mirror-create.1 @@ -49,7 +49,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), .BR avr-repo-mirror-locations (1), diff --git a/man/man1/avr-repo-mirror-disable.1 b/man/man1/avr-repo-mirror-disable.1 index 6b54a260..15c8a4da 100644 --- a/man/man1/avr-repo-mirror-disable.1 +++ b/man/man1/avr-repo-mirror-disable.1 @@ -45,7 +45,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-enable (1), .BR avr-repo-mirror-locations (1), diff --git a/man/man1/avr-repo-mirror-enable.1 b/man/man1/avr-repo-mirror-enable.1 index 7f516eff..5f6b174e 100644 --- a/man/man1/avr-repo-mirror-enable.1 +++ b/man/man1/avr-repo-mirror-enable.1 @@ -42,7 +42,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-locations (1), diff --git a/man/man1/avr-repo-mirror-locations.1 b/man/man1/avr-repo-mirror-locations.1 index b2c4a394..3b162ee1 100644 --- a/man/man1/avr-repo-mirror-locations.1 +++ b/man/man1/avr-repo-mirror-locations.1 @@ -36,7 +36,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), diff --git a/man/man1/avr-repo-mirror-place.1 b/man/man1/avr-repo-mirror-place.1 index 4af62c4a..2c1cb7ae 100644 --- a/man/man1/avr-repo-mirror-place.1 +++ b/man/man1/avr-repo-mirror-place.1 @@ -7,7 +7,7 @@ avr-repo-mirror-place \- Place the repository's mirror in a git cluster. .SH DESCRIPTION Place the repository's mirror in a git cluster. .PP -CLUSTER_ID is one of the ids from `avr repo mirror clusters`. Placing is idempotent; a new placement syncs from the upstream platform copy. Mirroring must be enabled first. Requires the organization admin role. +CLUSTER_ID is one of the ids from `avr repo mirror locations`. Placing is idempotent; a new placement syncs from the upstream platform copy. Mirroring must be enabled first. Requires the organization admin role. .PP .RS 4 .nf @@ -46,7 +46,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), diff --git a/man/man1/avr-repo-mirror-status.1 b/man/man1/avr-repo-mirror-status.1 index 6ad0b0db..7ccf7fe1 100644 --- a/man/man1/avr-repo-mirror-status.1 +++ b/man/man1/avr-repo-mirror-status.1 @@ -41,7 +41,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), diff --git a/man/man1/avr-repo-mirror-unplace.1 b/man/man1/avr-repo-mirror-unplace.1 index 42a7d194..8ca555cf 100644 --- a/man/man1/avr-repo-mirror-unplace.1 +++ b/man/man1/avr-repo-mirror-unplace.1 @@ -49,7 +49,6 @@ Filter --json output through a jq expression. .SH SEE ALSO .BR avr (1), .BR avr-repo-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), diff --git a/man/man1/avr-repo-mirror.1 b/man/man1/avr-repo-mirror.1 index c3dc566c..17ea1c15 100644 --- a/man/man1/avr-repo-mirror.1 +++ b/man/man1/avr-repo-mirror.1 @@ -9,9 +9,6 @@ Manage this repository's avrea-git mirror (feature-flagged). .PP .SH COMMANDS .TP -clusters -List the git clusters a mirror can be placed in. -.TP create Enable mirroring and place a connected repository at a location. .TP @@ -38,7 +35,6 @@ Remove the repository's mirror from a git cluster. .BR avr-repo-clone (1), .BR avr-repo-list (1), .BR avr-repo-public-mirror (1), -.BR avr-repo-mirror-clusters (1), .BR avr-repo-mirror-create (1), .BR avr-repo-mirror-disable (1), .BR avr-repo-mirror-enable (1), diff --git a/tests/test_repo_mirror.py b/tests/test_repo_mirror.py index a8204390..70de7703 100644 --- a/tests/test_repo_mirror.py +++ b/tests/test_repo_mirror.py @@ -465,14 +465,25 @@ def test_unplace_tolerates_empty_body(runner, monkeypatch): assert "Removed the git-mirror placement in gsc-fi." in result.output -def test_clusters_lists_targets(runner, monkeypatch): +def test_clusters_command_is_removed(runner): + help_result = runner.invoke(cli, ["repo", "mirror", "--help"]) + assert help_result.exit_code == 0, help_result.output + assert "locations" in help_result.output + assert "clusters" not in help_result.output + + result = runner.invoke(cli, ["repo", "mirror", "clusters"]) + assert result.exit_code == 2, result.output + assert "No such command 'clusters'" in result.output + + +def test_locations_lists_targets(runner, monkeypatch): captured = {} monkeypatch.setattr( "avrea_cli.api_client.ApiClient.public_get", _capture(captured, "get", lambda: json.loads(json.dumps(SAMPLE_CLUSTERS))), ) - result = runner.invoke(cli, ["repo", "mirror", "clusters"]) + result = runner.invoke(cli, ["repo", "mirror", "locations"]) assert result.exit_code == 0, result.output assert captured["get"] == f"/orgs/{ORG_ID}/git-clusters" @@ -481,19 +492,19 @@ def test_clusters_lists_targets(runner, monkeypatch): assert "Roubaix" in result.output -def test_clusters_json(runner, monkeypatch): +def test_locations_json(runner, monkeypatch): monkeypatch.setattr( "avrea_cli.api_client.ApiClient.public_get", lambda self, path, params=None: json.loads(json.dumps(SAMPLE_CLUSTERS)), ) - result = runner.invoke(cli, ["repo", "mirror", "clusters", "--json", "cluster_id"]) + result = runner.invoke(cli, ["repo", "mirror", "locations", "--json", "cluster_id"]) assert result.exit_code == 0, result.output assert json.loads(result.output) == [{"cluster_id": "gsc-fi"}, {"cluster_id": "gsc-rbx"}] -def test_clusters_follows_pagination(runner, monkeypatch): +def test_locations_follows_pagination(runner, monkeypatch): calls = [] def mock_get(self, path, params=None): @@ -511,7 +522,7 @@ def mock_get(self, path, params=None): monkeypatch.setattr("avrea_cli.api_client.ApiClient.public_get", mock_get) - result = runner.invoke(cli, ["repo", "mirror", "clusters", "--json", "cluster_id"]) + result = runner.invoke(cli, ["repo", "mirror", "locations", "--json", "cluster_id"]) assert result.exit_code == 0, result.output assert json.loads(result.output) == [{"cluster_id": "gsc-fi"}, {"cluster_id": "gsc-rbx"}] @@ -527,7 +538,7 @@ def mock_get(self, path, params=None): ] -def test_clusters_rejects_malformed_response(runner, monkeypatch): +def test_locations_rejects_malformed_response(runner, monkeypatch): responses = ( [], {"data": "not-a-list", "pagination": {"next_cursor": None}}, @@ -542,12 +553,12 @@ def test_clusters_rejects_malformed_response(runner, monkeypatch): lambda self, path, params=None, response=response: response, ) - result = runner.invoke(cli, ["repo", "mirror", "clusters"]) + result = runner.invoke(cli, ["repo", "mirror", "locations"]) assert result.exit_code != 0 assert isinstance(result.exception, SystemExit) assert "Unexpected" in result.stderr - assert "git clusters" in result.stderr + assert "mirror locations" in result.stderr def test_json_meta_lists_fields(runner):