Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
51 changes: 15 additions & 36 deletions avrea_cli/commands/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

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

Expand Down Expand Up @@ -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
Expand All @@ -1155,32 +1155,11 @@ 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(
clusters,
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)
27 changes: 1 addition & 26 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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.
Expand Down Expand Up @@ -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.

Expand Down
77 changes: 1 addition & 76 deletions docs/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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,
Expand Down
27 changes: 1 addition & 26 deletions docs/starlight/reference/repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

- <code class="cli-flag">&#x2D;&#x2D;org</code> <code class="cli-value">&lt;TEXT&gt;</code> — Organization ID or slug. Uses default org if not specified (see: avr config set org).
- <code class="cli-flag">&#x2D;&#x2D;json</code> <code class="cli-value">&lt;TEXT&gt;</code> — Output JSON. Pass comma-separated field names, "*" for all fields, or "?" to list available fields.
- <code class="cli-flag">-q, &#x2D;&#x2D;jq</code> <code class="cli-value">&lt;TEXT&gt;</code> — Filter --json output through a jq expression.

#### `avr repo mirror create`

Enable mirroring and place a connected repository at a location.
Expand Down Expand Up @@ -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.

Expand Down
43 changes: 0 additions & 43 deletions man/man1/avr-repo-mirror-clusters.1

This file was deleted.

1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-create.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-disable.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-enable.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-locations.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions man/man1/avr-repo-mirror-place.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-status.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion man/man1/avr-repo-mirror-unplace.1
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading
Loading