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

Function CallPluginExecutableInBackground

pkg/devspace/plugin/hook.go:261–288  ·  view source on GitHub ↗
(main string, argv []string, extraEnvVars map[string]string)

Source from the content-addressed store, hash-verified

259}
260
261func CallPluginExecutableInBackground(main string, argv []string, extraEnvVars map[string]string) error {
262 env := os.Environ()
263 for k, v := range extraEnvVars {
264 env = append(env, k+"="+v)
265 }
266
267 stderrOut := &bytes.Buffer{}
268 prog := exec.Command(main, argv...)
269 prog.Env = env
270 prog.Stderr = stderrOut
271 if err := prog.Start(); err != nil {
272 if strings.Contains(err.Error(), "no such file or directory") {
273 return fmt.Errorf("the plugin's binary was not found (%v). Please reinstall the plugin and make sure there are no other conflicting plugins installed (run 'devspace list plugins' to see all installed plugins)", err)
274 }
275
276 return err
277 }
278
279 go func() {
280 err := prog.Wait()
281 if err != nil {
282 if eerr, ok := err.(*exec.ExitError); ok {
283 os.Stderr.Write([]byte(fmt.Sprintf("Plugin Hook %s failed (code: %d): %s", main+" "+strings.Join(argv, " "), eerr.ExitCode(), stderrOut.String())))
284 }
285 }
286 }()
287 return nil
288}
289
290// CallPluginExecutable is used to setup the environment for the plugin and then
291// call the executable specified by the parameter 'main'

Callers 1

executePluginHookAtFunction · 0.85

Calls 7

StringMethod · 0.95
EnvironMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
ErrorMethod · 0.45
ErrorfMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected