feat(plugin): add plugin config setting to forward interrupt signals #3715
+42
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My previous PR got auto closed, I can't reopen it AFAIK, so am bringing this back and hopefully this can be merged: #3568
original message:
This proposal introduces a new
forwardInterruptsetting in the plugin config. When enabled, this setting sends the interrupt signal (such as CTRL+C) to the plugin itself, rather than allowing k9s to handle it and terminate the plugin. Initially, I considered naming itexitOnInterrupt, but that would imply the default action is toexitOnInterruptand as such the value will default to true, which would require broader changes. I set that idea aside for now to keep the scope focused on allowing interrupt forwarding.Why do I think it is useful? I have a couple of plugins that launch a shell from k9s as I use k9s as an overall dashboard to inspect all aspects of a k8s cluster. One example is a plugin that, on the node view, can start a shell on the node. It detects an EC2 or GCP VM and uses the correct tooling to launch a shell. However, at the moment, if I type CTRL+C in this shell, k9s sends the interrupt signal and will terminate the plugin. Hence, why I propose this flag: so I can suppress that and, instead, use CTRL+D with an EOF signal or just rely on typing
exitto terminate the plugin.For example, the following plugin allows you to hop on an EC2 node via SSM:
kubectl-ec2is a custom script that can determine the correct AWS environment based on the plugin context. My personal implementation lives here https://github.com/vandycknick/dotfiles/blob/1efa25fd6c4818b3267bb2029bdc254dd2f78814/.local/bin/kubectl-ec2 and can be different depending on your preference. The important part here is theforwardInterrupt: trueas that will send the CTRL+C signal into the shell launched by SSM instead of k9s handling the signal and killing the remote session.