CreateToolSet is used by the tools registry.
(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig)
| 510 | |
| 511 | // CreateToolSet is used by the tools registry. |
| 512 | func CreateToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error) { |
| 513 | env, err := environment.ExpandAll(ctx, environment.ToValues(toolset.Env), runConfig.EnvProvider()) |
| 514 | if err != nil { |
| 515 | return nil, fmt.Errorf("failed to expand the tool's environment variables: %w", err) |
| 516 | } |
| 517 | // Prepend os.Environ() so spawned processes inherit the host environment |
| 518 | // while the configured toolset env still wins on key collisions |
| 519 | // (exec.Cmd dedupes with last-wins). EnvProvider is used only to expand |
| 520 | // ${...} references in toolset.Env. |
| 521 | env = append(os.Environ(), env...) |
| 522 | |
| 523 | ts := New(env, runConfig) |
| 524 | if toolset.SudoAskpass != nil && *toolset.SudoAskpass { |
| 525 | ts.handler.sudoAskpass = true |
| 526 | } |
| 527 | return ts, nil |
| 528 | } |
| 529 | |
| 530 | // New creates a new shell toolset. |
| 531 | func New(env []string, runConfig *config.RuntimeConfig) *ToolSet { |