feat(server): add screenshot command#1435
Conversation
Adds a new `hcloud server screenshot -o screenshot.png <server>`, that take a screenshot of the server console using a VNC client.
|
Still missing from this PR:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1435 +/- ##
==========================================
- Coverage 72.80% 72.21% -0.59%
==========================================
Files 300 302 +2
Lines 11104 11209 +105
==========================================
+ Hits 8084 8095 +11
- Misses 2120 2214 +94
Partials 900 900
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| * [hcloud server request-console](hcloud_server_request-console.md) - Request a WebSocket VNC console for a Server | ||
| * [hcloud server reset](hcloud_server_reset.md) - Reset a Server | ||
| * [hcloud server reset-password](hcloud_server_reset-password.md) - Reset the root password of a Server | ||
| * [hcloud server screenshot](hcloud_server_screenshot.md) - Take a screenshot of the Server VNC console |
There was a problem hiding this comment.
I would prefer to mark this new command as experimental initially.
|
Would be awesome if users could directly show it in their terminal. For example with the Kitty graphics protocol I can run this right now to render the image in the terminal (Ghostty): hcloud server screenshot <name>
viu screenshot.pngIf hcloud server screenshot <name> -o - | viu - |
| } | ||
| defer vncConn.Close() | ||
|
|
||
| go func() { |
There was a problem hiding this comment.
The server message channel should be closed or we might end up waiting for it endlessly.
| go func() { | |
| go func() { | |
| defer close(vncCfg.ServerMessageCh) |
| } | ||
|
|
||
| slog.Debug("writing image to file") | ||
| if err := os.WriteFile(filename, imgData.Bytes(), 0600); err != nil { |
There was a problem hiding this comment.
This overwrites screenshot.png in the current dir without asking. Should we fail if the file already exists and add an explicit --overwrite flag?
Adds a new
hcloud server screenshot -o screenshot.png <server>, that take a screenshot of the server console using a VNC client.Fixes #1420