MCPcopy Index your code
hub / github.com/helm/helm / runPostrenderer

Method runPostrenderer

internal/plugin/runtime_subprocess.go:229–278  ·  view source on GitHub ↗
(input *Input)

Source from the content-addressed store, hash-verified

227}
228
229func (r *SubprocessPluginRuntime) runPostrenderer(input *Input) (*Output, error) {
230 if _, ok := input.Message.(schema.InputMessagePostRendererV1); !ok {
231 return nil, fmt.Errorf("plugin %q input message does not implement InputMessagePostRendererV1", r.metadata.Name)
232 }
233
234 env := ParseEnv(os.Environ())
235 maps.Insert(env, maps.All(r.EnvVars))
236 maps.Insert(env, maps.All(ParseEnv(input.Env)))
237 env["HELM_PLUGIN_NAME"] = r.metadata.Name
238 env["HELM_PLUGIN_DIR"] = r.pluginDir
239
240 msg := input.Message.(schema.InputMessagePostRendererV1)
241 cmds := r.RuntimeConfig.PlatformCommand
242 command, args, err := PrepareCommands(cmds, true, msg.ExtraArgs, env)
243 if err != nil {
244 return nil, fmt.Errorf("failed to prepare plugin command: %w", err)
245 }
246
247 cmd := exec.Command(
248 command,
249 args...)
250
251 stdin, err := cmd.StdinPipe()
252 if err != nil {
253 return nil, err
254 }
255
256 go func() {
257 defer stdin.Close()
258 io.Copy(stdin, msg.Manifests)
259 }()
260
261 postRendered := &bytes.Buffer{}
262 stderr := &bytes.Buffer{}
263
264 cmd.Env = FormatEnv(env)
265 cmd.Stdout = postRendered
266 cmd.Stderr = stderr
267
268 slog.Debug("executing plugin command", slog.String("pluginName", r.metadata.Name), slog.String("command", cmd.String()))
269 if err := executeCmd(cmd, r.metadata.Name); err != nil {
270 return nil, err
271 }
272
273 return &Output{
274 Message: schema.OutputMessagePostRendererV1{
275 Manifests: postRendered,
276 },
277 }, nil
278}

Callers 1

InvokeMethod · 0.95

Calls 8

ParseEnvFunction · 0.85
PrepareCommandsFunction · 0.85
FormatEnvFunction · 0.85
executeCmdFunction · 0.85
AllMethod · 0.80
CloseMethod · 0.80
CopyMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected