feat(ssh): allow to customize action name
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
@@ -15,12 +15,16 @@ func NewShell(config map[string]string) *ShellAction {
|
||||
privateKey: config["privateKey"],
|
||||
user: config["user"],
|
||||
host: config["host"],
|
||||
customName: config["customName"],
|
||||
customDescription: config["customDescription"],
|
||||
}
|
||||
}
|
||||
|
||||
type ShellAction struct {
|
||||
privateKey string
|
||||
user, host string
|
||||
customName string
|
||||
customDescription string
|
||||
}
|
||||
|
||||
func (a *ShellAction) Run(ctx context.Context, params action.ActionParams) (action.ActionResult, error) {
|
||||
@@ -50,10 +54,18 @@ func (a *ShellAction) Run(ctx context.Context, params action.ActionParams) (acti
|
||||
}
|
||||
|
||||
func (a *ShellAction) Definition() action.ActionDefinition {
|
||||
name := "shell"
|
||||
description := "Run a shell command on a remote server."
|
||||
if a.customName != "" {
|
||||
name = a.customName
|
||||
}
|
||||
if a.customDescription != "" {
|
||||
description = a.customDescription
|
||||
}
|
||||
if a.host != "" && a.user != "" {
|
||||
return action.ActionDefinition{
|
||||
Name: "shell",
|
||||
Description: "Run a shell command on a remote server.",
|
||||
Name: action.ActionDefinitionName(name),
|
||||
Description: description,
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"command": {
|
||||
Type: jsonschema.String,
|
||||
@@ -64,8 +76,8 @@ func (a *ShellAction) Definition() action.ActionDefinition {
|
||||
}
|
||||
}
|
||||
return action.ActionDefinition{
|
||||
Name: "shell",
|
||||
Description: "Run a shell command on a remote server.",
|
||||
Name: action.ActionDefinitionName(name),
|
||||
Description: description,
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"command": {
|
||||
Type: jsonschema.String,
|
||||
|
||||
Reference in New Issue
Block a user