carlos / platform Public

cli: restore refusal answers before seeded checks (#658)

--restore with --from and another conflicting flag used to print the
seeded-instance message, which does not name --from. The restore
conflict check now runs first; without --restore the order is as before.
The refusal test covers --from combined with --kind, --addr and --role.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev e3e1980a48bdccecb7bc52eb84bd9ae91cd234c4 parent 7a77c37
2 files changed, +6 −3
  • instances_cli.go +3 −3
  • instances_restore_test.go +3 −0
diff --git a/instances_cli.go b/instances_cli.go
index fcf48a568..510a2dbf1 100644
--- a/instances_cli.go
+++ b/instances_cli.go
@@ -337,15 +337,15 @@ func runInstancesCreate(args []string) {
fs.Visit(func(f *flag.Flag) { set[f.Name] = true })
addrs := parseAddrList(*addr, set["addr"])
probe := parseProbeFlags(*healthPath, *healthStatus, set["health-path"], set["health-status"])
+ if *restore && (*from != "" || *kind != "" || set["addr"] || *role != "") {
+ log.Fatalf("instances create: %s", "a restore is a plain instance. Drop --from, --kind, --addr and --role.")
+ }
if set["at"] && (*at <= 0 || *from == "") {
log.Fatalf("instances create: %s", "at must be a transaction id, a whole number above 0")
}
if *from != "" && (*kind != "" || set["addr"] || *role != "" || *replicas != "") {
log.Fatalf("instances create: %s", "a seeded instance is an ordinary instance. Drop --kind, --addr and --role.")
}
- if *restore && (*from != "" || *kind != "" || set["addr"] || *role != "") {
- log.Fatalf("instances create: %s", "a restore is a plain instance. Drop --from, --kind, --addr and --role.")
- }
sess := requireAPISession("create", *consoleFlag)
printUsing(stdout, sess)
acct := resolvedAccount(sess, acctRaw, acctIDRaw)
diff --git a/instances_restore_test.go b/instances_restore_test.go
index b812573e7..e43834def 100644
--- a/instances_restore_test.go
+++ b/instances_restore_test.go
@@ -108,6 +108,9 @@ func TestInstancesCreateRestoreRefusesTheOtherShapes(t *testing.T) {
{"--kind", "service"},
{"--addr", "10.0.0.1:8090"},
{"--role", "replica"},
+ {"--from", "other.jam.bab.oncarlos.com", "--kind", "service"},
+ {"--from", "other.jam.bab.oncarlos.com", "--addr", "10.0.0.1:8090"},
+ {"--from", "other.jam.bab.oncarlos.com", "--role", "replica"},
} {
c := &restoreConsole{answer: restoreAnswerOn}
ts := c.serve(t)