Skip to content

Commit 4186344

Browse files
Update 'tiger service fork' to output service info like 'tiger service create'
1 parent dbeea3d commit 4186344

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

internal/tiger/cmd/service.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,7 @@ func buildServiceForkCmd() *cobra.Command {
11041104
var forkToTimestamp string
11051105
var forkCPU int
11061106
var forkMemory int
1107+
var forkWithPassword bool
11071108

11081109
cmd := &cobra.Command{
11091110
Use: "fork [service-id]",
@@ -1320,20 +1321,26 @@ Examples:
13201321
}
13211322

13221323
// Handle wait behavior
1324+
var result error
13231325
if forkNoWait {
13241326
fmt.Fprintf(statusOutput, "⏳ Service is being forked. Use 'tiger service list' to check status.\n")
1325-
return nil
1327+
} else {
1328+
// Wait for service to be ready
1329+
fmt.Fprintf(statusOutput, "⏳ Waiting for fork to complete (timeout: %v)...\n", forkWaitTimeout)
1330+
forkedService.Status, result = waitForServiceReady(client, projectID, forkedServiceID, forkWaitTimeout, statusOutput)
1331+
if result != nil {
1332+
fmt.Fprintf(statusOutput, "❌ %v\n", result)
1333+
} else {
1334+
fmt.Fprintf(statusOutput, "🎉 Service fork completed successfully!\n")
1335+
printConnectMessage(statusOutput, passwordSaved, forkNoSetDefault, forkedServiceID)
1336+
}
13261337
}
13271338

1328-
// Wait for service to be ready with custom timeout
1329-
fmt.Fprintf(statusOutput, "⏳ Waiting for fork to complete (timeout: %v)...\n", forkWaitTimeout)
1330-
if _, err := waitForServiceReady(client, projectID, forkedServiceID, forkWaitTimeout, statusOutput); err != nil {
1331-
return err
1339+
if err := outputService(cmd, forkedService, cfg.Output, forkWithPassword); err != nil {
1340+
fmt.Fprintf(statusOutput, "⚠️ Warning: Failed to output service details: %v\n", err)
13321341
}
1333-
fmt.Fprintf(statusOutput, "🎉 Service fork completed successfully!\n")
1334-
printConnectMessage(statusOutput, passwordSaved, forkNoSetDefault, serviceID)
1335-
return nil
13361342

1343+
return result
13371344
case 401:
13381345
return exitWithCode(ExitAuthenticationError, fmt.Errorf("authentication failed: invalid API key"))
13391346
case 403:
@@ -1364,6 +1371,7 @@ Examples:
13641371
// Resource customization flags
13651372
cmd.Flags().IntVar(&forkCPU, "cpu", 0, "CPU allocation in millicores (inherits from source if not specified)")
13661373
cmd.Flags().IntVar(&forkMemory, "memory", 0, "Memory allocation in gigabytes (inherits from source if not specified)")
1374+
cmd.Flags().BoolVar(&forkWithPassword, "with-password", false, "Include initial password in output")
13671375

13681376
return cmd
13691377
}

0 commit comments

Comments
 (0)