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