-
Notifications
You must be signed in to change notification settings - Fork 291
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
Support Help() in plugins #948
Conversation
internal/executor/helm/executor.go
Outdated
@@ -131,6 +131,12 @@ func (e *Executor) Execute(ctx context.Context, in executor.ExecuteInput) (execu | |||
} | |||
} | |||
|
|||
func (Executor) Help() executor.HelpResponse { | |||
return executor.HelpResponse{ | |||
Help: (&HelpCommand{}).Help(), |
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.
What should happen with existing Helm plugin help
sub-command?
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 it should be totally overriden, so it shouldn't be possible to run such underlying sub-command. The plugin shouldn expose help only via gRPC API, and shouldn't handle {pluginName} help
as user won't be able to execute it.
ea72bff
to
f047d7b
Compare
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.
Here are some comments from the code review. I'll test it after fixes 🙂
You can also provide some small instruction in the PR desc how did you test it (executor with help like helm, or the one with empty help, like echo).
pkg/api/plugin.go
Outdated
type HelpOutput struct { | ||
Help string | ||
} | ||
|
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.
Desn't seem to be used anywhere 🤔 If it is, then where and why the Help
property is string?
internal/executor/helm/executor.go
Outdated
@@ -131,6 +131,12 @@ func (e *Executor) Execute(ctx context.Context, in executor.ExecuteInput) (execu | |||
} | |||
} | |||
|
|||
func (Executor) Help() executor.HelpResponse { | |||
return executor.HelpResponse{ | |||
Help: (&HelpCommand{}).Help(), |
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 it should be totally overriden, so it shouldn't be possible to run such underlying sub-command. The plugin shouldn expose help only via gRPC API, and shouldn't handle {pluginName} help
as user won't be able to execute it.
proto/executor.proto
Outdated
@@ -33,7 +33,12 @@ message JSONSchema { | |||
string refURL = 2; |
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.
This new API should be documented. Please open PR to Botkube docs and ensure the plugins docs (e.g. https://docs.botkube.io/plugin/custom-executor) are up to date.
pkg/execute/executor.go
Outdated
if isHelpCmd(cmdCtx.Args) { | ||
msg, err := e.pluginExecutor.Help(ctx, e.conversation.ExecutorBindings, cmdCtx.Args, cmdCtx.CleanCmd) | ||
if err != nil { | ||
e.log.Errorf("while executing help command %q: %s", cmdCtx.CleanCmd, err.Error()) | ||
return empty | ||
} | ||
return msg | ||
} |
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 report the help command usage as well
- Once you add the command reporting, then I think the code can look even more complicated - consider extracting this help usage to a separate small method.
pkg/execute/plugin_executor.go
Outdated
func isHelpCmd(s []string) bool { | ||
if len(s) < 2 { | ||
return false | ||
} | ||
return s[1] == "help" | ||
} |
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.
It is used only once, and only in the execute/executor.go
, so please move the usage there.
763773d
to
44bf4db
Compare
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.
In general LGTM, just a final batch of small comments 👍
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.
LGTM 👍 E2E tests are failing because of the formatting issue of the Helm help, but basically everything works well and all comments were addressed 👌 Thanks!
Provide an option to get plugin related help #893
Changes proposed in this pull request:
Help()
function to the executor interfaceTest
make gen-plugins-index
rm -rf /tmp/plugin*
env PLUGIN_SERVER_HOST=http://localhost go run test/helpers/plugin_server.go
go run cmd/botkube/main.go
gh
,helm
,echo
Related issue(s)
Resolves #893