feat(mirror): offer a cluster picker in the interactive one-shot create · Entire
feat(mirror): offer a cluster picker in the interactive one-shot create
9aafb5d→main·
toothbrush·1w ago·3 files·+111 added/-11 removed
When repo mirror create <github-url> is run on a terminal without a
[cluster-host], fetch the control plane's cluster catalog and offer it as a
single-select — pre-selecting the caller's jurisdiction default, and skipping
the prompt entirely when only one cluster exists (the same prompt-only-when-there-is-a-choice shape as repo clone). Non-interactive invocations keep the fixed defaultClusterHost so scripts stay stable and offline-resolvable.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Sessions
573bbdeb391dView transcript
Changes
3
cmd/entire/cli
Mrepo_mirror.go+21/-11
Mrepo_mirror_create_wizard.go+71
Mrepo_mirror_test.go+19
48 unmodified lines
// defaultClusterHost is the cluster the positional-arg mirror commands target
// when the caller omits the <cluster-host> argument. The no-arg create wizard
// instead enumerates real clusters from the catalog (GET /api/v1/clusters, see
// availableRegions in repo_mirror_create_wizard.go); this stays as the
// single-region fallback for the explicit `create <github-url>` form.
// and the interactive one-shot `create <github-url>` instead enumerate real
// clusters from the catalog (GET /api/v1/clusters, see availableRegions and
// resolveOneShotClusterHost in repo_mirror_create_wizard.go); this stays as
// the fixed fallback for non-interactive invocations, so scripts keep a
// stable, offline-resolvable default.
const defaultClusterHost = "aws-us-east-2.entire.io"
// clusterArg returns the cluster host from the optional second positional
// resolveOneShotClusterHost picks the cluster repo mirror create // <github-url> targets when [cluster-host] is omitted. Non-interactive
// callers keep the fixed defaultClusterHost so scripts stay stable and
// offline-resolvable; on a terminal the control plane's cluster catalog is
// offered as a single-select (skipped when only one cluster exists),
// pre-selecting the caller's jurisdiction default — the same
// prompt-only-when-there-is-a-choice shape repo clone uses for
// multi-cluster placements.
func resolveOneShotClusterHost(cmd *cobra.Command) (string, error) {
if !interactive.CanPromptInteractively() {
return defaultClusterHost, nil
}
... // truncated for clarity
}
// pickOneCluster runs the one-shot create's cluster single-select, // pre-selecting the default cluster for the caller's jurisdiction. A clean // cancel (Ctrl+C / cancelled ctx) surfaces as a SilentError so the create // stops instead of falling through to a cluster the user didn't choose. func pickOneCluster(ctx context.Context, w io.Writer, regions []regionChoice, jurisdiction string) (string, error) { ... }
// mirrorTarget is one unit of work: a selected repo to be mirrored into a // selected region. The wizard creates the cross-product of repos × regions. type mirrorTarget struct { ... }
// TestResolveOneShotClusterHost_NonInteractive locks in that a non-interactive
// repo mirror create <github-url> keeps the fixed defaultClusterHost without
// dialing the control plane — scripts must get a stable, offline default. Under
// go test, CanPromptInteractively() is false, so this exercises exactly the
// script path; no server is running, so any catalog fetch would error.
func TestResolveOneShotClusterHost_NonInteractive(t *testing.T) {
t.Parallel()
cmd := &cobra.Command{}
cmd.SetContext(t.Context())
got, err := resolveOneShotClusterHost(cmd)
if err != nil {
t.Fatalf("resolveOneShotClusterHost() error = %v", err)
}
if got != defaultClusterHost {
t.Errorf("resolveOneShotClusterHost() = %q, want default %q", got, defaultClusterHost)
}
}
func TestClusterArgAt(t *testing.T) { t.Parallel() // clusterArgAt reads the cluster from the optional positional at an }