Skip to content

feat(mirror): add repo mirror collaborators add/remove/list - #1458

Merged
toothbrush merged 4 commits into
mainfrom
mirror-collaborators-cli
Jun 18, 2026
Merged

feat(mirror): add repo mirror collaborators add/remove/list#1458
toothbrush merged 4 commits into
mainfrom
mirror-collaborators-cli

Conversation

@toothbrush

@toothbrush toothbrush commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/600

Spinoff of #1457 (based on its branch — these commands are cross-region control-plane ops that need the cross-juris transport that PR adds).

What

Adds mirror permission management verbs to the public CLI, under the existing entire repo mirror subtree:

entire repo mirror collaborators add    <github-url> <handle> [cluster-host] --role reader|writer
entire repo mirror collaborators remove <github-url> <handle> [cluster-host]
entire repo mirror collaborators list   <github-url> [cluster-host]

Ergonomics: cluster-host is an optional trailing positional defaulting to defaultClusterHost, consistent with sibling mirror create/remove. add/list honor --json; remove prints a prose confirmation to stdout (no body to render), like the other remove/revoke commands. They hit the user-facing /mirrors/collaborators endpoints (GitHub-admin gated).

coreapi regen — needs a look

Refreshed spec/core.openapi.json from the live console and ran go generate. The spec drift is clean: only the 3 collaborator ops + an unrelated GET /version (latent, no command wired).

However, go generate with gen.go's pinned ogen@v1.20.3 re-churns oas_security_gen.go by ~76 lines (Op: {}Op: []string{}). Root cause: ogen emits []string{}, and our committed files are gofmt -s-simplified to {} — the simplify pass (which lint:gofmt enforces via gofmt -l -s) isn't part of the go generate recipe in gen.go. Running gofmt -s -w after generate collapses it back, so the committed diff here is purely additive.

Fixed at the source in this PR: the //go:generate recipe in internal/coreapi/gen.go now ends with gofmt -s -w ., so a bare go generate is idempotent and CI-clean — the []string{}{} churn no longer escapes the recipe.

Test

go test ./cmd/entire/cli/ ./internal/coreapi/
mise run lint

Added unit tests for parseMirrorRole, clusterArgAt, and mirrorCollaboratorRow.


Note

Medium Risk
Changes who can pull/push mirrored repos via live GitHub-admin-gated API calls; mistakes or misuse affect access control, though enforcement remains server-side.

Overview
Adds entire repo mirror collaborators with add, remove, and list so GitHub admins can grant or revoke per-cluster mirror access (reader / writer) for a qualified handle, with optional trailing cluster-host like other mirror commands.

Introduces clusterArgAt for commands that put the cluster after extra positionals (e.g. <handle>). parseMirrorRole and table helpers validate --role and format list output; unit tests cover those paths.

Regenerates internal/coreapi from an updated OpenAPI spec (mirror collaborator endpoints plus incidental GET /version and repo mirror-suspension fields). gen.go now runs gofmt -s -w . after ogen so generate stays lint-clean.

Reviewed by Cursor Bugbot for commit 94030f4. Configure here.

Ports the per-mirror access verbs introduced in entiredb
(`entire-core admin mirrors collaborators`) to the public CLI, under
the existing `entire repo mirror` subtree:

  entire repo mirror collaborators add    <github-url> <handle> [cluster-host] --role reader|writer
  entire repo mirror collaborators remove <github-url> <handle> [cluster-host]
  entire repo mirror collaborators list   <github-url> [cluster-host]

cluster-host is an optional trailing positional defaulting to
defaultClusterHost, matching sibling create/remove. They hit the
user-facing /mirrors/collaborators endpoints (live GitHub-admin gated)
and inherit the cross-juris transport from the parent branch.

coreapi client regenerated from a refreshed spec; the refresh also
pulls in GET /version (latent, no command wired).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@toothbrush
toothbrush requested a review from a team as a code owner June 18, 2026 07:30
Copilot AI review requested due to automatic review settings June 18, 2026 07:30
Comment thread cmd/entire/cli/repo_mirror_collaborators.go
Comment thread cmd/entire/cli/repo_mirror_collaborators.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds public CLI support for managing per-mirror collaborators under entire repo mirror collaborators, backed by regenerated internal/coreapi client code for the new /mirrors/collaborators endpoints (plus a newly surfaced /version endpoint in the spec).

Changes:

  • Add repo mirror collaborators add|remove|list commands, including role parsing and table rendering for human output.
  • Refactor cluster-host positional parsing via clusterArgAt, and add unit tests for the new helpers/row formatting.
  • Regenerate internal/coreapi OpenAPI specs + ogen output to include mirror-collaborator APIs (and /version).

Reviewed changes

Copilot reviewed 4 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/coreapi/spec/core.openapi.json Updates the OpenAPI source spec to include /mirrors/collaborators and /version.
internal/coreapi/spec/core.gen.json Regenerated normalized spec used by codegen (new schemas + endpoints).
internal/coreapi/oas_validators_gen.go Generated validators for new request/response models and enum types.
internal/coreapi/oas_security_gen.go Generated security-operation maps updated for new mirror-collaborator ops.
internal/coreapi/oas_schemas_gen.go Generated Go schema/types for collaborator and version endpoints (plus new repo fields).
internal/coreapi/oas_response_decoders_gen.go Generated response decoders for getVersion + collaborator endpoints.
internal/coreapi/oas_request_encoders_gen.go Generated request encoder for grantMirrorCollaborator.
internal/coreapi/oas_parameters_gen.go Generated parameter structs for list/revoke mirror collaborators.
internal/coreapi/oas_operations_gen.go Registers new operation names for codegen/client wiring.
internal/coreapi/oas_client_gen.go Generated client methods for getVersion and mirror collaborator add/list/remove.
cmd/entire/cli/repo_mirror.go Adds collaborators subtree to repo mirror, and introduces clusterArgAt.
cmd/entire/cli/repo_mirror_test.go Adds tests for clusterArgAt, parseMirrorRole, and mirrorCollaboratorRow.
cmd/entire/cli/repo_mirror_collaborators.go Implements `repo mirror collaborators add
Files not reviewed (9)
  • internal/coreapi/oas_client_gen.go: Generated file
  • internal/coreapi/oas_json_gen.go: Generated file
  • internal/coreapi/oas_operations_gen.go: Generated file
  • internal/coreapi/oas_parameters_gen.go: Generated file
  • internal/coreapi/oas_request_encoders_gen.go: Generated file
  • internal/coreapi/oas_response_decoders_gen.go: Generated file
  • internal/coreapi/oas_schemas_gen.go: Generated file
  • internal/coreapi/oas_security_gen.go: Generated file
  • internal/coreapi/oas_validators_gen.go: Generated file

Comment thread cmd/entire/cli/repo_mirror_collaborators.go
Comment thread cmd/entire/cli/repo_mirror_collaborators.go
toothbrush and others added 2 commits June 18, 2026 17:05
Review feedback: the add success line went to stderr, inconsistent with
remove (cmd.Printf → stdout) and sibling mirror create/remove. Move it to
stdout so scripted/piped use is consistent across the subtree.

remove keeps prose on stdout and ignores --json, matching every other
remove/revoke in the CLI (no 204 body to render); the PR description is
corrected to not over-claim --json there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ogen emits empty role slices as []string{}, but lint:gofmt enforces the
simplified {} form (gofmt -l -s). Adding gofmt -s -w . as the final
//go:generate step makes a bare `go generate` idempotent and CI-clean
instead of leaving ~76 lines of churn that lint rejects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@toothbrush

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 94030f4. Configure here.

Trail review: list used clusterArg(args) while add/remove use
clusterArgAt(args, N). Behaviour is identical (clusterArg delegates to
clusterArgAt(..., 1)), but the explicit index reads uniformly across the
three collaborator commands.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Base automatically changed from fix/coreapi-cross-juris-transport to main June 18, 2026 08:00
@toothbrush
toothbrush merged commit 2717ad3 into main Jun 18, 2026
9 checks passed
@toothbrush
toothbrush deleted the mirror-collaborators-cli branch June 18, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants