InvokeWithEnv executes a plugin command with custom environment and I/O streams This method allows execution with different command/args than the plugin's default
(main string, argv []string, env []string, stdin io.Reader, stdout, stderr io.Writer)
| 112 | // InvokeWithEnv executes a plugin command with custom environment and I/O streams |
| 113 | // This method allows execution with different command/args than the plugin's default |
| 114 | func (r *SubprocessPluginRuntime) InvokeWithEnv(main string, argv []string, env []string, stdin io.Reader, stdout, stderr io.Writer) error { |
| 115 | mainCmdExp := os.ExpandEnv(main) |
| 116 | cmd := exec.Command(mainCmdExp, argv...) |
| 117 | cmd.Env = slices.Clone(os.Environ()) |
| 118 | cmd.Env = append( |
| 119 | cmd.Env, |
| 120 | "HELM_PLUGIN_NAME="+r.metadata.Name, |
| 121 | "HELM_PLUGIN_DIR="+r.pluginDir) |
| 122 | cmd.Env = append(cmd.Env, env...) |
| 123 | |
| 124 | cmd.Stdin = stdin |
| 125 | cmd.Stdout = stdout |
| 126 | cmd.Stderr = stderr |
| 127 | |
| 128 | if err := executeCmd(cmd, r.metadata.Name); err != nil { |
| 129 | return err |
| 130 | } |
| 131 | |
| 132 | return nil |
| 133 | } |
| 134 | |
| 135 | func (r *SubprocessPluginRuntime) InvokeHook(event string) error { |
| 136 | cmds := r.RuntimeConfig.PlatformHooks[event] |
no test coverage detected