From 0513a327f63b2d6a71a4f78c72ce9afd31f368d9 Mon Sep 17 00:00:00 2001 From: mudler Date: Thu, 20 Mar 2025 19:15:12 +0100 Subject: [PATCH] feat(ssh): allow to customize action name Signed-off-by: mudler --- services/actions/shell.go | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/services/actions/shell.go b/services/actions/shell.go index 3460460..36302bb 100644 --- a/services/actions/shell.go +++ b/services/actions/shell.go @@ -12,15 +12,19 @@ import ( func NewShell(config map[string]string) *ShellAction { return &ShellAction{ - privateKey: config["privateKey"], - user: config["user"], - host: config["host"], + privateKey: config["privateKey"], + user: config["user"], + host: config["host"], + customName: config["customName"], + customDescription: config["customDescription"], } } type ShellAction struct { - privateKey string - user, host string + 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,