chore: Cleanup executor shell passing (#556)

This commit is contained in:
James Read 2025-04-07 21:48:45 +01:00 committed by GitHub
parent fa44e958d8
commit 88f639d29f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View File

@ -46,13 +46,13 @@ func parseCommandForReplacements(rawShellCommand string, values map[string]strin
return rawShellCommand, usedArguments, nil return rawShellCommand, usedArguments, nil
} }
func parseActionArguments(rawShellCommand string, values map[string]string, action *config.Action, actionTitle string, entityPrefix string) (string, error) { func parseActionArguments(values map[string]string, action *config.Action, actionTitle string, entityPrefix string) (string, error) {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"actionTitle": actionTitle, "actionTitle": actionTitle,
"cmd": rawShellCommand, "cmd": action.Shell,
}).Infof("Action parse args - Before") }).Infof("Action parse args - Before")
rawShellCommand, usedArgs, err := parseCommandForReplacements(rawShellCommand, values) rawShellCommand, usedArgs, err := parseCommandForReplacements(action.Shell, values)
if err != nil { if err != nil {
return "", err return "", err

View File

@ -33,14 +33,14 @@ func TestArgumentValueNullable(t *testing.T) {
"count": "", "count": "",
} }
out, err := parseActionArguments(a1.Shell, values, &a1, a1.Title, "") out, err := parseActionArguments(values, &a1, a1.Title, "")
assert.Equal(t, "echo 'Releasing hounds'", out) assert.Equal(t, "echo 'Releasing hounds'", out)
assert.Nil(t, err) assert.Nil(t, err)
a1.Arguments[0].RejectNull = true a1.Arguments[0].RejectNull = true
_, err = parseActionArguments(a1.Shell, values, &a1, a1.Title, "") _, err = parseActionArguments(values, &a1, a1.Title, "")
assert.NotNil(t, err) assert.NotNil(t, err)
} }
@ -61,7 +61,7 @@ func TestArgumentNameNumbers(t *testing.T) {
"person1name": "Fred", "person1name": "Fred",
} }
out, err := parseActionArguments(a1.Shell, values, &a1, a1.Title, "") out, err := parseActionArguments(values, &a1, a1.Title, "")
assert.Equal(t, "echo 'Tickling Fred'", out) assert.Equal(t, "echo 'Tickling Fred'", out)
assert.Nil(t, err) assert.Nil(t, err)
@ -81,7 +81,7 @@ func TestArgumentNotProvided(t *testing.T) {
values := map[string]string{} values := map[string]string{}
out, err := parseActionArguments(a1.Shell, values, &a1, a1.Title, "") out, err := parseActionArguments(values, &a1, a1.Title, "")
assert.Equal(t, "", out) assert.Equal(t, "", out)
assert.Equal(t, err.Error(), "Required arg not provided: personName") assert.Equal(t, err.Error(), "Required arg not provided: personName")

View File

@ -395,7 +395,7 @@ func stepParseArgs(req *ExecutionRequest) bool {
req.Arguments["ot_executionTrackingId"] = req.TrackingID req.Arguments["ot_executionTrackingId"] = req.TrackingID
req.Arguments["ot_username"] = req.AuthenticatedUser.Username req.Arguments["ot_username"] = req.AuthenticatedUser.Username
req.finalParsedCommand, err = parseActionArguments(req.Action.Shell, req.Arguments, req.Action, req.logEntry.ActionTitle, req.EntityPrefix) req.finalParsedCommand, err = parseActionArguments(req.Arguments, req.Action, req.logEntry.ActionTitle, req.EntityPrefix)
if err != nil { if err != nil {
req.logEntry.Output = err.Error() req.logEntry.Output = err.Error()

View File

@ -82,7 +82,7 @@ func TestArgumentNameCamelCase(t *testing.T) {
"personName": "Fred", "personName": "Fred",
} }
out, err := parseActionArguments(a1.Shell, values, a1, a1.Title, "") out, err := parseActionArguments(values, a1, a1.Title, "")
assert.Equal(t, "echo 'Tickling Fred'", out) assert.Equal(t, "echo 'Tickling Fred'", out)
assert.Nil(t, err) assert.Nil(t, err)
@ -104,7 +104,7 @@ func TestArgumentNameSnakeCase(t *testing.T) {
"person_name": "Fred", "person_name": "Fred",
} }
out, err := parseActionArguments(a1.Shell, values, a1, a1.Title, "") out, err := parseActionArguments(values, a1, a1.Title, "")
assert.Equal(t, "echo 'Tickling Fred'", out) assert.Equal(t, "echo 'Tickling Fred'", out)
assert.Nil(t, err) assert.Nil(t, err)