Skip to content

Commit

Permalink
fix: env passing as array with escaped :
Browse files Browse the repository at this point in the history
  • Loading branch information
FMotalleb committed Sep 10, 2024
1 parent 133e83b commit 158d83f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/cmd_connection/cmd_utils/cmd_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,23 @@ func (ctx *Ctx) BuildExecuteParams(command string, eventData []string) (shell st
environments = append(
environments,
fmt.Sprintf("CRONTAB_GO_EVENT_ARGUMENTS=%s",
strings.Join(eventData, " "),
collectEventForEnv(eventData),
),
)
default:
ctx.logger.Warn("event argument passing mode is not supported, using default mode (omitting)")

Check warning on line 129 in core/cmd_connection/cmd_utils/cmd_context.go

View check run for this annotation

Codecov / codecov/patch

core/cmd_connection/cmd_utils/cmd_context.go#L111-L129

Added lines #L111 - L129 were not covered by tests
}
return shell, shellArgs, environments

Check warning on line 131 in core/cmd_connection/cmd_utils/cmd_context.go

View check run for this annotation

Codecov / codecov/patch

core/cmd_connection/cmd_utils/cmd_context.go#L131

Added line #L131 was not covered by tests
}

func collectEventForEnv(eventData []string) string {
builder := &strings.Builder{}
for i, part := range eventData {
builder.WriteString(strings.ReplaceAll(part, ":", "\\:"))
if i < len(eventData)-1 {
builder.WriteRune(':')

Check warning on line 139 in core/cmd_connection/cmd_utils/cmd_context.go

View check run for this annotation

Codecov / codecov/patch

core/cmd_connection/cmd_utils/cmd_context.go#L134-L139

Added lines #L134 - L139 were not covered by tests
}
}

return builder.String()

Check warning on line 143 in core/cmd_connection/cmd_utils/cmd_context.go

View check run for this annotation

Codecov / codecov/patch

core/cmd_connection/cmd_utils/cmd_context.go#L143

Added line #L143 was not covered by tests
}

0 comments on commit 158d83f

Please sign in to comment.