Skip to content
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

app: frontend: plugins: Add runCommand for shell commands in Electron app #1677

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

illume
Copy link
Collaborator

@illume illume commented Jan 29, 2024

So that some local shell commands can be run from inside a plugin.
This communicates the process interaction with the Electron app render process via ipc.

The interface exposed is a subset of the node spawn() which is what is used on the app side. It only implements the parts which are already used by the plugin we have in mind.

The interface supports streaming stdout and stderr, and getting exit codes.

Note, this supports running multiple commands at the same time. The complexities of this are hidden to the user of runCommand.

It limits the commands that can be run to only minikube and az so far. If there is a need for more this can be extended later. This is intended as a way to limit potential misuse.

How to test?

The app-menu example plugin has been extended to add a minikube menu which displays minikube status.

cd plugins/headlamp-plugin
npm i
npm run build
npm pack
cd ../examples/app-menus
npm i ../../headlamp-plugin/kinvolk-headlamp-plugin-0.9.0-alpha.2.tgz
npm start

Now in a separate terminal

cd app
npm i
npm start

Now with the app-menus example plugin there should be a minikube menu shown which when extended shows minikube status.

image

For the create cluster feature #1682

… app

So that some local shell commands can be run from inside a plugin.
This communicates the process interaction with the Electron app render
process via ipc.

The interface exposed is a subset of the node spawn() which is what is
used on the app side. It only implements the parts which are already
used by the plugin we have in mind.

The interface supports streaming stdout and stderr, and getting exit
codes.

Note, this supports running multiple commands at the same time. The
complexities of this are hidden to the user of runCommand.

It limits the commands that can be run to only minikube and az so
far. If there is a need for more this can be extended later. This is
intended as a way to limit potential misuse.

The app-menu example plugin has been extended to add a minikube menu
which displays minikube status.

Signed-off-by: René Dudfield <renedudfield@microsoft.com>
@illume illume added enhancement New feature or request frontend Issues related to the frontend plugins app labels Jan 29, 2024
Copy link
Contributor

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @illume. Some question/suggestions. Yet to test it.

app/electron/main.ts Show resolved Hide resolved
app/electron/main.ts Outdated Show resolved Hide resolved
frontend/src/components/App/runCommand.ts Outdated Show resolved Hide resolved
@illume
Copy link
Collaborator Author

illume commented Jan 29, 2024

Thanks for the review :) I'll make those changes.

@illume
Copy link
Collaborator Author

illume commented Jan 30, 2024

@knrt10 thanks, I addressed your notes.

@illume illume requested a review from knrt10 January 30, 2024 06:36
Copy link
Contributor

@knrt10 knrt10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @illume . Tested it.
Screenshot 2024-01-30 at 12 22 07 PM

Note: Not in the scope of this PR, but maybe we can edit the plugin later to show app menu for the current cluster that it is in. i.e. if there are multiple clusters when open it should show its status.

For example, here knrt10 cluster is opened it should show it's status

Screenshot 2024-01-30 at 12 28 42 PM

Again, it's not in the scope of this PR, just something we could improve later.

@illume illume merged commit d0aea57 into main Jan 30, 2024
9 checks passed
@illume illume deleted the runCommand branch January 30, 2024 07:25
@joaquimrocha joaquimrocha added this to the v0.23.0 milestone Jan 30, 2024
@joaquimrocha
Copy link
Collaborator

fixes #1670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app enhancement New feature or request frontend Issues related to the frontend plugins
Projects
Development

Successfully merging this pull request may close these issues.

3 participants