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)
| 290 | // CallPluginExecutable is used to setup the environment for the plugin and then |
| 291 | // call the executable specified by the parameter 'main' |
| 292 | func 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 | } |
no test coverage detected