-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for terminal size when executing command inside a container #983
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sign off your commits for DCO, and remove unused imports.
Signed-off-by: armandpicard <armandpicard71@gmail.com>
Signed-off-by: armandpicard <armandpicard71@gmail.com>
c30fda0
to
a0f42ab
Compare
pod_exec_terminal size example Signed-off-by: armandpicard <armandpicard71@gmail.com>
Signed-off-by: armandpicard <armandpicard71@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great. The example is very readable. The refactor is also nice despite the heavy change of the remote_command loop, and am slightly confused about some details there. It's the kind of change that makes me wish we have better tests for some of the nitty-gritty of the ws handling, but I am ultimately pro this change. The way it plugs into crossterm is really nice.
Also, sorry, I did not get to this sooner. Had missed it entirely :( |
Signed-off-by: armandpicard <armandpicard71@gmail.com>
Signed-off-by: armandpicard <armandpicard71@gmail.com>
I played around a bit with this now, and it does seem to work, but it's an incredibly frustrating example atm because every 3rd keystroke is ignored if it happens at a certain time. not quite sure what is causing it, but something in the example is not plumbed up correctly. but crucially it does a much better job than the |
examples/pod_exec_terminal_size.rs
Outdated
@@ -0,0 +1,134 @@ | |||
use futures::{channel::mpsc::Sender, SinkExt, StreamExt}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should rename this to pod_shell_crossterm
to match the other example and highlight functionality
The keystroke issue is related to crossterm. It looks likes crossterm is also reading stdin and get the keystroke and send it on the EventStream, that why we don't get it in stdin. I'll try to dig more into it. |
Signed-off-by: armandpicard <armandpicard71@gmail.com>
I can't find any way to avoid the EventStream from reading on stdin so I use just use signal stream on SIGWINCH. This work on unix I don't know if I should also make it work in Windows ? |
Thanks a lot, that feels a lot more usable now!
I think SIGWINCH is the right thing for us to do; minimal and keeps the code focused on what WE do, plus it serves the majority of users on mac/linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am happy to merge this as is, but will want to rename the example to pod_shell_crossterm
unless you have objections to that.
Signed-off-by: armandpicard <armandpicard71@gmail.com>
Thanks! I'm going to update the branch for CI and start the job so it's all good to go before merging. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #983 +/- ##
==========================================
+ Coverage 72.34% 72.48% +0.13%
==========================================
Files 65 65
Lines 4715 4757 +42
==========================================
+ Hits 3411 3448 +37
- Misses 1304 1309 +5
|
Ah, ok so two issues:
Just force push over my change if necessary. |
…+ run fmt Signed-off-by: armandpicard <armandpicard71@gmail.com>
I've been kind with Windows user, I've made the example work on Windows but without handling the terminal size change, I just send the size when the program start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah, that is nicer. partial windows support at least!
Thank you so much! |
…er (kube-rs#983) * Add support for terminal size when executing command inside a container Signed-off-by: armandpicard <armandpicard71@gmail.com> * remove unused import + fix example Signed-off-by: armandpicard <armandpicard71@gmail.com> * Use crossterm::event::EventStream to get terminal change in pod_exec_terminal size example Signed-off-by: armandpicard <armandpicard71@gmail.com> * Fix error when terminal_resize_tx is None Signed-off-by: armandpicard <armandpicard71@gmail.com> * Add some comments Signed-off-by: armandpicard <armandpicard71@gmail.com> * Fix typos Co-authored-by: kazk <kazk.dev@gmail.com> Signed-off-by: armand picard <33733022+armandpicard@users.noreply.github.com> * Fix: uniformize message send Signed-off-by: armandpicard <armandpicard71@gmail.com> * Remove crossterm event stream Signed-off-by: armandpicard <armandpicard71@gmail.com> * Rename example pod_shell_crossterm Signed-off-by: armandpicard <armandpicard71@gmail.com> * Make example run on window but without handling terminal size change + run fmt Signed-off-by: armandpicard <armandpicard71@gmail.com> Signed-off-by: armandpicard <armandpicard71@gmail.com> Signed-off-by: armand picard <33733022+armandpicard@users.noreply.github.com> Co-authored-by: kazk <kazk.dev@gmail.com> Co-authored-by: Eirik A <sszynrae@gmail.com>
Motivation
Adding support for terminal size when executing command in a container allow to reproduce "kubectl exec -it example -- sh" which can be needed when creating developers tools for example.
Solution