MCPcopy Index your code
hub / github.com/devspace-sh/devspace / executeShellCommand

Function executeShellCommand

cmd/run.go:276–295  ·  view source on GitHub ↗
(ctx context.Context, shellCommand string, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader)

Source from the content-addressed store, hash-verified

274}
275
276func executeShellCommand(ctx context.Context, shellCommand string, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader) error {
277 extraEnv := map[string]string{}
278 for k, v := range variables {
279 extraEnv[k] = fmt.Sprintf("%v", v)
280 }
281
282 // execute the command in a shell
283 err := engine.ExecuteSimpleShellCommand(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, args...)
284 if err != nil {
285 if status, ok := interp.IsExitStatus(err); ok {
286 return &exit.ReturnCodeError{
287 ExitCode: int(status),
288 }
289 }
290
291 return errors.Wrap(err, "execute command")
292 }
293
294 return nil
295}
296
297// ExecuteCommand executes a command from the config
298func ExecuteCommand(ctx context.Context, cmd *latest.CommandConfig, variables map[string]interface{}, args []string, dir string, stdout io.Writer, stderr io.Writer, stdin io.Reader) error {

Callers 1

executeCommandWithAfterFunction · 0.85

Calls 3

NewVariableEnvProviderFunction · 0.92
EnvironMethod · 0.65

Tested by

no test coverage detected