Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Jul 2, 2024
1 parent 01ae88e commit e7b9878
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (builtin *RunPythonCapabilities) Execute(ctx context.Context, _ *builtin_ar
if err != nil {
return "", stacktrace.Propagate(err, "error occurred while preparing the sh command to execute on the image")
}
fullCommandToRun := []string{shellWrapperCommand, "-c", fmt.Sprintf("{ %v; echo; } %v %v %v", commandToRun, ">>", "/proc/1/fd/1", "2>&1")}
fullCommandToRun := getFullCommandToRun(commandToRun)

// run the command passed in by user in the container
runPythonExecutionResult, err := executeWithWait(ctx, builtin.serviceNetwork, builtin.name, builtin.wait, fullCommandToRun)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (builtin *RunShCapabilities) Execute(ctx context.Context, _ *builtin_argume
if err != nil {
return "", stacktrace.Propagate(err, "error occurred while preparing the sh command to execute on the image")
}
fullCommandToRun := []string{shellWrapperCommand, "-c", fmt.Sprintf("{ %v; echo; } %v %v %v", commandToRun, ">>", "/proc/1/fd/1", "2>&1")}
fullCommandToRun := getFullCommandToRun(commandToRun)

// run the command passed in by user in the container
createDefaultDirectoryResult, err := executeWithWait(ctx, builtin.serviceNetwork, builtin.name, builtin.wait, fullCommandToRun)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,7 @@ func getTaskNameFromArgs(arguments *builtin_argument.ArgumentValuesSet) (string,
return fmt.Sprintf("task-%v", randomUuid.String()), nil
}
}

func getFullCommandToRun(commandToRun string) []string {
return []string{shellWrapperCommand, "-c", fmt.Sprintf("{ %v; echo; } %v %v %v", commandToRun, ">>", "/proc/1/fd/1", "2>&1")}
}

0 comments on commit e7b9878

Please sign in to comment.