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

Function CallPluginExecutable

pkg/devspace/plugin/hook.go:292–315  ·  view source on GitHub ↗

CallPluginExecutable is used to setup the environment for the plugin and then call the executable specified by the parameter 'main'

(main string, argv []string, extraEnvVars map[string]string, out io.Writer)

Source from the content-addressed store, hash-verified

290// CallPluginExecutable is used to setup the environment for the plugin and then
291// call the executable specified by the parameter 'main'
292func CallPluginExecutable(main string, argv []string, extraEnvVars map[string]string, out io.Writer) error {
293 env := os.Environ()
294 for k, v := range extraEnvVars {
295 env = append(env, k+"="+v)
296 }
297
298 prog := exec.Command(main, argv...)
299 prog.Env = env
300 prog.Stdin = os.Stdin
301 prog.Stdout = out
302 prog.Stderr = os.Stderr
303 if err := prog.Run(); err != nil {
304 if eerr, ok := err.(*exec.ExitError); ok {
305 os.Stderr.Write(eerr.Stderr)
306 return &exit.ReturnCodeError{ExitCode: eerr.ExitCode()}
307 } else if strings.Contains(err.Error(), "no such file or directory") {
308 return fmt.Errorf("the plugin's binary was not found (%v). Please uninstall and reinstall the plugin and make sure there are no other conflicting plugins installed (run 'devspace list plugins' to see all installed plugins)", err)
309 }
310
311 return err
312 }
313
314 return nil
315}

Callers 3

AddPredefinedVarsFunction · 0.92
AddPluginCommandsFunction · 0.85
executePluginHookAtFunction · 0.85

Calls 5

EnvironMethod · 0.65
RunMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected