Skip to content

Commit

Permalink
feat(server): return password on rebuild (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
apricote authored Mar 10, 2023
1 parent 0404541 commit 940fc1e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/cmd/server/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ var RebuildCommand = base.Cmd{
opts := hcloud.ServerRebuildOpts{
Image: image,
}
action, _, err := client.Server().Rebuild(ctx, server, opts)
result, _, err := client.Server().RebuildWithResult(ctx, server, opts)
if err != nil {
return err
}

if err := waiter.ActionProgress(ctx, action); err != nil {
if err := waiter.ActionProgress(ctx, result.Action); err != nil {
return err
}

fmt.Printf("Server %d rebuilt with image %s\n", server.ID, image.Name)

// Only print the root password if it's not empty,
// which is only the case if it wasn't created with an SSH key.
if result.RootPassword != "" {
fmt.Printf("Root password: %s\n", result.RootPassword)
}

return nil
},
}

0 comments on commit 940fc1e

Please sign in to comment.